rotating the camera around y axis

My camera can pitch and yaw but I would like it to yaw NOT relative to the new camera’s rotation. In other words, I would like the yaw to always rotate around an axis (0,1,0) in world coordinates relative to the camera position.

I tried translating back to the origin, rotating the Y axis and translating back but that didn’t work. I also tried rotating around an arbitrary axis.

Could someone please point me in the right direction? Thanks!

I don’t understand… do you rotate the camera in one glRotatef() call? Remember you can call that function multiple times, so you can rotate around all axes independently. I think I’ve had the same problem. If you do use multiple calls, try to change the order, that should help.

[This message has been edited by mm_freak (edited 11-08-2002).]

Have you looked at glulookat

Here is my code to do it (Z is up):

inline void TerrainCamera::Yaw( float angle )
// Yaw for this camera is always around the terrain’s Z axis so
// the camera’s Z axis is un-oriented to get that axis.
Turn( angle, Vector3f( Vector3f::ZAxis() ).Rotate( -GetOrientation() ) );

I already store a current matrix for my camera and I do glLoadMatrixf(cameraMatrix) in the beginning of my drawing.

So, I guess I should do the y rotation as the very first transformation and then multiply that matrix by my current camera matrix to get the new camera matrix rotated in the way I need it?

OK, I got it working now. I needed to convert my camera matrix to its inverse before doing glLoadMatrix because I was treating the camera matrix just like any other object.