Jump to content
  • Advertisement
Sign in to follow this  
nivlekio

Finding positions of 3d objects

This topic is 4080 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

Hey all new gl programmer here, i am making a 3d scene for a uni course work, and i decided to make the solar system all was going well until now. I have my planets translated and rotating around the sun and i have a vector based class camera, and what i want to do is find the position of a planet ( made the planets with quadratics ) and teleport my camera there eg the user presses one the camera teleports to mars, user presses 9 the camera teleports to Pluto eg. How on earth do i find the position of a 3d object after it has been translated or rotated about an axis???? Many thanks for your help in advance :D

Share this post


Link to post
Share on other sites
Advertisement
Since you are using glRotate and glTranslate, you will need to get the modelview matrix back from it just before you render your object/just after you do the transforms:


float Modelview[16];
glGetFloatv( GL_MODELVIEW_MATRIX, Modelview );


You will then need to multiply the matrix by the position of the model - centre point of all vertices in the object, or in your case, just the position you generate the quadrics at. This will give you the position of the model [smile]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!