Exemple #1
0
        public override void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            base.OnSceneGUI(sceneView, dragArea);

            // TODO: handle snapping against own points
            // TODO: handle ability to 'commit' last point
            switch (ShapeExtrusionHandle.Do(dragArea, out Curve2D shape, out float height, out ChiselModel modelBeneathCursor, out Matrix4x4 transformation, Axis.Y))
            {
Exemple #2
0
 public override void Reset()
 {
     ShapeExtrusionHandle.Reset();
     extrudedShape = null;
 }
        public void OnSceneGUI(SceneView sceneView, Rect dragArea)
        {
            Curve2D   shape;
            CSGModel  modelBeneathCursor;
            Matrix4x4 transformation;
            float     height;

            // TODO: handle snapping against own points
            // TODO: handle ability to 'commit' last point
            switch (ShapeExtrusionHandle.Do(dragArea, out shape, out height, out modelBeneathCursor, out transformation, Axis.Y))
            {
            case ShapeExtrusionState.Create:
            {
                var center2D = shape.Center;
                var center3D = new Vector3(center2D.x, 0, center2D.y);
                extrudedShape = BrushMeshAssetFactory.Create <CSGExtrudedShape>("Extruded Shape",
                                                                                BrushMeshAssetFactory.GetModelForNode(modelBeneathCursor),
                                                                                transformation * Matrix4x4.TRS(center3D, Quaternion.identity, Vector3.one));
                shape.Center = Vector2.zero;

                extrudedShape.Operation = forceOperation ?? CSGOperationType.Additive;
                extrudedShape.Shape     = new Curve2D(shape);
                extrudedShape.Path      = new Path(new[] {
                        new PathPoint(Vector3.zero),
                        new PathPoint(new Vector3(0, 1, 0))
                    });
                extrudedShape.UpdateGenerator();
                break;
            }

            case ShapeExtrusionState.Modified:
            {
                extrudedShape.Operation = forceOperation ??
                                          ((height < 0 && modelBeneathCursor) ?
                                           CSGOperationType.Subtractive :
                                           CSGOperationType.Additive);
                extrudedShape.Path.segments[1].position = new Vector3(0, height, 0);
                extrudedShape.UpdateGenerator();
                break;
            }

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

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

            case ShapeExtrusionState.ExtrusionMode:
            case ShapeExtrusionState.ShapeMode:             { CSGOutlineRenderer.VisualizationMode = VisualizationMode.SimpleOutline; break; }

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

            HandleRendering.RenderShape(transformation, shape, height);
        }
 void Reset()
 {
     ShapeExtrusionHandle.Reset();
     extrudedShape = null;
 }
Exemple #5
0
 public virtual void     Reset()
 {
     RectangleExtrusionHandle.Reset();
     ShapeExtrusionHandle.Reset();
 }
Exemple #6
0
 public override void Reset()
 {
     ShapeExtrusionHandle.Reset();
 }