3 degrees of freedom (a better way?)
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);
-----------------------Current Project: The Chromatic Game Engine
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement