4

Suppose I have a point at (250,125,-20). After the following transformation,

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(100.0, 50.0, 0.0);
glRotatef(-25.0, 0.0, 1.0, 0.0);    

How can I get the value of current coordinates of that point? Need I write a subroutine to multiply a matrix to a vector? Are there any built-in solutions?

genpfault
  • 51,148
  • 11
  • 85
  • 139
Roun
  • 1,449
  • 1
  • 18
  • 25

1 Answers1

7

You can't get the coordinates for a specific vertex (point) after a transformation, however for this particular case you can get the ModelViewMatrix after the translate/rotate is applied.

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(100.0, 50.0, 0.0);
glRotatef(-25.0, 0.0, 1.0, 0.0);  

glGetFloatv(GL_MODELVIEW_MATRIX , *your_matrix*);
//print your matrix to check if that is the desired transformation coordinates

There is no magic tape in OpenGL, you will have to write your own framework e.g: for every objects in your world a class where you hold the vertices and what data you find relevant.

Hamed Rajabi Varamini
  • 3,439
  • 3
  • 24
  • 38
Cristina
  • 1,991
  • 3
  • 17
  • 24
  • Thank you! I've found a similar topic in [OpenGL FAQ](http://www.opengl.org/resources/faq/technical/transformations.htm#tran0120). It gives the same answer. – Roun Apr 08 '11 at 14:41