• Advertisement

Archived

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

free moving

This topic is 6033 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

i have a problem with free moving in my 3d-world: i can move to the directions forward, backward, strafing left and right and i can look to any direction with my mouse. and now i want it, that i can move to any direction i am looking like the spectator mode in the quake engines. here is a part my code. can anyone help me to change the code that i can move to any direction i am looking? or has anybody a better way of moving in a 3d-world - please tell me !! ... i think i have to say that the core of this code is from the nehe tutorials void Update() { static float xrot=0,yrot=0; static float xpos=0,ypos=0,zpos=0; if(win.key[VK_UP]) { xpos-=(float)sin(-yrot*pi180)*0.05f; zpos-=(float)cos(-yrot*pi180)*0.05f; } if(win.key[VK_DOWN]) { xpos+=(float)sin(-yrot*pi180)*0.05f; zpos+=(float)cos(-yrot*pi180)*0.05f; } if(win.key[VK_LEFT]) { xpos-=(float)cos(yrot*pi180)*0.05f; zpos-=(float)sin(yrot*pi180)*0.05f; } if(win.key[VK_RIGHT]) { xpos+=(float)cos(yrot*pi180)*0.05f; zpos+=(float)sin(yrot*pi180)*0.05f; } mouse.GetState(); yrot+=(float)mouse.mstate.lX; xrot+=(float)mouse.mstate.lY; glRotatef(xrot,1.0f,0.0f,0.0f); glRotatef(yrot,0.0f,1.0f,0.0f); glTranslatef(-xpos,-ypos,-zpos); }

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement