Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

bondi

6 degrees freedom in flight sim with glRotate* and glTranslate*

This topic is 6043 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I''ve written a flight sim. For the viewpoint, i don''t want to use gluLookAt(). So I use glRotate* and glTranslate*. But I''ve some problems. Here is a piece of my sim code: 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!!!!!

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!