Sign in to follow this  
boyindie

airplane movement

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this