   [resolved] How to use quaternion for plane-like camera ? (does anybody know?)
  Hello all,Sorry for my basic english :-/ I've read a lot of things about quaternions (in particular http://www.idevgames.com/forum/archive/index.php/t-4131.html) but I still have a problem with that :-( i'm sure that someone here can help me.I want to be able to move my camera like a plane (yaw, pitch, roll). I use quaternions, here is how I do :- I read user input (three angles, an angle for each axis)- I construct three quaternions (for yaw, pitch, roll) from thee three axes and the three angles- I multiply the current camera quaternion by the three rotations quaternions like this :static CQuaternion q;// construct the three rotations quaternionsq = q * qYaw * m_qPitch * m_qRoll;- I normalize the current camera quaternion and I convert it to a matrix for OpenGL- I extract the new local axes from the matrix for next rotationsI'd like to know if that is the good way to do...because it doesn't work at all for me :'( The rotations work independently, but when I combine them, the extracted axis are not good anymore.Could someone help me please? :S thanks...Olivier[Edited by - keo on May 26, 2006 3:11:26 AM]
  There are many free tutorials around the web that will show you how to use quaternions to make a camera. One good one that I have found is this, which shows you how to use quaternions to improve a camera class.It shouldn't really matter, but just in-case you use OpenGL instead you can download an OpenGL version here.These were both taken from a great programming site called UltimateGameProgramming.   ;Quote:Original post by ussnewjersey4There are many free tutorials around the web that will show you how to use quaternions to make a camera. One good one that I have found is this, which shows you how to use quaternions to improve a camera class.It shouldn't really matter, but just in-case you use OpenGL instead you can download an OpenGL version here.These were both taken from a great programming site called UltimateGameProgramming.@The OP: Be aware that many 'quaternion camera tutorials' don't implement the kind of motion you're asking about; in fact, most of these tutorials don't 'improve' anything by introducing quaternions into the equation.Anyway, what you have looks correct. The only things I would suggest are a) make sure you're not using degrees with C++ trig functions, and b) try reversing the order of the quaternion multiplication, i.e.:q = m_qRoll * m_qPitch * qYaw * q;This is a bit of a guess (since I don't know how exactly these quats are being constructed), but it might fix the problem.   ;  In fact, my code works very well with only 2 rotations in global axes (yaw, pitch), but in local axes (and with roll), it doesn't work :( I've tested all possible combinaisons for multiply quaternions.It is so difficult to have a plane style camera ?? :(;Quote:Original post by keoIn fact, my code works very well with only 2 rotations in global axes (yaw, pitch), but in local axes (and with roll), it doesn't work :( I've tested all possible combinaisons for multiply quaternions.It is so difficult to have a plane style camera ?? :(No, it's not so difficult, but it can sometimes be tricky to get all the little details right.From your posts, I'm not quite sure though what you mean by 'plane style camera'. This could mean 6DOF (you can turn and orient yourself in any direction, even upside down), or 'fixed up' (where no matter how you're oriented, you always yaw about the world up axis).What you have so far looks like 6DOF; maybe it doesn't seem to be working because that's not really what you want. As far as 6DOF goes though, some variation on what you have should work; you can do it with either local or global axes, but you have to have the multiplication in the right order.   ;Quote:Original post by jykNo, it's not so difficult, but it can sometimes be tricky to get all the little details right.From your posts, I'm not quite sure though what you mean by 'plane style camera'. This could mean 6DOF (you can turn and orient yourself in any direction, even upside down), or 'fixed up' (where no matter how you're oriented, you always yaw about the world up axis).What you have so far looks like 6DOF; maybe it doesn't seem to be working because that's not really what you want. As far as 6DOF goes though, some variation on what you have should work; you can do it with either local or global axes, but you have to have the multiplication in the right order.Thanks for your posts jyk and ussnewjersey4. Jyk, yep exactly, I would a 6DOF camera. I go to verify again all my mutiplications.;  My suspicion is that the problem is related to your use of Euler angles and not your use of quaternions.Here's a suggestion: Simplify your problem. Replace the quaternions with matrices and get the camera working. Once it is working, replace the matrices with quaternions.;  YEAH ! I found my mistake : i was extracting the wrong axes !! (from the matrix in OpenGL format, I was taking the axes by column, instead by line). Thanks everybody !!! ;-)   