Jump to content
  • Advertisement
Sign in to follow this  
zaneski13

ModelView Matrix Question

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

Sorry for all of these questions lately, I just joined this forum and have lots of questions. I need to get the world location of a face, a quad. If I call glRotatef() the next thing I draw will be rotated. How can I get the position of that vertex that I'm going to draw next with glVertex3f(); so I call glLoadIdentity(); then I call glVertex3f( x, y, z ); now thats easy to figure out. x, y, z are the global positions of that quad now I call glRotatef( 34.0f, 0.0f, 1.0f, 0.0f ); now I draw another vertex. glVertex3f( x, y, z ); but that isn't the global position because I called glRotate. If I wanted to do colision detection, it would be off. I know you have to do something with the data in the modelview matrix but I'm just not sure what. Maybe someone could write a simple function where you pass in the modelview matrix and a vertex then it sends you back a new vertex with the global position. Thanks

Share this post


Link to post
Share on other sites
Advertisement
The columns of the matrix are your local or "current" x/y/z axes and the origin. If you want to know the position, you just do:

position = x*column1 + y*column2 + z*column3 + column4

Of course, you can achieve exactly the same by doing

position = matrix * vector(x,y,z);

It's pretty much the whole point of the matrix to transform points from one coordinate system to another by multiplying them with it.

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.

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!