Skip to main content
gamedev.net
🔒 Locked

3d rotation

Started by kajjait May 30, 2002 at 3:51 PM 1 replies 550+ views
Original Post
kajjait
kajjait
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 ?
Waverider
Waverider
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?
It's not what you're taught, it's what you learn.
kajjait
kajjait
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 ?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.