I'am new to Irrlicht and i'm trying to solve a node rotation issue for about a week.
I searched through the forum and found explanations about the "gimbal lock" problem and a way to avoid it using quaternions.
so, i wrote the following function which works fine except when a node is previously rotated -90.0 degrees on the Y axis (then, Z axis rotations are locked).
I think I misunderstood something about the gimbal lock and/or the use of quaternions to avoid it... or maybe I just did something wrong with my code.
Code: Select all
void QRotate(ISceneNode* node, float angle, vector3df axis) // Quaternion Rotation
{
quaternion quat_rot, quat_old;
quat_rot.fromAngleAxis(angle*DEGTORAD, axis);
quat_old.set(node->getRotation()*DEGTORAD);
quat_rot*=quat_old;
quat_rot.normalize();
node->setRotation (quat_rot.getMatrix().getRotationDegrees());
}
Thanks in advance.