This topic is 4163 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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.

##### Share on other sites
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.

##### Share on other sites
Thanks for the prompt reply, it is much appreciated!

Quote:
 Original post by strtokglLoadMatrix 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. :)

##### Share on other sites
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}

1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633760
• Total Posts
3013722
×