View Full Version : Camera Quaternion ?

02-21-2002, 08:10 PM
I'm creating a camera engine that's it own matrix. So If I want to move the camera Up and Down I will do that :

MatCamera[13] = MatCamera[13] - Movement;

Also, if I want to move to forward and backward :

MatCamera[12] = MatCamera[12] - Movement * CamLook.X;
MatCamera[14] = MatCamera[14] - Movement * CamLook.Z;

To update the camera :

glLoadMatrixf( MatCamera );

But now I got some problem when I need to rotate the camera. In other word, I need to modify some value into the MatCamera matrix to realize a rotation around an axis.
I know that Quaternion could be the best utility to proceed but HOW to use it ?

How can I extract the present X rotation inside the MatCamera matrix to modify it or increment it ? After this, I believe that I need to convert it to a Quaternion and an axis ? How can add this rotation to my MatCamera matrix ?

Thanks to help me...
I'm desperate...

PS :I just want to know if it's the right way to get the UP vector of the ModelView matrix

UpVect.X = MatCamera[1];
UpVect.Y = MatCamera[5];
UpVect.Z = MatCamera[9];

Concept of OpenGL matrix & my camera matrix :
[ 0 4 8 12 ]
[ 1 5 9 13 ]
[ 2 6 10 14 ]
[ 3 7 11 15 ]

02-22-2002, 06:03 AM
look at this:

forget quaternions and answer the question yourself

and btw there are a lot of tutorials on cameras
ever tried google or another search engine?