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


3 degrees of freedom (a better way?)

Recommended Posts

Keef    122
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