Assignment for RMIT Mixed Reality in 2020
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

144 lines
5.3 KiB

  1. /************************************************************************************
  2. Filename : ONSPReflectionCustomGUI.cs
  3. Content : GUI for Oculus Spatializer mixer effect
  4. Copyright : Copyright (c) Facebook Technologies, LLC and its affiliates. All rights reserved.
  5. Licensed under the Oculus SDK Version 3.5 (the "License");
  6. you may not use the Oculus SDK except in compliance with the License,
  7. which is provided at the time of installation or download, or which
  8. otherwise accompanies this software in either electronic or hard copy form.
  9. You may obtain a copy of the License at
  10. https://developer.oculus.com/licenses/sdk-3.5/
  11. Unless required by applicable law or agreed to in writing, the Oculus SDK
  12. distributed under the License is distributed on an "AS IS" BASIS,
  13. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. See the License for the specific language governing permissions and
  15. limitations under the License.
  16. ************************************************************************************/
  17. using UnityEditor;
  18. using UnityEngine;
  19. using System.Runtime.InteropServices;
  20. public class OculusSpatializerReflectionCustomGUI : IAudioEffectPluginGUI
  21. {
  22. public override string Name
  23. {
  24. get { return "OculusSpatializerReflection"; }
  25. }
  26. public override string Description
  27. {
  28. get { return "Reflection parameters for Oculus Spatializer"; }
  29. }
  30. public override string Vendor
  31. {
  32. get { return "Oculus"; }
  33. }
  34. public override bool OnGUI(IAudioEffectPlugin plugin)
  35. {
  36. float fval = 0.0f;
  37. bool bval = false;
  38. Separator();
  39. Label("Voice limit (1 - 1024)");
  40. ONSPSettings.Instance.voiceLimit = EditorGUILayout.IntField(" ", ONSPSettings.Instance.voiceLimit);
  41. if (GUI.changed)
  42. {
  43. GUI.changed = false;
  44. EditorUtility.SetDirty(ONSPSettings.Instance);
  45. }
  46. Separator();
  47. Label ("GLOBAL SCALE (0.00001 - 10000.0)");
  48. plugin.GetFloatParameter("GScale", out fval);
  49. plugin.SetFloatParameter("GScale", EditorGUILayout.FloatField(" ", Mathf.Clamp (fval, 0.00001f, 10000.0f)));
  50. Separator();
  51. Label ("REFLECTION ENGINE");
  52. Label("");
  53. // Treat these floats as bools in the inspector
  54. plugin.GetFloatParameter("E.Rflt On", out fval);
  55. bval = (fval == 0.0f) ? false : true;
  56. bval = EditorGUILayout.Toggle("Enable Early Reflections", bval);
  57. plugin.SetFloatParameter("E.Rflt On", (bval == false) ? 0.0f : 1.0f);
  58. plugin.GetFloatParameter("E.Rflt Rev On", out fval);
  59. bval = (fval == 0.0f) ? false : true;
  60. bval = EditorGUILayout.Toggle("Enable Reverberation", bval);
  61. plugin.SetFloatParameter("E.Rflt Rev On", (bval == false) ? 0.0f : 1.0f);
  62. Separator();
  63. Label("ROOM DIMENSIONS (meters)");
  64. Label("");
  65. plugin.GetFloatParameter("Room X", out fval);
  66. plugin.SetFloatParameter("Room X", EditorGUILayout.Slider("Width", fval, 1.0f, 200.0f));
  67. plugin.GetFloatParameter("Room Y", out fval);
  68. plugin.SetFloatParameter("Room Y", EditorGUILayout.Slider("Height", fval, 1.0f, 200.0f));
  69. plugin.GetFloatParameter("Room Z", out fval);
  70. plugin.SetFloatParameter("Room Z", EditorGUILayout.Slider("Length", fval, 1.0f, 200.0f));
  71. Separator();
  72. Label("WALL REFLECTION COEFFICIENTS (0.0 - 0.97)");
  73. Label("");
  74. plugin.GetFloatParameter("Left", out fval);
  75. plugin.SetFloatParameter("Left", EditorGUILayout.Slider("Left", fval, 0.0f, 0.97f));
  76. plugin.GetFloatParameter("Right", out fval);
  77. plugin.SetFloatParameter("Right", EditorGUILayout.Slider("Right", fval, 0.0f, 0.97f));
  78. plugin.GetFloatParameter("Up", out fval);
  79. plugin.SetFloatParameter("Up", EditorGUILayout.Slider("Up", fval, 0.0f, 0.97f));
  80. plugin.GetFloatParameter("Down", out fval);
  81. plugin.SetFloatParameter("Down", EditorGUILayout.Slider("Down", fval, 0.0f, 0.97f));
  82. plugin.GetFloatParameter("Behind", out fval);
  83. plugin.SetFloatParameter("Behind", EditorGUILayout.Slider("Back", fval, 0.0f, 0.97f));
  84. plugin.GetFloatParameter("Front", out fval);
  85. plugin.SetFloatParameter("Front", EditorGUILayout.Slider("Front", fval, 0.0f, 0.97f));
  86. Separator();
  87. Label("SHARED REVERB ATTENUATION RANGE (1.0 - 10000.0 meters)");
  88. Label("");
  89. plugin.GetFloatParameter("Shared Rev Min", out fval);
  90. plugin.SetFloatParameter("Shared Rev Min", EditorGUILayout.Slider("Minimum", fval, 1.0f, 10000.0f));
  91. plugin.GetFloatParameter("Shared Rev Max", out fval);
  92. plugin.SetFloatParameter("Shared Rev Max", EditorGUILayout.Slider("Maximum", fval, 1.0f, 10000.0f));
  93. Separator();
  94. Label("SHARED REVERB WET MIX (-60.0 - 20.0 dB)");
  95. Label("");
  96. plugin.GetFloatParameter("Shared Rev Wet", out fval);
  97. plugin.SetFloatParameter("Shared Rev Wet", EditorGUILayout.Slider(" ", fval, -60.0f, 20.0f));
  98. Separator();
  99. Label("PROPAGATION QUALITY LEVEL (0.0 - 200.0%)");
  100. Label("");
  101. plugin.GetFloatParameter("Prop Quality", out fval);
  102. plugin.SetFloatParameter("Prop Quality", EditorGUILayout.Slider(" ", fval, 0.0f, 200.0f));
  103. Separator();
  104. // We will override the controls with our own, so return false
  105. return false;
  106. }
  107. // Separator
  108. void Separator()
  109. {
  110. GUI.color = new Color(1, 1, 1, 0.25f);
  111. GUILayout.Box("", "HorizontalSlider", GUILayout.Height(16));
  112. GUI.color = Color.white;
  113. }
  114. // Label
  115. void Label(string label)
  116. {
  117. EditorGUILayout.LabelField (label);
  118. }
  119. }