Jump to content
  • Advertisement
Sign in to follow this  
0v3rloader

OpenGL Loading transformation matrix directly

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

If you intended to correct an error in the post then please contact us.

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 this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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. :)

Share this post


Link to post
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 matrix

for each object to render
{
glPushMatrix(); //save view matrix
glMultMatrix(objectWorldTransform); //create modelview
glPopMatrix(); //restore view matrix
}

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!