Jump to content
  • Advertisement
Sign in to follow this  

understanding modelview for a camera

This topic is 4414 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

Hello, im really trying to grasp on how a camera really works in opengl with respect to the viewing transform. In order to udnerstand this, i dont want to use gllookat, and for my perspective matrix im using glFrustum. Im essentially doing all rotations and trnaslations with matrix mutliplication, i don't want to shortchange myself with opengl utility functions. Lets say i have an object , i draw it by saying drawObject(); this box roates and translates, and i want to make a camera that translates with the box but doesnt rotate with it. My first question is, do i have camera matrix, object oreientation matrix, and a viewing matrix to load into the modelview? so lets one matrix is a translation matrix with the 1st row and fourth column have an arbitrary unit ( this is a translation along the x axis.) so from what i think, this is how i would implement this,psuedocode camera matrix = cameraM object oreientation matrix = objectM translation matrix = tranM viewing matrix = viewing M

Keybaord handler{
         case 'x':
                    tranM[0][3] = .01; //translating matrix set
                    objectM = objectM * tranM;      //translating object
                    tranM[0][3] = - .01;
                    cameraM = tranM * cameraM;         //translating camera
function drawandmovestuff()
    viewing = objectM * cameraM;     //im not getting the inverse of this
                                     //since i applied the inverse translation                                  
is this the correct way to translate hte camera with the object?

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!