Finding True x,y,z after transforms.

Started by
2 comments, last by Lord_Evil 16 years, 10 months ago
Hello peeps, I am wondering, after a set of transforms (glRotatef, glTranslatef, etc), is there a standard way to ask what the 'true' {x,y,z} value you are working with is? I am asking because I have a known {x,y,z} camera location and wish to rotate a bitmap to orient based off the camera from an unknown location after a series of transforms (NeHe Tutorial 09 + gluLookAt). Any help would be appreicated, Nee.
Advertisement
If I remember correctly, if you know what transformations you did, then you can. You apply the inverse matrices of each of the transformations over your final matrix in the inverse order you applied the transforms.
Why can't you make use of glPushMatrix() glPopMatrix() pair ?
Best Regards,KumGame07
AFAIK you can't get the transformed positions of vertices you passed to OpenGL.

What you can do is get the current modelview matrix from OpenGL (glGet(GL_MODELVIEW_MATRIX, _16_component_float_array_for_the_matrix)). Then do the transform yourself (billboard.position * matrix) to get the transformed position.

If you don't use any scaling you could also read the billboard's center position relative to the camera directly from the modelviewmatrix (components 14, 24, 34). Since the modelview matrix basically transforms the world to camera space, every vector transformed by the modelview matrix is also in camera space.
If I was helpful, feel free to rate me up ;)If I wasn't and you feel to rate me down, please let me know why!

This topic is closed to new replies.

Advertisement