Jump to content
  • Advertisement
Sign in to follow this  
felipedrl

camera and object manipulation not working[SOLVED]

This topic is 3606 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, I want to move my camera independent of my objects. I've designed both camera and objects to store its position and orientation ( I'm aware I can implement a scene graph where a node would handle that. I'm working towards it, for just just want to get that right. ) When I position my camera and set its orientation and try to move and rotates objects they don't do it in their local system. The camera render method works like this:
glPushAttrib(GL_TRANSFORM_BIT);
        glMatrixMode( GL_MODELVIEW );
        GLfloat viewMatrix[16];
        orientation.quatToMatrix( viewMatrix );
        glLoadMatrixf( viewMatrix );
        glTranslatef( -pos.x, -pos.y, -pos.z );
glPopAttrib();


I call camera.render() before rendering anything in the scene. And them I call each object render which is pretty similar to camera's method but it saves the matrixes.
glPushAttrib(GL_TRANSFORM_BIT);
        glMatrixMode( GL_MODELVIEW );
        glPushMatrix();
         GLfloat viewMatrix[16];
         orientation.quatToMatrix( viewMatrix );
         glMultMatrixf( viewMatrix );
         glTranslatef( pos.x, pos.y, pos.z );
        glPopMatrix();
glPopAttrib();


This is not working. I know why but I don't know how to fix it. What I can say is that I apply a rotation a translation in camera, and later on I apply a rotation and translation for each object. I if could find a way to apply all rotations first and then apply translation that might do it. But again, I don't know how to do that. Should I store modelview and projection matrixes in those classes? Any insights? Thanks in advance. [Edited by - felipedrl on December 1, 2008 11:14:59 AM]

Share this post


Link to post
Share on other sites
Advertisement
Yeah, I'm inverting rotations too. I find out today that I must convert everything to the camera coordinate sys by inverting the object matrices. It's working now, thanks for the reply.

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!