MoodSwingCoreComponents.MSCamera.Rotate C# (CSharp) 메소드

Rotate() 공개 메소드

Rotates the camera.
public Rotate ( Vector2 rotation ) : void
rotation Vector2 A Vector2D whose X coordinate represents the direction of the angle of the yaw rotation /// and whose Y coordinate represents the direction of the angle of the pitch rotation
리턴 void
        public void Rotate( Vector2 rotation )
        {
            float angle = .005f;
            Vector3 transformedReference;

            float pitchRotationAngle = angle * rotation.Y;
            if (currPitchAngle + pitchRotationAngle > maxPitchAngle)
                pitchRotationAngle = maxPitchAngle - currPitchAngle;
            else if (currPitchAngle + pitchRotationAngle < minPitchAngle)
                pitchRotationAngle = minPitchAngle - currPitchAngle;
            Matrix pitchRotationMatrix = Matrix.CreateFromAxisAngle(pitchAxis, pitchRotationAngle);
            currPitchAngle += pitchRotationAngle;
            transformedReference = Vector3.Transform(cameraPosition, pitchRotationMatrix);
            Vector3 transformedUpCamera = Vector3.Transform(upCamera, pitchRotationMatrix);
            upCamera = transformedUpCamera;

            Matrix yawRotationMatrix = Matrix.CreateFromAxisAngle(Vector3.UnitZ, angle * rotation.X);
            transformedReference = Vector3.Transform(transformedReference, yawRotationMatrix);
            upCamera = Vector3.Transform(upCamera, yawRotationMatrix);
            cameraPosition = transformedReference;
            currYawRotation += rotation.X;

            viewVector = cameraPosition - cameraTarget;
            normalizedViewVector = Vector3.Normalize(viewVector);

            AdjustPitchAxis();
            frustum = new BoundingFrustum(camera.GetView() * camera.ProjectionMatrix);
        }