Loading transformation matrix directly

Started by
2 comments, last by Lord_Evil 16 years, 8 months ago
Hi there, I am generating transform 4x4 matrices for different 3d models and would like to load them directly into OpenGL so as to avoid having to call the glTranslatef and glRotatef set of functions. How can this be accomplished assuming the matrices specify the object's position from the origin (0,0,0) and rotation? Will calling glLoadMatrixf suffice, after setting glMatrixMode to GL_MODELVIEW? Thank you. PS: I'm asking this question, as I'm unable to test it out by myself at the moment.
Advertisement
glLoadMatrix will replace the current matrix completely. Assuming your matrix contains ALL of the transformations you're interested in performing, it shouldn't be a problem.
Thanks for the prompt reply, it is much appreciated!

Quote:Original post by strtok
glLoadMatrix will replace the current matrix completely. Assuming your matrix contains ALL of the transformations you're interested in performing, it shouldn't be a problem.


By "all the transformations" do you mean translation from point of origin plus rotation on local axes (and no scaling in my case)? Sorry for the emphasis but I only want to be sure. :)
I think strtok means that your matrix will need to include all the translations from object space to world space (translations, rotations, scaling (OK, you said you don't scale)) AND the transformations to eye space.

Keep in mind that the modelview matrix contains the model transformations as well as the view transformations. So unless you don't assume that the camera is in its default position and orientation you need the camera's view transformations as well.

I therefore do the following per frame/camera:

glLoadMatrix(cameraMatrix); //load view matrixfor each object to render{  glPushMatrix(); //save view matrix  glMultMatrix(objectWorldTransform); //create modelview  glPopMatrix(); //restore view matrix}
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