I am try to pitch (nodding motion) a CameraPersp using its orientation quaternion. This is how i am currently doing this:
CameraPersp pitchedCam = mCam; // Copy base camera float pitchAmount = 0.5f; quat pitch = mCam.getOrientation(); // Get current camera orientation vec3 pitchAxis = glm::rotate( pitch, vec3(1.0f, 0.0f, 0.0f)); // Get camera x axis pitch = glm::rotate ( pitch, pitchAmount, pitchAxis ); // Roll around x axis pitchedCam.setOrientation( pitch );
I thought this logic would be the same for roll and yaw (just by changing the relative axis) but it gives unexpected results in all cases (swinging the camera around in unspecified axes). Does this have something to do with the WorldUp value in CameraPersp? I feel i’m missing something really obvious.
Any solutions or alternatives for this would be greatly appreciated (preferably using the camera orientation rather than additional model / view matrices).