# ModelView Matrix Question

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

## 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 on other sites
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.

1. 1
2. 2
Rutin
16
3. 3
4. 4
5. 5

• 26
• 11
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633709
• Total Posts
3013481
×