glTranslated()
how can i know the coordinates of an object after a glTranslated ?
please answer me :/
assuming u put all your tranformations in the Modelview matrix, the object coordinates are in the last column of that matrix:
GLdouble mvmatrix[16];
glGetDoublev( GL_MODELVIEW_MATRIX, mvmatrix );
This gives you:
(x,y,z) = (mvmatrix[12], mvmatrix[13], mvmatrix[14]);
But if there are no prior transformations to your glTranslated() call, then the position of the object is at the position u translated it to.
A word of advice, do your translations before your rotations.
GLdouble mvmatrix[16];
glGetDoublev( GL_MODELVIEW_MATRIX, mvmatrix );
This gives you:
(x,y,z) = (mvmatrix[12], mvmatrix[13], mvmatrix[14]);
But if there are no prior transformations to your glTranslated() call, then the position of the object is at the position u translated it to.
A word of advice, do your translations before your rotations.
The object position is always in the last column of the matrix, whatever the transformations applied to it.
I''d advise you to take a look at Steve Bakers'' "Matrices can be your friends" article (http://sjbaker.org/steve/omniv/matrices_can_be_your_friends.html) for a very light view on the subject, and "The Matrix and Quaternion FAQ" (http://www.j3d.org/matrix_faq/matrfaq_latest.html) for a more in depth approach.
I''d advise you to take a look at Steve Bakers'' "Matrices can be your friends" article (http://sjbaker.org/steve/omniv/matrices_can_be_your_friends.html) for a very light view on the subject, and "The Matrix and Quaternion FAQ" (http://www.j3d.org/matrix_faq/matrfaq_latest.html) for a more in depth approach.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement