The first step is to allow bones to move independently from the parent in the global reference frame, so I can attach each of them to a PhysX-actor.
For applying transformations from PhysX-actors to Irrlicht-nodes I call this on every frame:
- cpp Code: Select all
void applyPose (const PxRigidActor *fromPx, ISceneNode *toIrr)
PxTransform posePx = fromPx->getGlobalPose();
matrix4 matIrr = quaternion(posePx.q.x,posePx.q.y,posePx.q.z,posePx.q.w).makeInverse().getMatrix();
if (toIrr->getParent() != gScene->getRootSceneNode())// this would work with rootSceneNode as parent as well
matIrr = pTrans*matIrr;
vector3df rot = matIrr.getRotationDegrees();
... and it seems to work fine with nodes I manually "parented" - they move with their attached actor like they don't have a parent-node at all.
When I try the same with BoneSceneNodes I get weird behaviour and Axes don't seem to match, even though the whole .x-mesh orientation is as it should be. I set JointMode to EJUOR_CONTROL, but bones don't really move independently. I can't help thinking the problem is somehow related to the armature (and maybe the way I aligned it before export?...), but I don't know what to do... Any help?