Example #1
0
        private void apply_Click(object sender, EventArgs e)
        {
            CellSizeMode cellSizeMode = CellSizeMode.EqualToMaxNode;
            // get all parameters
            int         nMaxColumnCount = int.Parse(txtMaxColumnCount.Text);
            int         nMaxRowsCount   = int.Parse(txtMaxRowsCount.Text);
            Orientation orientation     = (comboExpandMode.SelectedIndex == 0) ? Orientation.Horizontal : Orientation.Vertical;

            if (comboCellSize.SelectedIndex == 0)
            {
                cellSizeMode = CellSizeMode.EqualToMaxNode;
            }
            else if (comboCellSize.SelectedIndex == 1)
            {
                cellSizeMode = CellSizeMode.Minimal;
            }
            else if (comboCellSize.SelectedIndex == 2)
            {
                cellSizeMode = CellSizeMode.MinimalTable;
            }

            TableLayoutManager m_layoutManager = diagram1.LayoutManager as TableLayoutManager;

            m_layoutManager.MaxColummnCount   = nMaxColumnCount;
            m_layoutManager.MaxRowsCount      = nMaxRowsCount;
            m_layoutManager.CellSizeMode      = cellSizeMode;
            m_layoutManager.HorizontalSpacing = float.Parse(txtHSpacing.Text);
            m_layoutManager.VerticalSpacing   = float.Parse(txtVSpacing.Text);
            m_layoutManager.LeftMargin        = float.Parse(txtLMarigin.Text);
            m_layoutManager.TopMargin         = float.Parse(txtTMarigin.Text);
            m_layoutManager.MaxSize           = new SizeF(float.Parse(txtMaxWidth.Text), float.Parse(txtMaxHeight.Text));
            m_layoutManager.Orientation       = orientation;
            m_layoutManager.AutoLayout        = chkAutoLayout.Checked;
            Layouting();
        }
Example #2
0
 public void CopySettings(VoxelSettings source)
 {
     m_cellSizeMode = source.m_cellSizeMode;
     m_cellSize     = source.m_cellSize;
     m_cellCount    = source.m_cellCount;
     m_volumeSize   = source.m_volumeSize;
     m_cellDensity  = source.m_cellDensity;
 }
Example #3
0
        public void LoadSetting(GridVirtual p_Grid, int p_Col, int p_Row, CellSizeMode p_Mode)
        {
            m_Grid = p_Grid;
            m_Col  = p_Col;
            m_Mode = p_Mode;
            m_Row  = p_Row;

            RefreshSetting();
        }
Example #4
0
        /// <summary>
        /// Loads the setting.
        /// </summary>
        /// <param name="grid">The parent grid.</param>
        /// <param name="column">The column.</param>
        /// <param name="row">The row.</param>
        /// <param name="mode">The cell size mode.</param>
        public void LoadSetting(GridVirtual grid, int column, int row, CellSizeMode mode)
        {
            this.ownerGrid    = grid;
            this.columnId     = column;
            this.rowId        = row;
            this.cellSizeMode = mode;

            RefreshSetting();
        }
        public override void OnInspectorGUI()
        {
            m_setter.Clear();

            serializedObject.DrawScript();

            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_serializedProperties.ComputeShader, Labels.ComputeShader);
            GUI.enabled = true;

            GUI.enabled = false;
            EditorGUILayout.PropertyField(m_serializedProperties.SDFGroup, Labels.SDFGroup);
            GUI.enabled = true;

            bool isControlledExternally = m_serializedProperties.SettingsControlledByGrid.boolValue;

            if (isControlledExternally)
            {
                EditorGUILayout.HelpBox(Labels.SettingsControlledByGridWarning, MessageType.Info);
                return;
            }

            GUI.enabled = !isControlledExternally;

            m_setter.DrawProperty(Labels.AutoUpdate, m_serializedProperties.AutoUpdate);

            m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_sdfGroupMeshGen.OnOutputModeChanged);

            OutputMode outputMode = (OutputMode)m_serializedProperties.OutputMode.enumValueIndex;

            if (outputMode == OutputMode.Procedural)
            {
                m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial);
            }
            else if (outputMode == OutputMode.MeshFilter)
            {
                m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous);
            }

            if (m_isVoxelSettingsOpen = EditorGUILayout.Foldout(m_isVoxelSettingsOpen, Labels.VoxelSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.CellSizeMode, m_serializedProperties.CellSizeMode);

                        CellSizeMode cellSizeMode = (CellSizeMode)m_serializedProperties.CellSizeMode.enumValueIndex;

                        if (cellSizeMode == CellSizeMode.Fixed)
                        {
                            m_setter.DrawFloatSetting(Labels.CellSize, m_serializedProperties.CellSize, min: 0.005f, onValueChangedCallback: m_sdfGroupMeshGen.OnCellSizeChanged);
                            m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_sdfGroupMeshGen.OnCellCountChanged);
                        }
                        else if (cellSizeMode == CellSizeMode.Density)
                        {
                            m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged);
                            m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_sdfGroupMeshGen.OnDensitySettingChanged);
                        }
                    }
                }
            }

            if (m_isAlgorithmSettingsOpen = EditorGUILayout.Foldout(m_isAlgorithmSettingsOpen, Labels.AlgorithmSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawEnumSetting <IsosurfaceExtractionType>(Labels.IsosurfaceExtractionType, m_serializedProperties.IsosurfaceExtractionType, onValueChangedCallback: m_sdfGroupMeshGen.OnIsosurfaceExtractionTypeChanged);

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel);

                        m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_sdfGroupMeshGen.OnMaxAngleToleranceChanged);
                        m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_sdfGroupMeshGen.OnVisualNormalSmoothingChanged);

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel);

                        m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged);

                        if ((EdgeIntersectionType)m_serializedProperties.EdgeIntersectionType.enumValueIndex == EdgeIntersectionType.BinarySearch)
                        {
                            m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnBinarySearchIterationsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel);

                        m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged);

                        if (m_serializedProperties.ApplyGradientDescent.boolValue)
                        {
                            m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_sdfGroupMeshGen.OnGradientDescentIterationsChanged);
                        }
                    }
                }
            }

            if (m_isDebugSettingsOpen = EditorGUILayout.Foldout(m_isDebugSettingsOpen, Labels.DebugSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.ShowGrid, m_serializedProperties.ShowGrid);
                    }
                }
            }

            m_setter.Update();

            GUI.enabled = true;
        }
