public override void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            var flags = (settings.isSymmetrical ? BoxExtrusionFlags.IsSymmetricalXZ : BoxExtrusionFlags.None) |
                        (settings.generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out Bounds bounds, out float height, out ChiselModel modelBeneathCursor, out Matrix4x4 transformation, flags, Axis.Y))
            {
        public override void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            base.OnSceneGUI(sceneView, dragArea);

            var flags = BoxExtrusionFlags.AlwaysFaceUp;

            switch (BoxExtrusionHandle.Do(dragArea, out Bounds bounds, out float height, out ChiselModel modelBeneathCursor, out Matrix4x4 transformation, flags, Axis.Y))
            {
        public override void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            // TODO: add support for XYZ symmetrical mode (symmetric along all 3 axi, except Y is half sized)
            var flags = (settings.isSymmetrical        ? BoxExtrusionFlags.IsSymmetricalXZ      : BoxExtrusionFlags.None) |
                        (settings.generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out Bounds bounds, out float height, out ChiselModel modelBeneathCursor, out Matrix4x4 transformation, flags, Axis.Y))
            {
        public void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            Bounds    bounds;
            CSGModel  modelBeneathCursor;
            Matrix4x4 transformation;
            float     height;

            var flags = BoxExtrusionFlags.AlwaysFaceUp;

            switch (BoxExtrusionHandle.Do(dragArea, out bounds, out height, out modelBeneathCursor, out transformation, flags, Axis.Y))
            {
            case BoxExtrusionState.Create:
            {
                linearStairs = BrushMeshAssetFactory.Create <CSGLinearStairs>("Linear Stairs",
                                                                              BrushMeshAssetFactory.GetModelForNode(modelBeneathCursor),
                                                                              transformation);
                linearStairs.definition.Reset();
                linearStairs.Operation = forceOperation ?? CSGOperationType.Additive;
                linearStairs.Bounds    = bounds;
                linearStairs.UpdateGenerator();
                break;
            }

            case BoxExtrusionState.Modified:
            {
                linearStairs.Operation = forceOperation ??
                                         ((height < 0 && modelBeneathCursor) ?
                                          CSGOperationType.Subtractive :
                                          CSGOperationType.Additive);
                linearStairs.Bounds = bounds;
                break;
            }

            case BoxExtrusionState.Commit:
            {
                UnityEditor.Selection.activeGameObject = linearStairs.gameObject;
                CSGEditModeManager.EditMode            = CSGEditMode.ShapeEdit;
                Reset();
                break;
            }

            case BoxExtrusionState.Cancel:
            {
                Reset();
                Undo.RevertAllInCurrentGroup();
                EditorGUIUtility.ExitGUI();
                break;
            }

            case BoxExtrusionState.BoxMode:
            case BoxExtrusionState.SquareMode:      { CSGOutlineRenderer.VisualizationMode = VisualizationMode.SimpleOutline; break; }

            case BoxExtrusionState.HoverMode:       { CSGOutlineRenderer.VisualizationMode = VisualizationMode.Outline; break; }
            }

            HandleRendering.RenderBox(transformation, bounds);
        }
Ejemplo n.º 5
0
        public override void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            base.OnSceneGUI(sceneView, dragArea);

            var flags = BoxExtrusionFlags.AlwaysFaceUp |
                        BoxExtrusionFlags.IsSymmetricalXZ |
                        (generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out Bounds bounds, out float height, out ChiselModel modelBeneathCursor, out Matrix4x4 transformation, flags, Axis.Y, snappingSteps: stepHeight))
            {
 void Reset()
 {
     BoxExtrusionHandle.Reset();
     linearStairs = null;
 }
 public override void Reset()
 {
     BoxExtrusionHandle.Reset();
     linearStairs = null;
 }
 void Reset()
 {
     BoxExtrusionHandle.Reset();
     box = null;
 }
 public override void Reset()
 {
     BoxExtrusionHandle.Reset();
 }
Ejemplo n.º 10
0
 void Reset()
 {
     BoxExtrusionHandle.Reset();
     spiralStairs = null;
 }
 void Reset()
 {
     BoxExtrusionHandle.Reset();
     sphere = null;
 }
Ejemplo n.º 12
0
 public override void Reset()
 {
     BoxExtrusionHandle.Reset();
     sphere = null;
 }
        public void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            Bounds    bounds;
            CSGModel  modelBeneathCursor;
            Matrix4x4 transformation;
            float     height;

            var flags = (isSymmetrical ? BoxExtrusionFlags.IsSymmetricalXZ : BoxExtrusionFlags.None) |
                        (generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out bounds, out height, out modelBeneathCursor, out transformation, flags, Axis.Y))
            {
            case BoxExtrusionState.Create:
            {
                capsule = BrushMeshAssetFactory.Create <CSGCapsule>("Capsule",
                                                                    BrushMeshAssetFactory.GetModelForNode(modelBeneathCursor),
                                                                    transformation);
                capsule.definition.Reset();
                capsule.Operation      = forceOperation ?? CSGOperationType.Additive;
                capsule.Sides          = sides;
                capsule.TopSegments    = topSegments;
                capsule.BottomSegments = bottomSegments;
                capsule.TopHeight      = topHeight;
                capsule.BottomHeight   = bottomHeight;
                capsule.DiameterX      = bounds.size[(int)Axis.X];
                capsule.Height         = height;
                capsule.DiameterZ      = bounds.size[(int)Axis.Z];
                capsule.UpdateGenerator();
                break;
            }

            case BoxExtrusionState.Modified:
            {
                capsule.Operation = forceOperation ??
                                    ((height < 0 && modelBeneathCursor) ?
                                     CSGOperationType.Subtractive :
                                     CSGOperationType.Additive);
                capsule.TopHeight    = topHeight;
                capsule.BottomHeight = bottomHeight;
                capsule.DiameterX    = bounds.size[(int)Axis.X];
                capsule.Height       = height;
                capsule.DiameterZ    = bounds.size[(int)Axis.Z];
                break;
            }

            case BoxExtrusionState.Commit:
            {
                UnityEditor.Selection.activeGameObject = capsule.gameObject;
                CSGEditModeManager.EditMode            = CSGEditMode.ShapeEdit;
                Reset();
                break;
            }

            case BoxExtrusionState.Cancel:
            {
                Reset();
                Undo.RevertAllInCurrentGroup();
                EditorGUIUtility.ExitGUI();
                break;
            }

            case BoxExtrusionState.BoxMode:
            case BoxExtrusionState.SquareMode: { CSGOutlineRenderer.VisualizationMode = VisualizationMode.SimpleOutline; break; }

            case BoxExtrusionState.HoverMode: { CSGOutlineRenderer.VisualizationMode = VisualizationMode.Outline; break; }
            }

            // TODO: render capsule here
            HandleRendering.RenderCylinder(transformation, bounds, (capsule) ? capsule.Sides : sides);
        }
 void Reset()
 {
     BoxExtrusionHandle.Reset();
     capsule = null;
 }
