Example #1
0
        /// <summary>
        /// Update movement of camera
        /// </summary>
        public void UpdateInput()
        {
            IKeyboard keyboard = InputEngine.Instance.Keyboard;
            IMouse    mouse    = InputEngine.Instance.Mouse;

            // Todo: remove and give app more control over updateInput
            if (!keyboard.IsDown(Key.LeftControl))
            {
                return;
            }

            float deltaX = mouse.Delta.X * mouseSpeed;
            float deltaY = mouse.Delta.Y * mouseSpeed;

            if (mouse.IsDown(MouseButton.Middle) ||
                (mouse.IsDown(MouseButton.Left) && mouse.IsDown(MouseButton.Right)))
            {
                position.X += deltaX * panSpeed;
                position.Y -= deltaY * panSpeed;
            }
            else if (mouse.IsDown(MouseButton.Left))
            {
                Rotate(deltaX * rotateSpeed, deltaY * rotateSpeed);
            }
            else if (mouse.IsDown(MouseButton.Right))
            {
                position.Z += (-deltaX - deltaY) * zoomSpeed;
            }
            mouse.Position = new Vector3(0.5f, 0.5f, 0.0f);
        }