Original Post
I'm using quaternions to rotate my camera around an object. I want to combine the cameras current rotation with an amount of extra rotation when the mouse moves. Any explanation I can find just says to multiply the quaternion for the current rotation with a quaterion for the angle to rotate it by. However if I try to change the pitch when the camera has already been rotated to the side of my object, I get the effect of the roll changing instead. How can I get the camera to rotate relative to it's current position instead of it's starting position? I want it to behave like I'd multiplied the current rotation matrix by another matrix, except avoiding gimbal lock since I'm using quaternions. Here's the code I'm using:
public void RotateVertical(float fAngle)
{
m_xRotation *= Quaternion.RotationYawPitchRoll(0.0f, fAngle, 0.0f);
}
public void RotateHorizontal(float fAngle)
{
m_xRotation *= Quaternion.RotationYawPitchRoll(fAngle, 0.0f, 0.0f);
} Where m_xRotation is a quaternion that my camera position gets rotated by before being passed into Matrix.LookAtLH. I know this has probably been asked many times before, but the answer is usually "use quaternions" which I already am, "multiply the quaternions" like I am or an explanation of how to convert an Euler to a Quaternion, which the RotationYawPitchRoll method already does.