예제 #1
0
        /// <summary>
        /// Rotates the specified p0.
        /// </summary>
        /// <param name="p0">The p0.</param>
        /// <param name="p1">The p1.</param>
        /// <param name="rotateAround">The rotate around.</param>
        /// <param name="stopOther">if set to <c>true</c> [stop other].</param>
        public void Rotate(Vector2 p0, Vector2 p1, Vector3 rotateAround, bool stopOther = true)
        {
            if (!this.Controller.IsRotationEnabled)
            {
                return;
            }
            if (stopOther)
            {
                Controller.StopZooming();
                Controller.StopPanning();
            }
            p0 = Vector2.Multiply(p0, Controller.AllowRotateXY);
            p1 = Vector2.Multiply(p1, Controller.AllowRotateXY);
            Vector3 newPos  = Camera.CameraInternal.Position;
            Vector3 newLook = Camera.CameraInternal.LookDirection;
            Vector3 newUp   = Vector3.Normalize(Camera.CameraInternal.UpDirection);

            switch (this.Controller.CameraRotationMode)
            {
            case CameraRotationMode.Trackball:
                CameraMath.RotateTrackball(CameraMode, ref p0, ref p1, ref rotateAround, (float)RotationSensitivity,
                                           Controller.Width, Controller.Height, Camera, Inv, out newPos, out newLook, out newUp);
                break;

            case CameraRotationMode.Turntable:
                var p = p1 - p0;
                CameraMath.RotateTurntable(CameraMode, ref p, ref rotateAround, (float)RotationSensitivity,
                                           Controller.Width, Controller.Height, Camera, Inv, ModelUpDirection, out newPos, out newLook, out newUp);
                break;

            case CameraRotationMode.Turnball:
                CameraMath.RotateTurnball(CameraMode, ref p0, ref p1, ref rotateAround, (float)RotationSensitivity,
                                          Controller.Width, Controller.Height, Camera, Inv, out newPos, out newLook, out newUp);
                break;

            default:
                break;
            }
            Camera.LookDirection = newLook.ToVector3D();
            Camera.Position      = newPos.ToPoint3D();
            Camera.UpDirection   = newUp.ToVector3D();
        }
예제 #2
0
        /// <summary>
        /// Rotate the camera around the specified point.
        /// </summary>
        /// <param name="p0">
        /// The p 0.
        /// </param>
        /// <param name="p1">
        /// The p 1.
        /// </param>
        /// <param name="rotateAround">
        /// The rotate around.
        /// </param>
        /// <param name="stopOther">Stop other manipulation</param>
        public void Rotate(Vector2 p0, Vector2 p1, Vector3 rotateAround, bool stopOther = true)
        {
            if (!this.Controller.IsRotationEnabled)
            {
                return;
            }
            if (stopOther)
            {
                Controller.StopZooming();
                Controller.StopPanning();
            }
            var newPos  = Camera.Position;
            var newLook = Camera.LookDirection;
            var newUp   = Vector3.Normalize(Camera.UpDirection);

            switch (this.Controller.CameraRotationMode)
            {
            case CameraRotationMode.Trackball:
                CameraMath.RotateTrackball(CameraMode, ref p0, ref p1, ref rotateAround, (float)RotationSensitivity,
                                           Controller.Width, Controller.Height, Camera, inv, out newPos, out newLook, out newUp);
                break;

            case CameraRotationMode.Turntable:
                var p = p1 - p0;
                CameraMath.RotateTurntable(CameraMode, ref p, ref rotateAround, (float)RotationSensitivity,
                                           Controller.Width, Controller.Height, Camera, inv, ModelUpDirection, out newPos, out newLook, out newUp);
                break;

            case CameraRotationMode.Turnball:
                CameraMath.RotateTurnball(CameraMode, ref p0, ref p1, ref rotateAround, (float)RotationSensitivity,
                                          Controller.Width, Controller.Height, Camera, inv, out newPos, out newLook, out newUp);
                break;
            }
            Camera.LookDirection = newLook;
            Camera.Position      = newPos;
            Camera.UpDirection   = newUp;
        }