Archived

This topic is now archived and is closed to further replies.

3 degrees of freedom (a better way?)

This topic is 5826 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 all, I''m looking for a more elegant way of getting full 3 degrees of freedom working (ie so the camera can pitch,yaw,roll and the player can move forward/back, left/right and up/down relative to the direction the camera is looking). Here''s how I currently do it: The camera object stores its own copy of the model view matrix (and its inverse) The camera object also stores the rotation and translation components of these matrices. To move the view relative to the current camera angle, I take the vector that represents the translation and multiply it by the inverse of the camera rotation matrix - this aligns it with the orientation of the camera. I then take the x,y and z components of this vector and use them to update the translation matrix. rotating the view is much easier, just apply the rotation to the rotation component matrix (and update the inverse at the same time) Each time the view is updated the model view matrix inside the camera object is calculated from the rotation and translation components. To set up the view I use glLoadMatrix() to replace the Model View matrix with the one stored in the camera object. This works, and is fairly cheap (3 or 4 matrix operations each time the view shifts), but I''m sure I''m doing things the hard way - what is ''best practice'' for this? Cheers Keef ----------------------- glDisable(WORK); glEnable(GL_CODING);

Share this post


Link to post
Share on other sites