0

My question is:

Is there a way to retrieve the coordinates of a vertex after translations or rotation?

Example: x = 10, y = 10, z = 0

After a series of calls to glTranslate or glRotate how can I know the actual status of x, y and z?

Thanks.

Perception
  • 79,279
  • 19
  • 185
  • 195
James
  • 5
  • 2
  • possible duplicate of [openGL: get coordinates after a glrotate](http://stackoverflow.com/questions/10543554/opengl-get-coordinates-after-a-glrotate) – CharlesB May 22 '12 at 11:33

1 Answers1

4

this is not possible... opengl sends your vertex data to the GPU and only on GPU you can get them after the transformation.

to get transformed vertices you have to multiply them by the matrix on your own

for each vertex:
   vertex_transformed = matrix * vertex

in old OpenGL:

glGetFloatv(GL_MODELVIEW_MATRIX, m);
x = pos.x*m[0] + pos.y*m[4] + pos.z*m[8] + m[12];
y = pos.x*m[1] + pos.y*m[5] + pos.z*m[9] + m[13];
z = pos.x*m[2] + pos.y*m[6] + pos.z*m[10] + m[14];

some more advanced ways is to use transform feedback and store those transformed vertices into a buffer (but still this buffer will be stored on the GPU).

fen
  • 9,835
  • 5
  • 34
  • 57
  • ok but.. how can i retrieve the matrix, after transformations, using a gl method? and.. what is the math for multiply a matrix (float[16]) and a Vertex? ... for the transform feedback, how can i create this buffer to store progress? – James May 21 '12 at 17:59
  • no problem :) Transform feedback is a bit more advanced... I need some more experience with this, so I cannot explain it to you right now. – fen May 21 '12 at 20:17