How can I know a new position after transformation

BlitzMax Forums/OpenGL Module/How can I know a new position after transformation

Uncle(Posted 2010) [#1]
Hello,

If I have a polygon, and I make several transformations (scale, rotate and translate) is it possible to get the new positions of the vertexs of the polygon easily? Ive had a look around the internet but didn't see any solutions yet.


Cheers,


Unc


Noobody(Posted 2010) [#2]
If by "I make several transformations" you mean glRotation, glScale etc. with the matrix mode GL_MODELVIEW, then there's no straightforward way to get the transformed coordinates. The matrix is only applied in the transformation pipeline on the graphic card itself, meaning that the CPU has no direct access.

What you can do is get the modelview matrix (glGetDoublev/glGetFloatv( GL_MODELVIEW_MATRIX, VarPtr YourMatrixArray[ 0 ] )) and multiply the position vector of each vertex with the matrix. Depending on how many vertices there are and how often this procedure is executed, this can get time consuming (16 multiplications, 12 additions and 4 assignments per vertex, either float or double), but with a reasonable number of vertices there should be no problem.