Finding True x,y,z after transforms.
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.
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.
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.
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement