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); }
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); }
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); }