Esempio n. 1
0
        public void MouseMove(MouseEventInfo e, KeyEventInfo k, Vector2 previousLocation)
        {
            var position = e.FullPosition;
            var movement = new Vector2(position.X, position.Y) - previousLocation;

            if (e.RightButton == ButtonState.Pressed && !_camera.LockRotation)
            {
                if (k.KeyCtrl)
                {
                    _camera._targetDistance *= 1 - movement.Y * -5 * 0.001f;
                }
                else
                {
                    if (!k.IsKeyDown("y"))
                    {
                        _camera.RotationX += movement.Y * rotFactorX;
                    }
                    if (!k.IsKeyDown("x"))
                    {
                        _camera.RotationY += movement.X * rotFactorY;
                    }

                    //Reset direction
                    _camera.Direction = Camera.FaceDirection.Any;
                }
            }
            if (e.LeftButton == ButtonState.Pressed)
            {
                Pan(movement.X * _camera.PanSpeed, movement.Y * _camera.PanSpeed);
            }
            _camera.UpdateMatrices();
        }
Esempio n. 2
0
 public void MouseClick(MouseEventInfo e, KeyEventInfo k)
 {
     if (k.KeyCtrl && e.RightButton == ButtonState.Pressed && _camera.Depth != _camera.ZFar)
     {
         // _camera.TargetPosition = -_camera.CoordFor(e.X, e.Y, _camera.Depth);
     }
 }
Esempio n. 3
0
        public void MouseWheel(MouseEventInfo e, KeyEventInfo k)
        {
            if (k.KeyCtrl)
            {
                float delta = -e.Delta * Math.Min(0.1f, _camera.Depth / 500f);

                delta *= _camera.TargetDistance;

                Vector2 normCoords = OpenGLHelper.NormMouseCoords(e.X, e.Y, _camera.Width, _camera.Height);

                Vector3 vec = _camera.InverseRotationMatrix.Row0 * -normCoords.X * delta * _camera.FactorX +
                              _camera.InverseRotationMatrix.Row1 * normCoords.Y * delta * _camera.FactorY +
                              _camera.InverseRotationMatrix.Row2 * delta;

                _camera.TargetPosition += vec;
            }
            else
            {
                Zoom(e.Delta * 0.1f * _camera.ZoomSpeed, true);
            }
        }
Esempio n. 4
0
        public void KeyPress(KeyEventInfo e)
        {
            float   movement = 0.2f * _camera.KeyMoveSpeed;
            Vector3 vec      = Vector3.Zero;

            if (e.KeyShift)
            {
                movement *= 2;
            }

            if (e.IsKeyDown(KeyController.View3D.MOVE_FORWARD))
            {
                vec.Z -= movement;
            }
            if (e.IsKeyDown(KeyController.View3D.MOVE_BACK))
            {
                vec.Z += movement;
            }
            if (e.IsKeyDown(KeyController.View3D.MOVE_LEFT))
            {
                vec.X -= movement;
            }
            if (e.IsKeyDown(KeyController.View3D.MOVE_RIGHT))
            {
                vec.X += movement;
            }

            if (e.IsKeyDown(KeyController.View3D.MOVE_DOWN))
            {
                vec.Y -= movement;
            }
            else if (e.IsKeyDown(KeyController.View3D.MOVE_UP))
            {
                vec.Y += movement;
            }

            float UP = 0;

            _camera.TargetPosition += Vector3.Transform(_camera.InverseRotationMatrix, vec) + Vector3.UnitY * UP;
        }
Esempio n. 5
0
        public void MouseWheel(MouseEventInfo e, KeyEventInfo k)
        {
            if (k.KeyShift)
            {
                float amount = e.Delta * 0.1f;
                _camera.KeyMoveSpeed += amount;
            }
            else
            {
                float delta = (e.Delta * Math.Min(k.KeyShift ? 0.04f : 0.01f, _camera.Depth / 500f));

                Vector3 vec;

                Vector2 normCoords = OpenGLHelper.NormMouseCoords(e.X, e.Y, _camera.Width, _camera.Height);

                vec.X = (-normCoords.X * delta) * _camera.FactorX;
                vec.Y = (normCoords.Y * delta) * _camera.FactorY;
                vec.Z = delta;

                _camera.TargetPosition -= Vector3.Transform(_camera.InverseRotationMatrix, vec);
            }
        }
Esempio n. 6
0
        public void MouseMove(MouseEventInfo e, KeyEventInfo k, Vector2 previousLocation)
        {
            var position = new Vector2(e.FullPosition.X, e.FullPosition.Y);
            var movement = position - previousLocation;

            if ((e.LeftButton == ButtonState.Pressed ||
                 e.RightButton == ButtonState.Pressed) && !_camera.LockRotation)
            {
                if (k.KeyCtrl)
                {
                    float   delta = ((float)movement.Y * -5 * Math.Min(0.01f, _camera.Depth / 500f));
                    Vector3 vec;
                    vec.X = 0;
                    vec.Y = 0;
                    vec.Z = delta;

                    _camera.TargetPosition += Vector3.Transform(_camera.InverseRotationMatrix, vec);
                }
                else
                {
                    if (!k.IsKeyDown("y"))
                    {
                        _camera.RotationX += movement.Y * rotFactorX;
                    }
                    if (!k.IsKeyDown("x"))
                    {
                        _camera.RotationY += movement.X * rotFactorY;
                    }

                    //Reset direction
                    _camera.Direction = Camera.FaceDirection.Any;
                }
            }
            if (e.LeftButton == ButtonState.Pressed)
            {
            }
        }
Esempio n. 7
0
 public void KeyPress(KeyEventInfo e)
 {
 }
Esempio n. 8
0
 public void MouseClick(MouseEventInfo e, KeyEventInfo k)
 {
 }