Original Post
Hi,
I'm trying to get my head around Quaternions in Graphics, and I believe I understand the basic principles. Given that, I came up with the following piece of code to handle my rotations:
setRotation sets the rotation of the entity, and it requires euler co-ordinates to do so. In addition, I have a getRotation and a getQRotation method for use with the Camera. getQRotation returns the same rotation variable seen in this code-snippet.
For now I'm assuming that toEuler is doing the correct thing, and it's my maths that's off. The character rotates, but in a very "jerky" way, e.g. it just skips parts. When moving in a certain direction, it also moves much slower than moving in another direction, which is clearly wrong as well. As for the camera, I've written this:
This rotates correctly, but doesn't keep the same distance consistently. I'm quite sure that that's related to my 50.0, but at the same time wasn't quite sure how to handle the translation otherwise.
Thanks in advance for your help.
I'm trying to get my head around Quaternions in Graphics, and I believe I understand the basic principles. Given that, I came up with the following piece of code to handle my rotations:
quaternion newRot(0.0f, ANGLE * timeSinceLastUpdate, 0.0f);
rotation *= newRot;
rotation.toEuler(euler);
setRotation(euler * RADTODEG );
setRotation sets the rotation of the entity, and it requires euler co-ordinates to do so. In addition, I have a getRotation and a getQRotation method for use with the Camera. getQRotation returns the same rotation variable seen in this code-snippet.
For now I'm assuming that toEuler is doing the correct thing, and it's my maths that's off. The character rotates, but in a very "jerky" way, e.g. it just skips parts. When moving in a certain direction, it also moves much slower than moving in another direction, which is clearly wrong as well. As for the camera, I've written this:
setPosition( parent->getPosition()+parent->getQRotation() * vector3df(-50.0, 30.0, 0.0) );
This rotates correctly, but doesn't keep the same distance consistently. I'm quite sure that that's related to my 50.0, but at the same time wasn't quite sure how to handle the translation otherwise.
Thanks in advance for your help.