# camera transformations

I am really stuck with a camera transformations that I am working on. 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

Dana

[This message has been edited by dnstapes (edited 11-28-2000).]

If i have no mistake, translation should come before rotation(else plane coordinates will be rotated too). It seems to me that you should call glTranslated(-planex,-planey,-planez)
If you also want a way how to change plane’s coordinates try multiplying matrix you recieve by rotation(without translation) on move vector (like (0,0,-1))
I’m sorry if it is not works