bondi

01-02-2002, 11:47 PM

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!!!!!

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!!!!!