Esempio n. 1
0
        /// <summary>
        /// Gets the 3D coordinates for the given mouse XY coordinates and depth value.
        /// </summary>
        /// <returns></returns>
        public Vector3 CoordFor(int x, int y, float depth)
        {
            Vector3 vec;

            Vector2 normCoords = OpenGLHelper.NormMouseCoords(x, Height - y, Width, Height);

            Vector3 cameraPosition = TargetPosition + invRotationMatrix.Row2 * Distance;

            vec.X = (normCoords.X * depth) * FactorX;
            vec.Y = (normCoords.Y * depth) * FactorY;

            vec.Z = depth - Distance;

            return(-cameraPosition + Vector3.Transform(invRotationMatrix, vec));
        }
Esempio n. 2
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. 3
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);
            }
        }