Exemplo n.º 1
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);
            }
        }