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);
}