I have a quaternion class implementation, and when I apply this class to my objects all gone right (rotations), but I have a lot of troubles with the camera. I've been searching a lot trying to solved my problem but nothing works.
When I do a yaw and then a pitch rotation (or vice versa) a roll rotation is introduced. If I do the Y rotation around local axis the undesired roll disappears, but looking up and down will not work properly after a roll rotation (so I need to apply the Y rotation around the global axis).
Like I said, applying the quaternion to the object works fine, so maybe the problem is when passing the rotation data to opengl. I do this like that:
mainCamera.getAnglesAxis(angle, vAngle);
glRotatef(-angle, vAngle.getX(), vAngle.getY(), vAngle.getZ());
glTranslatef(-mainCamera.getX(), -mainCamera.getY(), -mainCamera.getZ());
glTranslatef(obj.getX(),obj.getY(),obj.getZ());
cube.getAnglesAxis(angle, vAngle);
glRotatef(angle, vAngle.getX(), vAngle.getY(), vAngle.getZ());
drawCube();
I'm doing it right?