Jump to content
  • Advertisement

Archived

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

kajjait

3d rotation

This topic is 5921 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 need to know they best best way to rotate a 3d model given x,y,z coordinates to "look at" like how the camera works.. or maybe there is a better way to rotate things.. im making a 3d space combat game and i need the enemies to "follow" the player around for combat heh what would be the best way to accomplish this ?

Share this post


Link to post
Share on other sites
Advertisement
For my own coding I used an orientation structure that includes 3d vectors that detail the position, and the forward, up and left vectors that represent the actual facing of the object.

When I want to adjust a ship''s travel direction to chase after another, I just take the vector from one object''s position to the other and perform a dot product with the orientation vectors. The resulting values determine how I need to adjust the craft''s orientation to face the needed direction.

When rendering comes along, I take those elements and load up a matrix to do a glMultMatrix(). A better way might be to have the matrix already prepared within the structure, but I haven''t done that yet.

Does that make sense?

Share this post


Link to post
Share on other sites
can i maybe get some code to look at, it might make sense then .. after you get the dot product how do you change the crafts position ?

Share this post


Link to post
Share on other sites

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