private void OnGUI()
        {
            // Update selected object
            VolumeRenderedObject volRendObject = SelectionHelper.GetSelectedVolumeObject();

            if (volRendObject == null)
            {
                volRendObject = GameObject.FindObjectOfType <VolumeRenderedObject>();
            }
            if (volRendObject == null)
            {
                return;
            }

            EditorGUILayout.LabelField("Edit the visible value range (min/max value) with the slider.");

            Vector2 visibilityWindow = volRendObject.GetVisibilityWindow();

            EditorGUILayout.BeginHorizontal();
            EditorGUILayout.MinMaxSlider("Visible value range", ref visibilityWindow.x, ref visibilityWindow.y, 0.0f, 1.0f);
            EditorGUILayout.Space();
            EditorGUILayout.Space();
            EditorGUILayout.EndHorizontal();

            volRendObject.SetVisibilityWindow(visibilityWindow);
        }
Exemple #2
0
        private void UpdateWindow(int windowID)
        {
            GUI.DragWindow(new Rect(0, 0, 10000, 20));

            GUILayout.BeginVertical();

            if (targetObject != null)
            {
                // Render mode
                GUILayout.Label("Render mode");
                selectedRenderModeIndex = GUILayout.SelectionGrid(selectedRenderModeIndex, new string[] { "Direct volume rendering", "Maximum intensity projection", "Isosurface rendering" }, 2);
                targetObject.SetRenderMode((RenderMode)selectedRenderModeIndex);

                // Visibility window
                GUILayout.Label("Visibility window (min - max visible values)");
                GUILayout.BeginHorizontal();
                Vector2 visibilityWindow = targetObject.GetVisibilityWindow();
                GUILayout.Label("min:");
                visibilityWindow.x = GUILayout.HorizontalSlider(visibilityWindow.x, 0.0f, visibilityWindow.y, GUILayout.Width(150.0f));
                GUILayout.Label("max:");
                visibilityWindow.y = GUILayout.HorizontalSlider(visibilityWindow.y, visibilityWindow.x, 1.0f, GUILayout.Width(150.0f));
                targetObject.SetVisibilityWindow(visibilityWindow);
                GUILayout.EndHorizontal();

                // Rotation
                GUILayout.Label("Rotation");
                rotation.x = GUILayout.HorizontalSlider(rotation.x, 0.0f, 360.0f);
                rotation.y = GUILayout.HorizontalSlider(rotation.y, 0.0f, 360.0f);
                rotation.z = GUILayout.HorizontalSlider(rotation.z, 0.0f, 360.0f);
                targetObject.transform.rotation = Quaternion.Euler(rotation);

                // Load transfer function
                if (GUILayout.Button("Load transfer function", GUILayout.Width(150.0f)))
                {
                    RuntimeFileBrowser.ShowOpenFileDialog(OnLoadTransferFunction);
                }
            }

            GUILayout.FlexibleSpace();

            GUILayout.BeginHorizontal();
            GUILayout.FlexibleSpace();
            // Show close button
            if (GUILayout.Button("Close"))
            {
                GameObject.Destroy(this.gameObject);
            }
            GUILayout.EndHorizontal();

            GUILayout.EndVertical();
        }
        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);
            }

            // Lighting settings
            if (volrendObj.GetRenderMode() == RenderMode.DirectVolumeRendering)
            {
                volrendObj.SetLightingEnabled(GUILayout.Toggle(volrendObj.GetLightingEnabled(), "Enable lighting"));
            }
            else
            {
                volrendObj.SetLightingEnabled(false);
            }

            // Visibility window
            Vector2 visibilityWindow = volrendObj.GetVisibilityWindow();

            EditorGUILayout.MinMaxSlider("Visible value range", ref visibilityWindow.x, ref visibilityWindow.y, 0.0f, 1.0f);
            EditorGUILayout.Space();
            volrendObj.SetVisibilityWindow(visibilityWindow);

            // 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();
                }
                else
                {
                    TransferFunction2DEditorWindow.ShowWindow();
                }
            }
        }