dnstapes
11-28-2000, 08:32 AM
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
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