Example #6
0
        public override void OnInspectorGUI()
        {
            m_setter.Clear();

            //Debug.Log(m_grid.VoxelSettings.Extents);
            //Debug.Log(m_grid.VoxelSettings.Radius);


            serializedObject.DrawScript();

            m_setter.DrawProperty(Labels.SDFGroup, m_serializedProperties.SDFGroup);

            bool hasGroup = m_serializedProperties.SDFGroup.objectReferenceValue;

            if (!hasGroup)
            {
                EditorGUILayout.HelpBox(Labels.GroupRequiredError, MessageType.Error);
            }

            GUI.enabled = hasGroup;

            m_setter.DrawEnumSetting <OutputMode>(Labels.OutputMode, m_serializedProperties.OutputMode, onValueChangedCallback: m_grid.OnMainSettingsChanged);

            OutputMode outputMode = (OutputMode)m_serializedProperties.OutputMode.enumValueIndex;

            if (outputMode == OutputMode.Procedural)
            {
                m_setter.DrawProperty(Labels.ProceduralMaterial, m_serializedProperties.ProceduralMaterial, onValueChangedCallback: m_grid.OnMainSettingsChanged);
            }
            else if (outputMode == OutputMode.MeshFilter)
            {
                m_setter.DrawProperty(Labels.AddMeshRenderers, m_serializedProperties.AddMeshRenderers);

                if (m_serializedProperties.AddMeshRenderers.boolValue)
                {
                    m_setter.DrawProperty(Labels.MeshRendererMaterial, m_serializedProperties.MeshRendererMaterial);
                }

                m_setter.DrawProperty(Labels.AddMeshColliders, m_serializedProperties.AddMeshColliders);

                m_setter.DrawProperty(Labels.IsAsynchronous, m_serializedProperties.IsAsynchronous, onValueChangedCallback: m_grid.OnMainSettingsChanged);
            }

            if (m_isVoxelSettingsOpen = EditorGUILayout.Foldout(m_isVoxelSettingsOpen, Labels.VoxelSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawProperty(Labels.CellSizeMode, m_serializedProperties.CellSizeMode);

                        CellSizeMode cellSizeMode = (CellSizeMode)m_serializedProperties.CellSizeMode.enumValueIndex;

                        if (cellSizeMode == CellSizeMode.Fixed)
                        {
                            m_setter.DrawFloatSetting(Labels.CellSize, m_serializedProperties.CellSize, min: 0.005f, onValueChangedCallback: m_grid.OnVoxelSettingChanged);
                            m_setter.DrawIntSetting(Labels.CellCount, m_serializedProperties.CellCount, min: 2, max: 200, onValueChangedCallback: m_grid.OnVoxelSettingChanged);
                        }
                        else if (cellSizeMode == CellSizeMode.Density)
                        {
                            m_setter.DrawFloatSetting(Labels.VolumeSize, m_serializedProperties.VolumeSize, min: 0.05f, onValueChangedCallback: m_grid.OnVoxelSettingChanged);
                            m_setter.DrawFloatSetting(Labels.CellDensity, m_serializedProperties.CellDensity, min: 0.05f, onValueChangedCallback: m_grid.OnVoxelSettingChanged);
                        }
                    }
                }
            }

            if (m_isAlgorithmSettingsOpen = EditorGUILayout.Foldout(m_isAlgorithmSettingsOpen, Labels.AlgorithmSettings, true))
            {
                using (EditorGUILayout.VerticalScope box = new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
                {
                    using (EditorGUI.IndentLevelScope indent = new EditorGUI.IndentLevelScope())
                    {
                        m_setter.DrawEnumSetting <IsosurfaceExtractionType>(Labels.IsosurfaceExtractionType, m_serializedProperties.IsosurfaceExtractionType, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);

                        if ((IsosurfaceExtractionType)m_serializedProperties.IsosurfaceExtractionType.enumValueIndex == IsosurfaceExtractionType.DualContouring)
                        {
                            m_setter.DrawFloatSetting(Labels.ConstrainToCellUnits, m_serializedProperties.ConstrainToCellUnits, min: 0f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Normal Settings", EditorStyles.boldLabel);

                        m_setter.DrawFloatSetting(Labels.MaxAngleTolerance, m_serializedProperties.MaxAngleTolerance, min: 0f, max: 180f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                        m_setter.DrawFloatSetting(Labels.VisualNormalSmoothing, m_serializedProperties.VisualNormalSmoothing, min: 1e-5f, max: 10f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);

                        if ((IsosurfaceExtractionType)m_serializedProperties.IsosurfaceExtractionType.enumValueIndex == IsosurfaceExtractionType.DualContouring)
                        {
                            EditorGUILayout.Space();
                            EditorGUILayout.LabelField("QEF Settings", EditorStyles.boldLabel);

                            m_setter.DrawBoolSetting(Labels.OverrideQEFSettings, m_serializedProperties.OverrideQEFSettings, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);

                            if (m_serializedProperties.OverrideQEFSettings.boolValue)
                            {
                                m_setter.DrawIntSetting(Labels.QEFSweeps, m_serializedProperties.QEFSweeps, min: 1, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                                m_setter.DrawFloatSetting(Labels.QEFPseudoInverseThreshold, m_serializedProperties.QEFPseudoInverseThreshold, min: 1e-7f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                            }

                            EditorGUILayout.Space();
                            EditorGUILayout.LabelField("Nudge Settings", EditorStyles.boldLabel);

                            m_setter.DrawFloatSetting(Labels.NudgeVerticesToAverageNormalScalar, m_serializedProperties.NudgeVerticesToAverageNormalScalar, min: 0f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                            m_setter.DrawFloatSetting(Labels.NudgeMaxMagnitude, m_serializedProperties.NudgeMaxMagnitude, min: 0f, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Edge Intersection Settings", EditorStyles.boldLabel);

                        m_setter.DrawEnumSetting <EdgeIntersectionType>(Labels.EdgeIntersectionType, m_serializedProperties.EdgeIntersectionType, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);

                        if ((EdgeIntersectionType)m_serializedProperties.EdgeIntersectionType.enumValueIndex == EdgeIntersectionType.BinarySearch)
                        {
                            m_setter.DrawIntSetting(Labels.BinarySearchIterations, m_serializedProperties.BinarySearchIterations, min: 1, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                        }

                        EditorGUILayout.Space();
                        EditorGUILayout.LabelField("Gradient Descent Settings", EditorStyles.boldLabel);

                        m_setter.DrawBoolSetting(Labels.ApplyGradientDescent, m_serializedProperties.ApplyGradientDescent, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);

                        if (m_serializedProperties.ApplyGradientDescent.boolValue)
                        {
                            m_setter.DrawIntSetting(Labels.GradientDescentIterations, m_serializedProperties.GradientDescentIterations, min: 1, onValueChangedCallback: m_grid.OnAlgorithmSettingsChanged);
                        }
                    }
                }
            }

            GUI.enabled = true;

            m_setter.Update();
        }
        /// <summary>
        /// Loads the setting.
        /// </summary>
        /// <param name="grid">The parent grid.</param>
        /// <param name="column">The column.</param>
        /// <param name="row">The row.</param>
        /// <param name="mode">The cell size mode.</param>
        public void LoadSetting(GridVirtual grid, int column, int row, CellSizeMode mode)
        {
            this.ownerGrid = grid;
              this.columnId = column;
              this.rowId = row;
              this.cellSizeMode = mode;

              RefreshSetting();
        }