Page 1 of 1

Rotation on X occurs on Z

Posted: Tue Feb 02, 2021 9:52 am
by azerty69
Hello community,

I'm encountering a strange problem. I want to rotate my model on X and the rotation
occurs on Z. I use Irrlicht 1.8.4 and the OpenGL driver. Rotations on Y and Z are working perfectly.

(...)

rotation.X += ...

(...)

// Apply new values to the ship.
shipNode->setPosition(position);
shipNode->setRotation(rotation);

I hope someone can help,
azerty69

Re: Rotation on X occurs on Z

Posted: Tue Feb 02, 2021 10:19 pm
by CuteAlien
Maybe not enough information. But basically full 6 degrees of freedom with euler angles can be tricky. If you just go on adding rotations to all axes the result is often now what you expect. Stuff like gimbal lock and one axis suddenly meaning something different happening.

What you want in this case is usually rotations added to the current local orientation (not to global axes). I posted some rotateAxesXYZToEuler function once in the past which might work for you here: http://irrlicht.sourceforge.net/forum/v ... =4&t=52136

edit: But no guarantee it really works... I realized when reading that old thread that I didn't really test this for the 6-dof use-case. I should probably do that :-(

Re: Rotation on X occurs on Z

Posted: Sat Feb 06, 2021 9:36 am
by azerty69
Hello CuteAlien,

Thank you for your reply. I've found where my problem was coming from.
At initialization, I was rotating my model of 90 degrees on Y to obtain a good
orientation. I've modified the orientation of the model with Blender and removed
the following lines from my init code:

rotation = vector3df(0.f, 90.f, 0.f);
shipNode->setRotation(rotation);

Now, the ship reacts correctly.

Thank you again for your reply,
azerty69