6 degress of Freedom for flight sims

I wrote this to make a 6DF game, but something its wrong:

  • I CANT PITCH MORE THEM 90º
  • THE ROLL ITS NOT SMOOTH - ITS LIKE WAVES
  • I DONT KNOW TO MOVE IN THE CAMERAS DIRECTION

Can Anyone help me or tell me where I found more info?

here is the code:

ps. sorry for bad english.

struct Camera
{
float x, y, z;
float yaw, pitch, roll;
} cam;
float tx, ty, tz=0.0f;
float rx, ry, rz=0.0f;

void mundo(void)
{
tx=cam.x+cos(cam.yaw)*0.5;
ty=cam.y+sin(cam.pitch)*0.5;
tz=cam.z+sin(cam.yaw)*0.5;
rx=sin(cam.roll)*0.5;
ry=cos(cam.roll)*0.5;
rz=0.0f;
glPushMatrix();
gluLookAt(cam.x,cam.y,cam.z,
tx,ty,tz,
rx,ry,rz);
glCallList(Lground);
glPopMatrix();
}

Thanks;

For a 6 DOF flight sim, I think it’s better if you use three calls to glRotate (along with a glTranslate to move the viewpoint) to rotate about the thre axes, pitch, yaw and roll (or whatever you call them).

The problem you have is, I believe, related to the up vector (rx, ry and rz). The up vector is specified in world coordinates, and must be rotated using the pitch and yaw also, not only roll. Thats why you have trouble, because when you pitch/yaw the camera, you don’t pitch/yaw the up vector, and you will have a wierd result.

You should really use quaternions to avoid the gimal lock problem. On my web-site (www.web-discovery.net) there is a simple project which shows use of quaternions to accomplish 6DOF.

Your project its great(glhorizon). Thanks for help.

I in trouble in some parts do your tutorial , Penetrator, can you send me a example in C?

thanks a lot;

You should really use quaternions to avoid the gimal lock problem.

Gimbal lock is a problem only if you abuse the Euler angles.