Jump to content
Posted 23 June 2012 - 01:50 AM
Posted 23 June 2012 - 05:53 AM
I gets all your texture budgets!
Posted 23 June 2012 - 06:16 AM
he main point you should take note (in the while loop) is
- The orientation of the camera is a quaternion.
- There are 3 angles corresponding to the keypress. Note the angles are meant to be an on/off switch (not accumulative). I reset them inside the while loop. Of course this is not the best way to do it but as I said, it is a quick job.
- I convert the 3 angles to a temporary quaternion.
- I multiply the temporary quaternion to the camera quaternion to obtain the combined orientation. Note the order of multiplication.
- The camera rotation is then converted to the Axis Angle representation for transforming the final matrix.
When a key is pressed, I generate a temporary quaternion corresponding to the key for a small rotation in that particular axis. I then multiply the temporary quaternion into the camera quaternion. This concatenation of rotations in 4D space will avoid gimbal lock. Try it and see for yourself.
Posted 23 June 2012 - 07:16 AM
That's the key to avoiding gimbal lock. You need to have some representation of the current attitude and modify it with incremental rotations around the axes. Whether you use quaternions or some other representation is secondary.
I multiply the temporary quaternion to the camera quaternion to obtain the combined orientation.
Posted 23 June 2012 - 10:37 AM