-
-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathVolumeRenderedObjectCustomInspector.cs
More file actions
113 lines (96 loc) · 4.98 KB
/
Copy pathVolumeRenderedObjectCustomInspector.cs
File metadata and controls
113 lines (96 loc) · 4.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using UnityEngine;
using UnityEditor;
namespace UnityVolumeRendering
{
[CustomEditor(typeof(VolumeRenderedObject))]
public class VolumeRenderedObjectCustomInspector : Editor
{
private bool clipSettings = false;
private bool tfSettings = true;
private bool lightSettings = true;
private bool otherSettings = true;
public override void OnInspectorGUI()
{
VolumeRenderedObject volrendObj = (VolumeRenderedObject)target;
// Render mode
RenderMode oldRenderMode = volrendObj.GetRenderMode();
RenderMode newRenderMode = (RenderMode)EditorGUILayout.EnumPopup("Render mode", oldRenderMode);
if (newRenderMode != oldRenderMode)
volrendObj.SetRenderMode(newRenderMode);
#region ClippingData
EditorGUILayout.Space();
clipSettings = EditorGUILayout.Foldout(clipSettings, "Clipping Settings");
if (clipSettings)
{
// Clip dim 1
Vector2 ClipDim1 = volrendObj.GetClipDim1();
EditorGUILayout.MinMaxSlider("Clipping Dimension x", ref ClipDim1.x, ref ClipDim1.y, 0.0f, 1.0f);
// Clip dim 2
Vector2 ClipDim2 = volrendObj.GetClipDim2();
EditorGUILayout.MinMaxSlider("Clipping Dimension y", ref ClipDim2.x, ref ClipDim2.y, 0.0f, 1.0f);
// Clip dim 3
Vector2 ClipDim3 = volrendObj.GetClipDim3();
EditorGUILayout.MinMaxSlider("Clipping Dimension y", ref ClipDim3.x, ref ClipDim3.y, 0.0f, 1.0f);
// setting clip dims
volrendObj.SetClipDims(ClipDim1, ClipDim2, ClipDim3);
}
#endregion EndClippingData
// Visibility window
Vector2 visibilityWindow = volrendObj.GetVisibilityWindow();
EditorGUILayout.MinMaxSlider("Visible value range", ref visibilityWindow.x, ref visibilityWindow.y, 0.0f, 1.0f);
volrendObj.SetVisibilityWindow(visibilityWindow);
// Transfer function settings
EditorGUILayout.Space();
tfSettings = EditorGUILayout.Foldout(tfSettings, "Transfer function");
if (tfSettings)
{
// Transfer function type
TFRenderMode tfMode = (TFRenderMode)EditorGUILayout.EnumPopup("Transfer function type", volrendObj.GetTransferFunctionMode());
if (tfMode != volrendObj.GetTransferFunctionMode())
volrendObj.SetTransferFunctionMode(tfMode);
// Show TF button
if (GUILayout.Button("Edit transfer function"))
{
if (tfMode == TFRenderMode.TF1D)
TransferFunctionEditorWindow.ShowWindow(volrendObj);
else
TransferFunction2DEditorWindow.ShowWindow();
}
}
// Lighting settings
GUILayout.Space(10);
lightSettings = EditorGUILayout.Foldout(lightSettings, "Lighting");
if (lightSettings)
{
if (volrendObj.GetRenderMode() == RenderMode.DirectVolumeRendering)
volrendObj.SetLightingEnabled(GUILayout.Toggle(volrendObj.GetLightingEnabled(), "Enable lighting"));
else
volrendObj.SetLightingEnabled(false);
if (volrendObj.GetLightingEnabled() || volrendObj.GetRenderMode() == RenderMode.IsosurfaceRendering)
{
LightSource oldLightSource = volrendObj.GetLightSource();
LightSource newLightSource = (LightSource)EditorGUILayout.EnumPopup("Light source", oldLightSource);
if (newLightSource != oldLightSource)
volrendObj.SetLightSource(newLightSource);
}
}
// Other settings
GUILayout.Space(10);
otherSettings = EditorGUILayout.Foldout(otherSettings, "Other Settings");
if (otherSettings)
{
if (volrendObj.GetRenderMode() == RenderMode.DirectVolumeRendering)
{
// Back-to-front rendering option
volrendObj.SetDVRBackwardEnabled(GUILayout.Toggle(volrendObj.GetDVRBackwardEnabled(), "Enable Back-to-Front Direct Volume Rendering"));
// Early ray termination for Front-to-back DVR
if (!volrendObj.GetDVRBackwardEnabled())
{
volrendObj.SetRayTerminationEnabled(GUILayout.Toggle(volrendObj.GetRayTerminationEnabled(), "Enable early ray termination"));
}
}
volrendObj.SetCubicInterpolationEnabled(GUILayout.Toggle(volrendObj.GetCubicInterpolationEnabled(), "Enable cubic interpolation (better quality)"));
}
}
}
}