Ejemplo n.º 15
0
        public void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            Bounds    bounds;
            CSGModel  modelBeneathCursor;
            Matrix4x4 transformation;
            float     height;

            var flags = BoxExtrusionFlags.AlwaysFaceUp |
                        BoxExtrusionFlags.IsSymmetricalXZ |
                        (generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out bounds, out height, out modelBeneathCursor, out transformation, flags, Axis.Y, snappingSteps: stepHeight))
            {
            case BoxExtrusionState.Create:
            {
                spiralStairs = BrushMeshAssetFactory.Create <CSGSpiralStairs>("Spiral Stairs",
                                                                              BrushMeshAssetFactory.GetModelForNode(modelBeneathCursor),
                                                                              transformation);
                spiralStairs.definition.Reset();
                spiralStairs.Operation     = forceOperation ?? CSGOperationType.Additive;
                spiralStairs.StepHeight    = stepHeight;
                spiralStairs.Height        = height;
                spiralStairs.OuterDiameter = bounds.size[(int)Axis.X];
                spiralStairs.OuterSegments = outerSegments;
                spiralStairs.UpdateGenerator();
                break;
            }

            case BoxExtrusionState.Modified:
            {
                spiralStairs.Operation = forceOperation ??
                                         ((height < 0 && modelBeneathCursor) ?
                                          CSGOperationType.Subtractive :
                                          CSGOperationType.Additive);
                spiralStairs.Height        = bounds.size.y;
                spiralStairs.OuterDiameter = bounds.size[(int)Axis.X];
                break;
            }

            case BoxExtrusionState.Commit:
            {
                UnityEditor.Selection.activeGameObject = spiralStairs.gameObject;
                CSGEditModeManager.EditMode            = CSGEditMode.ShapeEdit;
                Reset();
                break;
            }

            case BoxExtrusionState.Cancel:
            {
                Reset();
                Undo.RevertAllInCurrentGroup();
                EditorGUIUtility.ExitGUI();
                break;
            }

            case BoxExtrusionState.BoxMode:
            case BoxExtrusionState.SquareMode:      { CSGOutlineRenderer.VisualizationMode = VisualizationMode.SimpleOutline; break; }

            case BoxExtrusionState.HoverMode:       { CSGOutlineRenderer.VisualizationMode = VisualizationMode.Outline; break; }
            }

            HandleRendering.RenderCylinder(transformation, bounds, (spiralStairs) ? spiralStairs.OuterSegments : outerSegments);
        }
        public void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            Bounds    bounds;
            CSGModel  modelBeneathCursor;
            Matrix4x4 transformation;
            float     height;

            var flags = (generateFromCenterY  ? BoxExtrusionFlags.GenerateFromCenterY  : BoxExtrusionFlags.None) |
                        (isSymmetrical        ? BoxExtrusionFlags.IsSymmetricalXZ      : BoxExtrusionFlags.None) |
                        (generateFromCenterXZ ? BoxExtrusionFlags.GenerateFromCenterXZ : BoxExtrusionFlags.None);

            switch (BoxExtrusionHandle.Do(dragArea, out bounds, out height, out modelBeneathCursor, out transformation, flags, Axis.Y))
            {
            case BoxExtrusionState.Create:
            {
                sphere = BrushMeshAssetFactory.Create <CSGSphere>("Sphere",
                                                                  BrushMeshAssetFactory.GetModelForNode(modelBeneathCursor),
                                                                  transformation);

                sphere.definition.Reset();
                sphere.Operation          = forceOperation ?? CSGOperationType.Additive;
                sphere.VerticalSegments   = verticalSegments;
                sphere.HorizontalSegments = horizontalSegments;
                sphere.GenerateFromCenter = generateFromCenterY;
                sphere.DiameterXYZ        = bounds.size;
                sphere.UpdateGenerator();
                break;
            }

            case BoxExtrusionState.Modified:
            {
                sphere.Operation = forceOperation ??
                                   ((height < 0 && modelBeneathCursor) ?
                                    CSGOperationType.Subtractive :
                                    CSGOperationType.Additive);
                sphere.DiameterXYZ = bounds.size;
                break;
            }

            case BoxExtrusionState.Commit:
            {
                UnityEditor.Selection.activeGameObject = sphere.gameObject;
                CSGEditModeManager.EditMode            = CSGEditMode.ShapeEdit;
                Reset();
                break;
            }

            case BoxExtrusionState.Cancel:
            {
                Reset();
                Undo.RevertAllInCurrentGroup();
                EditorGUIUtility.ExitGUI();
                break;
            }

            case BoxExtrusionState.BoxMode:
            case BoxExtrusionState.SquareMode: { CSGOutlineRenderer.VisualizationMode = VisualizationMode.SimpleOutline; break; }

            case BoxExtrusionState.HoverMode: { CSGOutlineRenderer.VisualizationMode = VisualizationMode.Outline; break; }
            }

            // TODO: Make a RenderSphere method
            HandleRendering.RenderCylinder(transformation, bounds, horizontalSegments);
        }
Ejemplo n.º 17
0
 public override void Reset()
 {
     BoxExtrusionHandle.Reset();
     capsule = null;
 }
 void Reset()
 {
     BoxExtrusionHandle.Reset();
 }