Ejemplo n.º 1
0
        public HUDRadialMenu GenerateDefaultRadialMenu(float fDiameter, AnyRayHit rayHit)
        {
            HUDRadialMenu popup = new HUDRadialMenu();

            popup.Radius    = fDiameter * 0.5f;
            popup.TextScale = fDiameter * TextScale;

            popup.SubItemRadialWidth   = popup.Radius * 0.75f;
            popup.SubItemRadialPadding = popup.Radius * 0.05f;
            popup.SubItemTextScale     = popup.TextScale * 0.75f;

            float Pullback = 2.0f;

            HUDRadialMenu.MenuItem teleport = popup.AppendMenuItem("Teleport", (s, o) => {
                Teleporter.TeleportTowards(cockpit.ActiveCamera, cockpit.Scene, rayHit.hitPos, Pullback);
            });
            popup.AppendSubMenuItem(teleport, "Teleport\nLevel", (s, o) => {
                Teleporter.TeleportTowards_Level(cockpit.ActiveCamera, cockpit.Scene, rayHit.hitPos, Pullback);
            });
            popup.AppendSubMenuItem(teleport, "Teleport\nNormal", (s, o) => {
                Teleporter.Teleport_Normal_Auto(cockpit.ActiveCamera, cockpit.Scene, rayHit.hitPos, rayHit.hitNormal, Pullback);
            });
            popup.AppendMenuItem("Center", (s, o) => {
                cockpit.ActiveCamera.Animator().AnimatePanFocus(rayHit.hitPos, CoordSpace.WorldCoords, 0.3f);
            });

            return(popup);
        }
Ejemplo n.º 2
0
        public void BeginDraw_Ray(AnyRayHit rayHit)
        {
            CreateNewCurve();

            planarF        = UnityUtil.GetGameObjectFrame(scene.ActiveCamera.GameObject(), CoordSpace.WorldCoords);
            planarF.Origin = rayHit.hitPos;

            float fScale = scene.GetSceneScale();

            smooth_append(preview,
                          scene.SceneFrame.ToFrameP(rayHit.hitPos) / fScale, dist_thresh(Width, fScale));
        }
