Not a bug, but it seems to me that matrix multiplication is left handed while quaternion is right handed.
Should we standardize it across different conventions?
For example: if I want to rotate a b3d anim mesh shoulder->elbow to an abs target position, I would do the below:
Irrlicht version: svn trunk from last obj file scale update.
1) Matrix method: (target is a target position)
Code: Select all
irr::scene::IBoneSceneNode *base = ((IAnimatedMeshSceneNode *)this->sceneNode)->getJointNode("Rshoulder");
irr::scene::IBoneSceneNode *endEffector = ((IAnimatedMeshSceneNode *)this->sceneNode)->getJointNode("Relbow");
vector3df p1 = endEffector->getAbsolutePosition() - base->getAbsolutePosition();
vector3df p2 = target - base->getAbsolutePosition();
matrix4 m1;
m1.buildRotateFromTo(p1, p2);
vector3df cAngle = base->getRotation();
matrix4 m2;
m2.setRotationDegrees(cAngle);
m2 = m1*m2; //Left handed multiplication
base->setRotation( m2.getRotationDegrees());
base->updateAbsolutePosition();
endEffector->updateAbsolutePositionOfAllChildren(); //or just call endEffector->updateAbsolutePosition()
Code: Select all
irr::scene::IBoneSceneNode *base = ((IAnimatedMeshSceneNode *)this->sceneNode)->getJointNode("Rshoulder");
irr::scene::IBoneSceneNode *endEffector = ((IAnimatedMeshSceneNode *)this->sceneNode)->getJointNode("Relbow");
vector3df p1 = endEffector->getAbsolutePosition() - base->getAbsolutePosition();
vector3df p2 = target - base->getAbsolutePosition();
quaternion q1;
q1.rotationFromTo(p1, p2);
quaternion q2;
q2.set(base->getRotation()*DEGTORAD);
q2 = q2*q1; //Right handed multiplication
vector3df anglexx = q2.getMatrix().getRotationDegrees();
base->setRotation(anglexx);
base->updateAbsolutePosition();
endEffector->updateAbsolutePositionOfAllChildren();
If my target flying in a circle. After one revolution the shoulder seems to twist a little. Is this due to floating point rounding error? Should I always reset the shoulder rotation to zero between calculations?
Thanks
thanh