PDA

View Full Version : 6 degress of Freedom for flight sims

lsdi
12-31-2001, 06:40 PM
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:

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;

Bob
01-01-2002, 02:36 AM
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.

Alessandro_dup1
01-01-2002, 05:23 AM
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.

lsdi
01-01-2002, 09:24 AM
Your project its great(glhorizon). Thanks for help.

lsdi
01-01-2002, 10:10 AM
I in trouble in some parts do your tutorial , Penetrator, can you send me a example in C?

thanks a lot;

Bob
01-02-2002, 04:10 AM
You should really use quaternions to avoid the gimal lock problem.

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