# Looking for a good way to move a model in 3D

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

## Recommended Posts

Hey I have an F16 model that I am trying to move around in 3D with the arrow keys. I draw the plane by giving it's xyz location, direction vector, and up vector. I am trying to figure out a good way to move the plane around my skybox in 3d using the arrow keys probobally left and right to pivot in the X plane forward and backward to move to and fro in the direction it is pointing and pgdn and pgup to pivot in the y plane. I am currently using gllookat() to view the model. I have tried a couple different options but nothing worked out right. Anyone have an easy way to do this?

##### Share on other sites
Try a combination of glRotate and glTranslate or use your own transformation matrices. Basically it's just a matter of matrix multiplication.

You move the plane and move the camera with it. The skybox isn't moved at all (identity modelview transformation, except camera rotation).

##### Share on other sites
I am trying to use a rotation matrix and I want to change direction by modifying Dx. What I originally did was start the plane point Dx 1 and Dz 0 so it was pointing directly in the direction of the positive X. Then when you press left I would have it decrease Dx by the same amount that I decreased Dz so eventually when you got to be pointing directly in the negative Z direction your Dx was zero and Dz was -1. My problem was that I was also using Dx and Dz to set up my gluLookat() (I had X Y Z for my object coords and I was set (Ex = eye x) Ex = X - 7*Dx and so on for the rest) basically I was trying to use this to know where to look but my problem was when Dx or Dz was zero you couldn't see the object at all and when Dx approached 1 it got very far away. How would I do this and maintain a constant eye position relative to the object?

1. 1
Rutin
70
2. 2
3. 3
4. 4
5. 5

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633430
• Total Posts
3011825
• ### Who's Online (See full list)

There are no registered users currently online

×