PDA

View Full Version : 6 degrees freedom with glRotate* and glTranslate*



bondi
01-03-2002, 12:47 AM
I've read the article "6 degrees of freedom for flight sims" in this forum. But I don't want to use gluLookAt for my flight sim.
so this is a piece of my flight sim:


POINT mpos;

void input()
{
GetCursorPos(&mpos);
SetCursorPos(SCREENWIDTH/2,SCREENHEIGHT/2);
heading += (float)(320 - mpos.x)/100 * 5;
yrot = heading;
updown -= (float)(240 - mpos.y)/100 * 5;

//Piover180 is simply a conversion factor
//for converting between degrees and
//radians
float speed=0.4f;
if(key[VK_UP])
{
xpos -=(float)sin(heading*piover180)*speed;
zpos -=(float)cos(heading*piover180)*speed;
ypos -=(float)sin(updown*piover180)*speed;
}

if(key[VK_DOWN])
{
xpos +=(float)sin(heading*piover180)*speed;
zpos +=(float)cos(heading*piover180)*speed;
ypos +=(float)sin(updown*piover180)*speed;
}
}

void DrawScene()
{
.........
GLfloat sceneroty = 360.0f - yrot;

glRotatef(updown,1.0f,0,0);
glRotatef(sceneroty,0,1.0f,0);
glTranslatef(-xpos,-ypos,-zpos);
.........
}

if I test test the sim, it looks to be correct. But later, I've found a bug.
I think that there is a bug in calculation of "ypos".
can anybody help me!!!!!

Bob
01-03-2002, 02:49 AM
So, you found a bug.

.
.
.

Wanna tell us what this bug is, what it looks like, what happens, when it happens, what is supposed to happen, and important stuff like that?