camera transformations

I am really stuck with a camera transformations that I am working on. It seems to be very similar to the problem that BradleyP has, but I think it might be a little different. I am writing a very primitive flight simulator. What I am trying to do is show the plane from the perspective of the cockpit, and basically, just show different camera transformations such as pitch (rotate on y axis), yaw (rotate on x axis), and roll (rotate on z axis). Also I would like to be able to send the plane forward. I have been able to get some basic functionality using a function from the OpenGL book:

void pilotView(GLdouble planex, GLdouble planey,
GLdouble planez, int roll,
int pitch, int yaw)
{
glRotated((GLfloat) roll, 0.0, 0.0, 1.0);
glRotated((GLfloat) pitch, 0.0, 1.0, 0.0);
glRotated((GLfloat) yaw, 1.0, 0.0, 0.0);
glTranslated(planex, planey, planez);
}

However, this doesn’t work all that well because after a rotation, the translation function doesn’t work the way that I would like it to. After a rotation, going forward always results in moving down the negative z-axis, instead of moving forward in whatever direction the camera is aimed at currently. I’ve heard that I could do this with quaternions, but I’ve never used them, and I’m not sure how to do it.

I’m really not even sure that I am approaching the problem the way that I should be. Is there a better way to do it? How would you do it?

Could you please help me out here? Please tell me as much as you can. Thanks

The problem is, that you have an local forward, that is into z direction, no global. You need to get the orientation vector of the current rotation. So, you need to do the rotations for an vector that is directed to 0,0,zdir. It will result in the movement direction. Then you have to update the position by adding this vector in a scaled form.

How do I change the vector, and also, how do I use the updated vector to help out my situation?

You can either get the current modelview matrix and then multiplicate it with you GLOBAL forward vector, or you can handle all the matrix stuff yourself, which is more complicated (I know…) but preferrable.
You can then scale this vector according to your current speed (for example make it 5 long if you’re flying 5m/s and your scale is in meters). Then simply add it to your current position, and here you go.