Jump to content
  • Advertisement
Sign in to follow this  
boyindie

airplane movement

This topic is 3893 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 have made an world war 2 like plane, and a fractal landscape as part of a university project. i am having problems getting my plane to move around my scene. i can't get the plane to move in the correct direction, i am not sure how i would go about doing this, I stupidly thought it would jus mean rotating the plane in direction i want to go and then translating it forward in the x axis would do the trick but its always jus going to send the plane along the x axis. How can i write it so that i can get my plane to go forward in the correct direction depending on what angle its been rotated too? Any help greatly appreciated Cheers Boyindie

Share this post


Link to post
Share on other sites
Advertisement
glTranslate(d,0,0) will always translate the object along the principal x axis direction of the parental co-ordinate frame. What you want is to translate it along the local axis. However, actually doing so means to shift each vertex in the mesh. That wouldn't be good, of course. Hence, you have to determine how the local x axis is defined w.r.t. the said parental frame. Assuming you've already computed the rotation matrix (w.r.t. the parental frame), then when you fetch the "forward" vector from that matrix, you've got the vector in which the plane should move. In general that vector has all components (x,y,z) differing from 0.

From your request I assume the "first" vector of the matrix is the one of interest, since you try to move the plane in the "x" direction. Then scale that vector by the product of the plane's speed and the elapsed time, and add it to its current position to yield in the new position.

(I'll suggest you to track the orientation and position of the plane by yourself, and only applying the current values to OpenGL's MODELVIEW stack.)

Share this post


Link to post
Share on other sites
Sign in to follow this  

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