Exemplo n.º 1
0
        /// <summary>
        /// Rotates the camera according mouse movements.
        /// </summary>
        protected void HandleMouseMove(Vector mouseMove)
        {
            double factor = WFUtils.IsShiftDown() ? 0.5 : 0.1;
            double angleX = mouseMove.X * factor;
            double angleY = mouseMove.Y * factor;

            Camera.StopAnyTurn();
            if (Camera.Speed == 0)
            {
                Camera.Rotate(Math3D.UnitZ, 2 * angleX, touchPoint);
                Camera.Rotate(Camera.RightDirection, 2 * angleY, touchPoint);
            }
            else
            {
                if (Camera.MovingDirectionIsLocked)
                {
                    Camera.ChangeHeading(angleX);
                    Camera.ChangePitch(angleY);
                }
                else
                {
                    Camera.ChangeRoll(-angleX);
                    Camera.ChangePitch(angleY);
                }
            }
        }
Exemplo n.º 2
0
        protected override void OnKeyDown(KeyEventArgs e)
        {
            base.OnKeyDown(e);
            if (!IsInteractive)
            {
                return;
            }

            //--- assume we are handling the key
            e.Handled = true;
            double amount = WFUtils.IsShiftDown() ? 1 : 0.2;

            if (WFUtils.IsCtrlDown())
            {
                amount *= WFUtils.IsAltDown() ? 0.1 : 0.5;
                amount *= Camera.Scale;
                switch (e.Key)
                {
                case Key.Up: Camera.Move(Camera.LookDirection, +amount); return;

                case Key.Down: Camera.Move(Camera.LookDirection, -amount); return;

                case Key.Left: Camera.Move(Camera.LeftDirection, +amount); return;

                case Key.Right: Camera.Move(Camera.LeftDirection, -amount); return;

                case Key.Prior: Camera.Move(Camera.UpDirection, +amount); return;

                case Key.Next: Camera.Move(Camera.UpDirection, -amount); return;

                default: e.Handled = false; return;
                }
            }

            switch (e.Key)
            {
            case Key.Up: Camera.ChangePitch(amount); break;

            case Key.Down: Camera.ChangePitch(-amount); break;

            case Key.Left: if (Camera.Speed == 0)
                {
                    Camera.ChangeYaw(amount);
                }
                else
                {
                    Camera.ChangeRoll(-amount);
                } break;

            case Key.Right: if (Camera.Speed == 0)
                {
                    Camera.ChangeYaw(-amount);
                }
                else
                {
                    Camera.ChangeRoll(+amount);
                } break;

            case Key.Prior: Camera.ChangeRoll(-amount); break;

            case Key.Next: Camera.ChangeRoll(+amount); break;

            case Key.W: Camera.Speed++; return;

            case Key.S: Camera.Speed--; return;

            case Key.X: Camera.Speed = 0; return;

            case Key.F: Camera.FlyParallel(); return;

            case Key.A: Camera.FlyParallel(-1); return;

            case Key.D: Camera.FlyParallel(+1); return;

            case Key.T: Camera.LookBack(); return;

            case Key.H: ToggleHelperModels(); return;

            case Key.Space: Camera.LookAtOrigin(); return;

            case Key.D1: ActivateCamera(0); return;

            case Key.D2: ActivateCamera(1); return;

            case Key.D3: ActivateCamera(2); return;

            default: e.Handled = false; return;
            }

            Camera.StopAnyTurn();
        }