Actually I have a airplane/ship flying.
Everything (for example movement following ship's direction) works ...except rotation.
I've tried:
irr::core::vector3df rotation_init; // <- the actual rotation of node with this code:
rotation_init = node.getRotation();
//rotation.X,Y,Z are the rotation of the node at the end
rotation.Y = rotation_init.Y + diffY; // YAW AXIS
rotation.Z = rotation_init.Z + diffZ; // PITCH AXIS
rotation.X = rotation_init.X + diffX; // ROLL AXIS
But not works, exactly works for the Y-axis (Yaw) around rotation, and X-axis (Roll) around rotation... but
Z Rotation (Pitching) work only if Roll Axis is parallel to Global X axis.
If Roll Axis is parallel to Global Z axis, the Z Rotation instead of Pitching, it Rolls too! And i don't understand why...
So i've tried a "solution" code (found in a thread in forum http://irrlicht.sourceforge.net/forum/v ... php?t=4680) about turn roll and pitch:
But not works! When rotating the ship around Y axis (or around Yaw Axis), it makes strange things like rotation around other axisvoid rotate(irr::scene::ISceneNode *node, irr::core::vector3df rot) //rot = the rotation to add
{
irr::core::matrix4 m;
m.setRotationDegrees(node->getRotation());
irr::core::matrix4 n;
n.setRotationDegrees(rot);
m *= n;
node->setRotation( m.getRotationDegrees() );
}
So actually my code (the first one) is the better working except for that error. Like the graphic engine use global axis instead of considering rotation around object's axis.
Any idea?
-----------------
EDIT: The solution is:
Create an EmptySceneNode for each rotation, then parent them in the order you want to rotate. For example:
1-Yaw
2-Pitch
3-Roll
So the roll effect doesn't influence the other 2, and we use the first 2 like "spherical coordinates" or Elevation/Rotation.. and third, Roll, effect only himself.