public void RotateFirstPerson(float headingDegrees, float pitchDegrees)
{
accumPitchDegrees += pitchDegrees;
if (accumPitchDegrees > 90.0f)
{
pitchDegrees = 90.0f - (accumPitchDegrees - pitchDegrees);
accumPitchDegrees = 90.0f;
}
if (accumPitchDegrees < -90.0f)
{
pitchDegrees = -90.0f - (accumPitchDegrees - pitchDegrees);
accumPitchDegrees = -90.0f;
}
float heading = MathHelper.ToRadians(headingDegrees);
float pitch = MathHelper.ToRadians(pitchDegrees);
Quaternion rotation = Quaternion.Identity;
// Rotate the camera about the world Y axis.
if (heading != 0.0f)
{
Quaternion.CreateFromAxisAngle(ref WORLD_Y_AXIS, heading, out rotation);
Quaternion.Concatenate(ref rotation, ref orientation, out orientation);
}
// Rotate the camera about its local X axis.
if (pitch != 0.0f)
{
Quaternion.CreateFromAxisAngle(ref WORLD_X_AXIS, pitch, out rotation);
Quaternion.Concatenate(ref orientation, ref rotation, out orientation);
}
}