Ejemplo n.º 3
0
        public void BeginDraw_Ray(Ray3f ray, AnyRayHit rayHit, int nStep)
        {
            CreateNewPrimitive();

            Vector3f hitPos = rayHit.hitPos;

            // try snap points
            SnapResult snap = Snaps.FindHitSnapPoint(ray);

            if (snap != null)
            {
                Frame3f snapF = scene.ToWorldFrame(snap.FrameS);
                hitPos = snapF.Origin;
            }

            Frame3f sceneW = scene.SceneFrame;

            if (rayHit.hitSO == null)
            {
                primStartW        = sceneW;
                primStartW.Origin = hitPos;
            }
            else
            {
                if (scene.Context.TransformManager.ActiveFrameType == FrameType.WorldFrame)
                {
                    primStartW        = sceneW;
                    primStartW.Origin = hitPos;
                }
                else if (rayHit.hitSO is PivotSO)
                {
                    primStartW        = (rayHit.hitSO as PivotSO).GetLocalFrame(CoordSpace.WorldCoords);
                    primStartW.Origin = hitPos;
                }
                else if (rayHit.hitSO is PrimitiveSO)
                {
                    // align with object frame as much as possible, given that we still want
                    //  to use hit normal...
                    Frame3f objFrame  = (rayHit.hitSO as PrimitiveSO).GetLocalFrame(CoordSpace.WorldCoords);
                    int     nBestAxis = MathUtil.MostParallelAxis(objFrame, rayHit.hitNormal);
                    int     nPerp     = (nBestAxis + 1) % 3;
                    primStartW = new Frame3f(hitPos, rayHit.hitNormal, 1);
                    primStartW.ConstrainedAlignAxis(0, objFrame.GetAxis(nPerp), primStartW.Y);
                }
                else
                {
                    primStartW = new Frame3f(hitPos, rayHit.hitNormal, 1);
                    primStartW.ConstrainedAlignAxis(1, sceneW.Y, primStartW.Y);
                }
            }
            primitive.Frame = primStartW;
            primStartS      = scene.ToSceneFrame(primStartW);
        }
        public bool HandleShortcuts()
        {
            bool bShiftDown = Input.GetKey(KeyCode.LeftShift);
            bool bCtrlDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

            // ESCAPE CLEARS ACTIVE TOOL OR SELECTION
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                if (context.ToolManager.HasActiveTool(0) || context.ToolManager.HasActiveTool(1))
                {
                    context.ToolManager.DeactivateTool(0);
                    context.ToolManager.DeactivateTool(1);
                }
                else if (context.Scene.Selected.Count > 0)
                {
                    context.Scene.ClearSelection();
                }
                return(true);


                // CENTER TARGET (??)
            }
            else if (Input.GetKeyUp(KeyCode.C))
            {
                Ray3f     cursorRay = context.MouseController.CurrentCursorWorldRay();
                AnyRayHit hit       = null;
                if (context.Scene.FindSceneRayIntersection(cursorRay, out hit))
                {
                    context.ActiveCamera.Animator().AnimatePanFocus(hit.hitPos, CoordSpace.WorldCoords, 0.3f);
                }
                return(true);

                // TOGGLE FRAME TYPE
            }
            else if (Input.GetKeyUp(KeyCode.F))
            {
                FrameType eCur = context.TransformManager.ActiveFrameType;
                context.TransformManager.ActiveFrameType = (eCur == FrameType.WorldFrame)
                    ? FrameType.LocalFrame : FrameType.WorldFrame;
                return(true);

                // DROP A COPY
            }
            else if (Input.GetKeyUp(KeyCode.D))
            {
                foreach (SceneObject so in context.Scene.Selected)
                {
                    SceneObject copy = so.Duplicate();
                    if (copy != null)
                    {
                        // [TODO] could have a lighter record here because we can just re-run Duplicate() ?
                        context.Scene.History.PushChange(
                            new AddSOChange()
                        {
                            scene = context.Scene, so = copy
                        });
                        context.Scene.History.PushInteractionCheckpoint();
                    }
                }
                return(true);

                // VISIBILITY  (V HIDES, SHIFT+V SHOWS)
            }
            else if (Input.GetKeyUp(KeyCode.V))
            {
                // show/hide (should be abstracted somehow?? instead of directly accessing GOs?)
                if (bShiftDown)
                {
                    foreach (SceneObject so in context.Scene.SceneObjects)
                    {
                        so.RootGameObject.Show();
                    }
                }
                else
                {
                    foreach (SceneObject so in context.Scene.Selected)
                    {
                        so.RootGameObject.Hide();
                    }
                    context.Scene.ClearSelection();
                }
                return(true);

                // UNDO
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Z))
            {
                context.Scene.History.InteractiveStepBack();
                return(true);

                // REDO
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Y))
            {
                context.Scene.History.InteractiveStepForward();
                return(true);



                // APPLY CURRENT TOOL IF POSSIBLE
            }
            else if (Input.GetKeyUp(KeyCode.Return))
            {
                if (((context.ActiveInputDevice & InputDevice.Mouse) != 0) &&
                    context.ToolManager.HasActiveTool(ToolSide.Right) &&
                    context.ToolManager.ActiveRightTool.CanApply)
                {
                    context.ToolManager.ActiveRightTool.Apply();
                }
                return(true);
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.M))
            {
                List <SceneObject> selected = new List <SceneObject>(context.Scene.Selected);

                // combine two selected SOs into a GroupSO
                if (selected.Count == 2)
                {
                    SceneUtil.CreateGroupSO(selected[0], selected[1]);
                }

                // [RMS] alternative, does deep-copy of internal GOs. This works OK except
                //   that the frame of the combined object ends up at the origin...
                //if (selected.Count == 2)
                //    SceneUtil.CombineAnySOs(selected[0], selected[1]);
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.M))
            {
                // combine two DMeshSOs into a Dnew MeshSO
                List <SceneObject> selected = new List <SceneObject>(context.Scene.Selected);
                if (selected.Count == 2 && selected[0] is DMeshSO && selected[1] is DMeshSO)
                {
                    SceneUtil.AppendMeshSO(selected[0] as DMeshSO, selected[1] as DMeshSO);
                }
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 5
0
        public bool HandleShortcuts()
        {
            bool bShiftDown = Input.GetKey(KeyCode.LeftShift);
            bool bCtrlDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

            // ESCAPE CLEARS ACTIVE TOOL OR SELECTION
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                if (context.ToolManager.HasActiveTool(0) || context.ToolManager.HasActiveTool(1))
                {
                    OGActions.CancelCurrentTool();
                }
                else if (context.Scene.Selected.Count > 0)
                {
                    context.Scene.ClearSelection();
                }
                return(true);


                // ENTER AND LETTER A APPLY CURRENT TOOL IF POSSIBLE
            }
            else if (Input.GetKeyUp(KeyCode.Return) || Input.GetKeyUp(KeyCode.A))
            {
                if (OGActions.CanAcceptCurrentTool())
                {
                    OGActions.AcceptCurrentTool();
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Delete))
            {
                if (context.Scene.Selected.Count == 1)
                {
                    DeleteSOChange change = new DeleteSOChange()
                    {
                        scene = context.Scene, so = context.Scene.Selected[0]
                    };
                    context.Scene.History.PushChange(change, false);
                }
                return(true);


                // CENTER TARGET (??)
            }
            else if (Input.GetKeyUp(KeyCode.C))
            {
                Ray3f     cursorRay = context.MouseController.CurrentCursorWorldRay();
                AnyRayHit hit       = null;
                if (context.Scene.FindSceneRayIntersection(cursorRay, out hit))
                {
                    context.ActiveCamera.Manipulator().ScenePanFocus(context.Scene, context.ActiveCamera, hit.hitPos, true);
                }
                return(true);

                // TOGGLE FRAME TYPE
            }
            else if (Input.GetKeyUp(KeyCode.F))
            {
                FrameType eCur = context.TransformManager.ActiveFrameType;
                context.TransformManager.ActiveFrameType = (eCur == FrameType.WorldFrame)
                    ? FrameType.LocalFrame : FrameType.WorldFrame;
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.D))
            {
                return(true);

                // VISIBILITY  (V HIDES, SHIFT+V SHOWS)
            }
            else if (Input.GetKeyUp(KeyCode.V))
            {
                // show/hide (should be abstracted somehow?? instead of directly accessing GOs?)
                if (bShiftDown)
                {
                    foreach (SceneObject so in context.Scene.SceneObjects)
                    {
                        so.RootGameObject.Show();
                    }
                }
                else
                {
                    foreach (SceneObject so in context.Scene.Selected)
                    {
                        so.RootGameObject.Hide();
                    }
                    context.Scene.ClearSelection();
                }
                return(true);

                // UNDO
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Z))
            {
                context.Scene.History.InteractiveStepBack();
                return(true);

                // REDO
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Y))
            {
                context.Scene.History.InteractiveStepForward();
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Backspace))
            {
                if (OG.IsInState(OGWorkflow.SocketState) && OG.CanTransitionToState(OGWorkflow.RectifyState))
                {
                    OG.TransitionToState(OGWorkflow.RectifyState);
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.UpArrow) || Input.GetKeyUp(KeyCode.DownArrow))
            {
                float sign = Input.GetKeyUp(KeyCode.UpArrow) ? 1 : -1;
                if (OG.LastActiveModelingOp != null)
                {
                    if (OG.LastActiveModelingOp is PlaneBandExpansionOp)
                    {
                        PlaneBandExpansionOp deform = OG.LastActiveModelingOp as PlaneBandExpansionOp;
                        deform.BandDistance = MathUtil.Clamp(deform.BandDistance + sign * 2.0f, 10.0f, 1000.0f);
                    }
                    if (OG.LastActiveModelingOp is EnclosedRegionSmoothOp)
                    {
                        EnclosedRegionSmoothOp deform = OG.LastActiveModelingOp as EnclosedRegionSmoothOp;
                        deform.OffsetDistance += sign * 0.1f;
                    }
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.LeftArrow) || Input.GetKeyUp(KeyCode.RightArrow))
            {
                float sign = Input.GetKeyUp(KeyCode.RightArrow) ? 1 : -1;
                if (OG.LastActiveModelingOp != null)
                {
                    if (OG.LastActiveModelingOp is PlaneBandExpansionOp)
                    {
                        PlaneBandExpansionOp deform = OG.LastActiveModelingOp as PlaneBandExpansionOp;
                        deform.PushPullDistance += sign * 0.25f;
                    }
                    if (OG.LastActiveModelingOp is EnclosedRegionOffsetOp)
                    {
                        EnclosedRegionOffsetOp deform = OG.LastActiveModelingOp as EnclosedRegionOffsetOp;
                        deform.PushPullDistance += sign * 0.25f;
                    }
                    if (OG.LastActiveModelingOp is EnclosedRegionSmoothOp)
                    {
                        EnclosedRegionSmoothOp deform = OG.LastActiveModelingOp as EnclosedRegionSmoothOp;
                        deform.SmoothAlpha += sign * 0.1f;
                    }
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.LeftBracket) || Input.GetKeyUp(KeyCode.RightBracket))
            {
                SculptCurveTool tool = OG.ActiveToolAs <SculptCurveTool>();
                if (tool != null)
                {
                    float  fSign    = Input.GetKeyUp(KeyCode.LeftBracket) ? -1 : 1;
                    double fRadiusS = tool.Radius.SceneValue;
                    fRadiusS    = MathUtil.Clamp(fRadiusS + 2.5 * fSign, 5.0, 100.0);
                    tool.Radius = fDimension.Scene(fRadiusS);
                }
                return(true);
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Q))
            {
                FPlatform.QuitApplication();
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 6
0
 public void BeginDraw_Spatial(AnyRayHit rayHit, Frame3f handFrame)
 {
     BeginDraw_Ray(rayHit);
     startHandF = handFrame;
     handHitVec = startHandF.ToFrameP(rayHit.hitPos);
 }
Ejemplo n.º 7
0
        public HUDRadialMenu GenerateSceneObjectRadialMenu(float fDiameter, AnyRayHit rayHit)
        {
            HUDRadialMenu popup = new HUDRadialMenu();

            popup.Radius    = fDiameter * 0.5f;
            popup.TextScale = fDiameter * TextScale;

            popup.SubItemRadialWidth   = popup.Radius * 0.75f;
            popup.SubItemRadialPadding = popup.Radius * 0.05f;
            popup.SubItemTextScale     = popup.TextScale * 0.75f;

            float Pullback = 2.0f;

            HUDRadialMenu.MenuItem teleport = popup.AppendMenuItem("Teleport", (s, o) => {
                Teleporter.TeleportTowards(cockpit.ActiveCamera, cockpit.Scene, rayHit.hitPos, Pullback);
            });
            popup.AppendSubMenuItem(teleport, "Teleport\nLevel", (s, o) => {
                Teleporter.TeleportTowards_Level(cockpit.ActiveCamera, cockpit.Scene, rayHit.hitPos, Pullback);
            });
            popup.AppendSubMenuItem(teleport, "Teleport\nNormal", (s, o) => {
                Teleporter.Teleport_Normal_Auto(cockpit.ActiveCamera, cockpit.Scene, rayHit.hitPos, rayHit.hitNormal, Pullback);
            });

            popup.AppendMenuItem("Center", (s, o) => {
                cockpit.ActiveCamera.Animator().AnimatePanFocus(rayHit.hitPos, CoordSpace.WorldCoords, 0.3f);
            });
            if (rayHit.hitSO != null)
            {
                popup.AppendMenuItem("Delete", (s, o) => {
                    cockpit.Scene.History.PushChange(
                        new DeleteSOChange()
                    {
                        scene = cockpit.Scene, so = rayHit.hitSO
                    });
                    cockpit.Scene.History.PushInteractionCheckpoint();
                });
            }

            // Ungroup menu item
            if (cockpit.Scene.Selected.Count == 0 && rayHit.hitSO is GroupSO)
            {
                popup.AppendMenuItem("Ungroup", (s, o) => {
                    cockpit.Scene.History.PushChange(
                        new UnGroupChange()
                    {
                        Group = rayHit.hitSO as GroupSO, Scene = cockpit.Scene
                    }, false);
                    cockpit.Scene.History.PushInteractionCheckpoint();
                });
            }

            // Group menu item
            int nGroupable = cockpit.Scene.Selected.Count;

            if (nGroupable > 1)
            {
                popup.AppendMenuItem("Group", (s, o) => {
                    List <SceneObject> Selected = new List <SceneObject>();
                    foreach (var so in cockpit.Scene.Selected)
                    {
                        Selected.Add(so);
                    }
                    // clear selection and then do this command next frame, so that any active gizmos can clean themselves up!
                    cockpit.Scene.ClearSelection();
                    cockpit.Context.RegisterNextFrameAction(() => {
                        cockpit.Scene.History.PushChange(
                            new CreateGroupChange()
                        {
                            Objects = Selected, Scene = cockpit.Scene
                        }, false);
                        cockpit.Scene.History.PushInteractionCheckpoint();
                    });
                });
            }

            return(popup);
        }
Ejemplo n.º 8
0
        public override Capture BeginCapture(InputState input, CaptureSide eSide)
        {
            if (input.LeftCaptureActive || input.RightCaptureActive || popup != null)
            {
                DebugUtil.Warning("SceneRightClickBehavior.BeginCapture - we should not be here...");
                return(Capture.Ignore);
            }

            Ray3f useRay = new Ray3f(Vector3f.Zero, Vector3f.AxisY);

            if (input.IsForDevice(InputDevice.Mouse) || input.IsForDevice(InputDevice.Gamepad))
            {
                useRay = (input.bRightMousePressed) ? input.vMouseWorldRay : input.vGamepadWorldRay;
            }
            else if (input.IsForDevice(InputDevice.AnySpatialDevice))
            {
                useRay = (eSide == CaptureSide.Left) ? input.vLeftSpatialWorldRay : input.vRightSpatialWorldRay;
            }

            // raycast into scene to find hit object/position for menu. We try Pivots first,
            // because they are special and have priority (?? always ??). Then we cast into general scene.
            SORayHit  pivotHit;
            bool      bHitPivot = cockpit.Scene.FindSORayIntersection(useRay, out pivotHit, (x) => { return(x is PivotSO); });
            AnyRayHit rayHit;

            if (bHitPivot)
            {
                rayHit = new AnyRayHit(pivotHit);
            }
            else
            {
                if (cockpit.Scene.FindSceneRayIntersection(useRay, out rayHit) == false)
                {
                    return(Capture.Ignore);
                }
            }

            // find center of menu in space
            Vector3f vHUDCenter   = cockpit.RootGameObject.GetPosition();
            Vector3f menuLocation = rayHit.hitPos;

            if (Placement == PlacementMode.OnHUDSphere)
            {
                float fRayT;
                bool  bHit = RayIntersection.Sphere(useRay.Origin, useRay.Direction,
                                                    vHUDCenter, HUDRadius, out fRayT);
                Debug.Assert(bHit);
                menuLocation = useRay.Origin + fRayT * useRay.Direction;
            }

            // compute extents
            float fDiameter = VRUtil.GetVRRadiusForVisualAngle(
                menuLocation, cockpit.ActiveCamera.GetPosition(), VisualDiameter);

            if (rayHit.eType == HitType.SceneObjectHit && rayHit.hitSO is PivotSO)
            {
                popup = GeneratePivotRadialMenu(fDiameter, rayHit.hitSO as PivotSO);
            }
            else if (rayHit.eType == HitType.SceneObjectHit)
            {
                popup = GenerateSceneObjectRadialMenu(fDiameter, rayHit);
            }
            else
            {
                popup = GenerateDefaultRadialMenu(fDiameter, rayHit);
            }
            popup.Create();
            popup.Name = "popup_menu";

            if (Placement == PlacementMode.InScene)
            {
                HUDUtil.PlaceInScene(popup, vHUDCenter, menuLocation);
            }
            else
            {
                HUDUtil.PlaceInSphere(popup, HUDRadius, vHUDCenter, menuLocation);
            }

            // this is a bit of a hack...radial menu lives in-scene, if we attach it to
            //   cockpit then it will move with cockpit, which is wrong. So we want to
            //   stick it in the scene. But, at least for now, we still want it to be
            //   drawn in the cockpit layer, so we add to cockpit first, them remove and
            //   re-add to the scene
            cockpit.AddUIElement(popup, false);
            cockpit.RemoveUIElement(popup, false);
            cockpit.Scene.AddUIElement(popup, false);

            HUDUtil.AnimatedShow(popup, 0.2f);

            return(Capture.Begin(this, eSide));
        }
Ejemplo n.º 9
0
        public bool HandleShortcuts()
        {
            bool bShiftDown = Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift);
            bool bCtrlDown  = Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl);

            // ESCAPE CLEARS ACTIVE TOOL OR SELECTION
            if (Input.GetKeyUp(KeyCode.Escape))
            {
                if (CCActions.IsPreferencesVisible())
                {
                    CCActions.HidePreferencesDialog();
                }
                else if (CCActions.InTool)
                {
                    CCActions.CancelCurrentTool();
                }
                else if (context.Scene.Selected.Count > 0)
                {
                    context.Scene.ClearSelection();
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Delete))
            {
                if (CCActions.InTool == false)
                {
                    CCActions.DeleteSelectedObjects(true);
                }
                return(true);


                // CENTER TARGET (??)
            }
            else if (Input.GetKeyUp(KeyCode.C))
            {
                Ray3f     cursorRay = context.MouseController.CurrentCursorWorldRay();
                AnyRayHit hit       = null;
                if (context.Scene.FindSceneRayIntersection(cursorRay, out hit))
                {
                    context.ActiveCamera.Animator().AnimatePanFocus(hit.hitPos, CoordSpace.WorldCoords, 0.3f);
                }
                return(true);

                // DROP A COPY
            }
            else if (Input.GetKeyUp(KeyCode.D))
            {
                if (CCActions.InTool == false)
                {
                    CCActions.DuplicateSelectedObjects(true);
                }
                return(true);

                // Mesh Editor
            }
            else if (Input.GetKeyUp(KeyCode.E))
            {
                if (bCtrlDown)
                {
                    CCActions.DoMeshExport();
                }
                else
                {
                    CCActions.BeginTool(MeshEditorTool.Identifier);
                }
                return(true);

                // TOGGLE FRAME TYPE
            }
            else if (Input.GetKeyUp(KeyCode.F))
            {
                FrameType eCur = context.TransformManager.ActiveFrameType;
                context.TransformManager.ActiveFrameType = (eCur == FrameType.WorldFrame)
                    ? FrameType.LocalFrame : FrameType.WorldFrame;
                return(true);

                // Fill Holes
            }
            else if (Input.GetKeyUp(KeyCode.H))
            {
                CCActions.BeginTool(FillHolesTool.Identifier);
                return(true);

                // Autorepair
            }
            else if (Input.GetKeyUp(KeyCode.I))
            {
                CCActions.BeginTool(MeshAutoRepairTool.Identifier);
                return(true);

                // CENTER AND ON BED
            }
            else if (Input.GetKeyUp(KeyCode.N))
            {
                if (CCActions.InTool == false)
                {
                    CCActions.AcceptAndExitCurrentTool();
                    CCActions.MoveCurrentToPrintBed(false);
                    CCActions.CenterCurrent(true);
                }
                return(true);

                // Remesh or Simplify
            }
            else if (Input.GetKeyUp(KeyCode.R))
            {
                if (bShiftDown)
                {
                    CCActions.BeginTool(ReduceTool.Identifier);
                }
                else
                {
                    CCActions.BeginTool(RemeshTool.Identifier);
                }
                return(true);

                // SET UNITS/SIZE
            }
            else if (Input.GetKeyUp(KeyCode.U))
            {
                CCActions.BeginTool(SetDimensionsTool.Identifier);
                return(true);

                // VISIBILITY  (V HIDES, SHIFT+V SHOWS)
            }
            else if (Input.GetKeyUp(KeyCode.V))
            {
                // show/hide (should be abstracted somehow?? instead of directly accessing GOs?)
                if (bShiftDown)
                {
                    foreach (SceneObject so in context.Scene.SceneObjects)
                    {
                        so.RootGameObject.Show();
                    }
                }
                else
                {
                    foreach (SceneObject so in context.Scene.Selected)
                    {
                        so.RootGameObject.Hide();
                    }
                    context.Scene.ClearSelection();
                }
                return(true);

                // UNDO
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Z))
            {
                context.Scene.History.InteractiveStepBack();
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Backspace))
            {
                context.Scene.History.InteractiveStepBack();
                return(true);

                // REDO
            }
            else if (bCtrlDown && Input.GetKeyUp(KeyCode.Y))
            {
                context.Scene.History.InteractiveStepForward();
                return(true);

                // Toggle Y/Z Up
            }
            else if (bShiftDown && Input.GetKeyUp(KeyCode.Z))
            {
                if (CCActions.InTool == false)
                {
                    CCActions.AcceptAndExitCurrentTool();
                    CCActions.SwapCurrentUpDirections(true);
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.UpArrow))
            {
                int step = (bShiftDown) ? 10 : 1;
                CC.Objects.CurrentLayer = CC.Objects.CurrentLayer + step;
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.DownArrow))
            {
                int step = (bShiftDown) ? 10 : 1;
                CC.Objects.CurrentLayer = CC.Objects.CurrentLayer - step;
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.A))
            {
                CCActions.AcceptAndExitCurrentTool();
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Q) && bCtrlDown)
            {
                FPlatform.QuitApplication();
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.S))
            {
                if (bCtrlDown && bShiftDown)
                {
                    CCActions.SaveCurrentSceneAs();
                }
                else if (bCtrlDown)
                {
                    CCActions.SaveCurrentSceneOrSaveAs();
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.X))
            {
                if (FPlatform.InUnityEditor())
                {
                    //CC.ActiveContext.Scene.ClearHistory();
                    CC.ActiveContext.Scene.History.DebugPrint();
                }
                return(true);
            }
            else if (bShiftDown && Input.GetKeyUp(KeyCode.Alpha1))
            {
                if (FPlatform.InUnityEditor() == false && bCtrlDown == false)
                {
                    return(true);
                }
                string lastFile = FPlatform.GetPrefsString("LastImportPath", "");
                if (lastFile != "")
                {
                    if (lastFile.EndsWith(".cota"))
                    {
                        CCActions.DoFileOpen(lastFile, false, (str) => {
                            CC.ActiveScene.ClearHistory();
                        });
                    }
                    else
                    {
                        CCActions.ClearScene();
                        CCActions.DoFileImport(lastFile, false, (str) => {
                            CC.ActiveScene.ClearHistory();
                        });
                    }
                }
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.W))
            {
                CCActions.WireframeEnabled = !CCActions.WireframeEnabled;
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha1))
            {
                CCActions.SwitchToViewMode(AppViewMode.PrintView);
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha2))
            {
                CCActions.SwitchToViewMode(AppViewMode.RepairView);
                return(true);
            }
            else if (Input.GetKeyUp(KeyCode.Alpha3))
            {
                CCActions.SwitchToViewMode(AppViewMode.ModelView);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 10
0
 public void BeginDraw_Spatial(Ray3f ray, AnyRayHit rayHit, Frame3f handFrame, int nStep)
 {
     BeginDraw_Ray(ray, rayHit, nStep);
 }