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

## 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 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.)

1. 1
2. 2
3. 3
Rutin
19
4. 4
5. 5

• 10
• 14
• 30
• 13
• 11
• ### Forum Statistics

• Total Topics
631782
• Total Posts
3002332
×