Ok..
But yesterday I found ragdoll example by "stoneyjones".
It's about skinned ragdoll in Irrlicht. It works great.
so...
Code: Select all
//PhysxObjects for body
IPhysxObject* CPhysxManager::createCapsuleObject1(NxReal height, NxReal radius, core::vector3df position)
{
if (!Scene) return NULL;
NxVec3 pos(position.X, position.Y, position.Z);
NxBodyDesc BodyDesc;
BodyDesc.angularDamping = 1.5f;
NxCapsuleShapeDesc CapDesc;
CapDesc.height = height-(radius*2);
CapDesc.radius = radius;
CapDesc.localPose.t = NxVec3(0, 0.5f * height, 0);
NxActorDesc CapActorDesc;
CapActorDesc.shapes.pushBack(&CapDesc);
CapActorDesc.body = &BodyDesc;
CapActorDesc.density = 200.0f; // you can change density to make it more "floppy" (lighter)
CapActorDesc.globalPose.t = pos;
NxActor* capsule = Scene->createActor(CapActorDesc);
return createPhysxObject(capsule, EOT_CAPSULE);
}
IPhysxObject* CPhysxManager::createBoxObject1(NxReal dx, NxReal dy, NxReal dz, core::vector3df position)
{
if (!Scene) return NULL;
NxVec3 pos(position.X, position.Y, position.Z);
NxBodyDesc bodyDesc;
bodyDesc.angularDamping = 1.5f;
NxBoxShapeDesc boxDesc;
boxDesc.dimensions.set(dx*0.5f, dy*0.5f, dz*0.5f);
boxDesc.localPose.t = NxVec3(0, 0.5f*dy, 0);
NxActorDesc actorDesc;
actorDesc.shapes.pushBack(&boxDesc);
actorDesc.body = &bodyDesc;
actorDesc.density = 350.0; // you can set up a variable for density. i just did this for this demo.
actorDesc.globalPose.t = pos;
NxActor* box = Scene->createActor(actorDesc);
return createPhysxObject(box, EOT_BOX);
}
.........
class PhysxRagdoll
{
public:
struct boneSet
{
IBoneSceneNode* iBone;
f32 length;
SPhysxAndNodePair * actor;
};
boneSet head, torso, pelvis, pelvisRight, pelvisLeft, leftThigh, rightThigh, leftCalf, rightCalf;
boneSet leftCollar, rightCollar, rightUpperArm, leftUpperArm, leftForeArm, rightForeArm, leftHand, rightHand;
vector3df ragPosition;
NxSphericalJoint* neck;
NxFixedJoint* upperLeftShoulder;
NxFixedJoint* upperRightShoulder;
NxSphericalJoint* leftShoulder;
NxSphericalJoint* rightShoulder;
NxRevoluteJoint* spine;
NxFixedJoint* leftHip;
NxFixedJoint* rightHip;
NxSphericalJoint* leftHipLow;
NxSphericalJoint* rightHipLow;
NxRevoluteJoint* leftElbow;
NxRevoluteJoint* rightElbow;
NxRevoluteJoint* leftWrist;
NxRevoluteJoint* rightWrist;
NxRevoluteJoint* leftKnee;
NxRevoluteJoint* rightKnee;
NxJoint* leftAnkle;
NxJoint* rightAnkle;
IPhysxManager* physx;
PhysxRagdoll(array<SPhysxAndNodePair*>& Nodes, IPhysxManager* phx, IAnimatedMeshSceneNode* irrnode, vector3df position=vector3df(0,0,0))
: physx(phx)
{
ragPosition = position;
irrnode->setJointMode(EJUOR_READ);
head.iBone = irrnode->getJointNode("head");
torso.iBone = irrnode->getJointNode("torso");
pelvis.iBone = irrnode->getJointNode("pelvis");
pelvisRight.iBone = irrnode->getJointNode("pelvisright");
pelvisLeft.iBone = irrnode->getJointNode("pelvisleft");
leftCollar.iBone = irrnode->getJointNode("leftCollar");
rightCollar.iBone = irrnode->getJointNode("rightCollar");
leftUpperArm.iBone = irrnode->getJointNode("leftUpperArm");
rightUpperArm.iBone = irrnode->getJointNode("rightUpperArm");
leftForeArm.iBone = irrnode->getJointNode("leftForeArm");
rightForeArm.iBone = irrnode->getJointNode("rightForeArm");
leftHand.iBone = irrnode->getJointNode("leftHand");
rightHand.iBone = irrnode->getJointNode("rightHand");
leftThigh.iBone = irrnode->getJointNode("leftThigh");
rightThigh.iBone = irrnode->getJointNode("rightThigh");
leftCalf.iBone = irrnode->getJointNode("leftCalf");
rightCalf.iBone = irrnode->getJointNode("rightCalf");
// leftFoot;
// rightFoot;
irrnode->addChild(pelvis.iBone);
pelvis.iBone->addChild(torso.iBone);
pelvis.iBone->addChild(pelvisLeft.iBone);
pelvis.iBone->addChild(pelvisRight.iBone);
torso.iBone->addChild(head.iBone);
torso.iBone->addChild(leftCollar.iBone);
torso.iBone->addChild(rightCollar.iBone);
leftCollar.iBone->addChild(leftUpperArm.iBone);
rightCollar.iBone->addChild(rightUpperArm.iBone);
leftUpperArm.iBone->addChild(leftForeArm.iBone);
rightUpperArm.iBone->addChild(rightForeArm.iBone);
leftForeArm.iBone->addChild(leftHand.iBone);
rightForeArm.iBone->addChild(rightHand.iBone);
pelvisRight.iBone->addChild(rightThigh.iBone);
pelvisLeft.iBone->addChild(leftThigh.iBone);
rightThigh.iBone->addChild(rightCalf.iBone);
leftThigh.iBone->addChild(leftCalf.iBone);
pelvis.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
torso.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
head.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
pelvisRight.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
pelvisLeft.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
leftThigh.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
rightThigh.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
leftCalf.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
rightCalf.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
leftCollar.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
rightCollar.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
leftUpperArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
rightUpperArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
leftForeArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
rightForeArm.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
leftHand.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
rightHand.iBone->setSkinningSpace(irr::scene::EBSS_GLOBAL);
irrnode->setJointMode(scene::EJUOR_CONTROL);
updateFamily(irrnode);
line3d<f32> bLine;
bLine.start = pelvis.iBone->getAbsolutePosition();
bLine.end = torso.iBone->getAbsolutePosition();
pelvis.length = bLine.getLength();
bLine.start = torso.iBone->getAbsolutePosition();
bLine.end = head.iBone->getAbsolutePosition();
torso.length = bLine.getLength();
bLine.start = pelvisRight.iBone->getAbsolutePosition();
bLine.end = rightThigh.iBone->getAbsolutePosition();
pelvisRight.length = bLine.getLength();
bLine.start = pelvisLeft.iBone->getAbsolutePosition();
bLine.end = leftThigh.iBone->getAbsolutePosition();
pelvisLeft.length = bLine.getLength();
bLine.start = rightThigh.iBone->getAbsolutePosition();
bLine.end = rightCalf.iBone->getAbsolutePosition();
rightThigh.length = bLine.getLength();
bLine.start = leftThigh.iBone->getAbsolutePosition();
bLine.end = leftCalf.iBone->getAbsolutePosition();
leftThigh.length = bLine.getLength();
bLine.start = leftCollar.iBone->getAbsolutePosition();
bLine.end = leftUpperArm.iBone->getAbsolutePosition();
leftCollar.length = bLine.getLength();
bLine.start = rightCollar.iBone->getAbsolutePosition();
bLine.end = rightUpperArm.iBone->getAbsolutePosition();
rightCollar.length = bLine.getLength();
bLine.start = leftUpperArm.iBone->getAbsolutePosition();
bLine.end = leftForeArm.iBone->getAbsolutePosition();
leftUpperArm.length = bLine.getLength();
bLine.start = rightUpperArm.iBone->getAbsolutePosition();
bLine.end = rightForeArm.iBone->getAbsolutePosition();
rightUpperArm.length = bLine.getLength();
bLine.start = leftForeArm.iBone->getAbsolutePosition();
bLine.end = leftHand.iBone->getAbsolutePosition();
leftForeArm.length = bLine.getLength();
bLine.start = rightForeArm.iBone->getAbsolutePosition();
bLine.end = rightHand.iBone->getAbsolutePosition();
rightForeArm.length = bLine.getLength();
head.length = 14;
leftHand.length = 8;
rightHand.length = 8;
leftCalf.length = 30;
rightCalf.length = 30;
NxScene * pscene = physx->getScene();
pelvis.actor = new SPhysxAndNodePair;
pelvis.actor->PhysxObject = physx->createCapsuleObject1(pelvis.length, 2, pelvis.iBone->getAbsolutePosition());
pelvis.actor->SceneNode = pelvis.iBone;
pelvis.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(pelvis.iBone->getAbsoluteTransformation().getRotationDegrees()));
torso.actor = new SPhysxAndNodePair;
torso.actor->PhysxObject = physx->createBoxObject1(24, torso.length, 8, torso.iBone->getAbsolutePosition());
torso.actor->SceneNode = torso.iBone;
torso.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(torso.iBone->getAbsoluteTransformation().getRotationDegrees()));
head.actor = new SPhysxAndNodePair;
head.actor->PhysxObject = physx->createCapsuleObject1(head.length, 5, head.iBone->getAbsolutePosition());
head.actor->SceneNode = head.iBone;
head.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(head.iBone->getAbsoluteTransformation().getRotationDegrees()));
pelvisRight.actor = new SPhysxAndNodePair;
pelvisRight.actor->PhysxObject = physx->createCapsuleObject1(pelvisRight.length, 2, pelvisRight.iBone->getAbsolutePosition());
pelvisRight.actor->SceneNode = pelvisRight.iBone;
pelvisRight.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(pelvisRight.iBone->getAbsoluteTransformation().getRotationDegrees()));
pelvisLeft.actor = new SPhysxAndNodePair;
pelvisLeft.actor->PhysxObject = physx->createCapsuleObject1(pelvisLeft.length, 2, pelvisLeft.iBone->getAbsolutePosition());
pelvisLeft.actor->SceneNode = pelvisLeft.iBone;
pelvisLeft.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(pelvisLeft.iBone->getAbsoluteTransformation().getRotationDegrees()));
leftCollar.actor = new SPhysxAndNodePair;
leftCollar.actor->PhysxObject = physx->createCapsuleObject1(leftCollar.length, 2, leftCollar.iBone->getAbsolutePosition());
leftCollar.actor->SceneNode = leftCollar.iBone;
leftCollar.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftCollar.iBone->getAbsoluteTransformation().getRotationDegrees()));
rightCollar.actor = new SPhysxAndNodePair;
rightCollar.actor->PhysxObject = physx->createCapsuleObject1(rightCollar.length, 2, rightCollar.iBone->getAbsolutePosition());
rightCollar.actor->SceneNode = rightCollar.iBone;
rightCollar.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightCollar.iBone->getAbsoluteTransformation().getRotationDegrees()));
leftUpperArm.actor = new SPhysxAndNodePair;
leftUpperArm.actor->PhysxObject = physx->createCapsuleObject1(leftUpperArm.length, 4, leftUpperArm.iBone->getAbsolutePosition());
leftUpperArm.actor->SceneNode = leftUpperArm.iBone;
leftUpperArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftUpperArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
leftForeArm.actor = new SPhysxAndNodePair;
leftForeArm.actor->PhysxObject = physx->createCapsuleObject1(leftForeArm.length, 3, leftForeArm.iBone->getAbsolutePosition());
leftForeArm.actor->SceneNode = leftForeArm.iBone;
leftForeArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftForeArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
leftHand.actor = new SPhysxAndNodePair;
leftHand.actor->PhysxObject = physx->createCapsuleObject1(leftHand.length, 2, leftHand.iBone->getAbsolutePosition());
leftHand.actor->SceneNode = leftHand.iBone;
leftHand.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftHand.iBone->getAbsoluteTransformation().getRotationDegrees()));
rightUpperArm.actor = new SPhysxAndNodePair;
rightUpperArm.actor->PhysxObject = physx->createCapsuleObject1(rightUpperArm.length, 4, rightUpperArm.iBone->getAbsolutePosition());
rightUpperArm.actor->SceneNode = rightUpperArm.iBone;
rightUpperArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightUpperArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
rightForeArm.actor = new SPhysxAndNodePair;
rightForeArm.actor->PhysxObject = physx->createCapsuleObject1(rightForeArm.length, 3, rightForeArm.iBone->getAbsolutePosition());
rightForeArm.actor->SceneNode = rightForeArm.iBone;
rightForeArm.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightForeArm.iBone->getAbsoluteTransformation().getRotationDegrees()));
rightHand.actor = new SPhysxAndNodePair;
rightHand.actor->PhysxObject = physx->createCapsuleObject1(rightHand.length, 2, rightHand.iBone->getAbsolutePosition());
rightHand.actor->SceneNode = rightHand.iBone;
rightHand.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightHand.iBone->getAbsoluteTransformation().getRotationDegrees()));
leftThigh.actor = new SPhysxAndNodePair;
leftThigh.actor->PhysxObject = physx->createCapsuleObject1(leftThigh.length, 6, leftThigh.iBone->getAbsolutePosition());
leftThigh.actor->SceneNode = leftThigh.iBone;
leftThigh.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftThigh.iBone->getAbsoluteTransformation().getRotationDegrees()));
leftCalf.actor = new SPhysxAndNodePair;
leftCalf.actor->PhysxObject = physx->createCapsuleObject1(leftCalf.length, 4, leftCalf.iBone->getAbsolutePosition());
leftCalf.actor->SceneNode = leftCalf.iBone;
leftCalf.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(leftCalf.iBone->getAbsoluteTransformation().getRotationDegrees()));
//// leftFoot = CreateBox(NxVec3(0.6,1.5,0.2), NxVec3(0.4,0.2,0.75), 10);
//// leftFoot->setGlobalOrientationQuat(qRotAround);
rightThigh.actor = new SPhysxAndNodePair;
rightThigh.actor->PhysxObject = physx->createCapsuleObject1(rightThigh.length, 6, rightThigh.iBone->getAbsolutePosition());
rightThigh.actor->SceneNode = rightThigh.iBone;
rightThigh.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightThigh.iBone->getAbsoluteTransformation().getRotationDegrees()));
rightCalf.actor = new SPhysxAndNodePair;
rightCalf.actor->PhysxObject = physx->createCapsuleObject1(rightCalf.length, 4, rightCalf.iBone->getAbsolutePosition());
rightCalf.actor->SceneNode = rightCalf.iBone;
rightCalf.actor->PhysxObject->getActor()->setGlobalOrientation(getMat33Rot(rightCalf.iBone->getAbsoluteTransformation().getRotationDegrees()));
//// rightFoot = CreateBox(NxVec3(-0.6,1.5,0.2), NxVec3(0.4,0.2,0.75), 10);
//// rightFoot->setGlobalOrientationQuat(qRotAround);
//// These flags are supposed to keep certain actors from colliding with others
pscene->setActorPairFlags(*pelvisLeft.actor->PhysxObject->getActor(), *pelvisRight.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
pscene->setActorPairFlags(*pelvis.actor->PhysxObject->getActor(), *pelvisRight.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
pscene->setActorPairFlags(*pelvis.actor->PhysxObject->getActor(), *pelvisLeft.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
pscene->setActorPairFlags(*leftCollar.actor->PhysxObject->getActor(), *rightCollar.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
pscene->setActorPairFlags(*leftCollar.actor->PhysxObject->getActor(), *torso.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
pscene->setActorPairFlags(*rightCollar.actor->PhysxObject->getActor(), *torso.actor->PhysxObject->getActor(), NX_IGNORE_PAIR);
neck = CreateBodySphericalJoint(pscene, head.actor->PhysxObject->getActor(), torso.actor->PhysxObject->getActor(), head.iBone->getAbsolutePosition(), vector3df(0,1,0));
spine = CreateBodyRevoluteJoint(pscene, pelvis.actor->PhysxObject->getActor(), torso.actor->PhysxObject->getActor(), torso.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.01 * NxPi), NxReal(0.01 * NxPi));
//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), leftCollar.actor->PhysxObject->getActor(), leftCollar.iBone->getAbsolutePosition(), vector3df(0,1,0));
//upperLeftShoulder = CreateBodyFixedJoint(pscene, head.actor->PhysxObject->getActor(), rightCollar.actor->PhysxObject->getActor(), rightCollar.iBone->getAbsolutePosition(), vector3df(0,1,0));
leftShoulder = CreateBodySphericalJoint(pscene, leftCollar.actor->PhysxObject->getActor(), leftUpperArm.actor->PhysxObject->getActor(), leftUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0));
rightShoulder = CreateBodySphericalJoint(pscene, rightCollar.actor->PhysxObject->getActor(), rightUpperArm.actor->PhysxObject->getActor(), rightUpperArm.iBone->getAbsolutePosition(), vector3df(0,1,0));
leftHip = CreateBodyFixedJoint(pscene, torso.actor->PhysxObject->getActor(), pelvisLeft.actor->PhysxObject->getActor(), torso.iBone->getAbsolutePosition(), vector3df(0,1,0));
rightHip = CreateBodyFixedJoint(pscene, torso.actor->PhysxObject->getActor(), pelvisRight.actor->PhysxObject->getActor(), torso.iBone->getAbsolutePosition(), vector3df(0,1,0));
leftHipLow = CreateBodySphericalJoint(pscene, pelvisLeft.actor->PhysxObject->getActor(), leftThigh.actor->PhysxObject->getActor(), leftThigh.iBone->getAbsolutePosition(), vector3df(0,1,0));
rightHipLow = CreateBodySphericalJoint(pscene, pelvisRight.actor->PhysxObject->getActor(), rightThigh.actor->PhysxObject->getActor(), rightThigh.iBone->getAbsolutePosition(), vector3df(0,1,0));
leftElbow = CreateBodyRevoluteJoint(pscene, leftUpperArm.actor->PhysxObject->getActor(), leftForeArm.actor->PhysxObject->getActor(), leftForeArm.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.9*NxPi));
rightElbow = CreateBodyRevoluteJoint(pscene, rightUpperArm.actor->PhysxObject->getActor(), rightForeArm.actor->PhysxObject->getActor(), rightForeArm.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.9*NxPi));
leftWrist = CreateBodyRevoluteJoint(pscene, leftHand.actor->PhysxObject->getActor(), leftForeArm.actor->PhysxObject->getActor(), leftHand.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.5*NxPi));
rightWrist = CreateBodyRevoluteJoint(pscene, rightHand.actor->PhysxObject->getActor(), rightForeArm.actor->PhysxObject->getActor(), rightHand.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(-0.5*NxPi), NxReal(0.5*NxPi));
leftKnee = CreateBodyRevoluteJoint(pscene, leftThigh.actor->PhysxObject->getActor(), leftCalf.actor->PhysxObject->getActor(), leftCalf.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(0*NxPi), NxReal(0.85*NxPi));
rightKnee = CreateBodyRevoluteJoint(pscene, rightThigh.actor->PhysxObject->getActor(), rightCalf.actor->PhysxObject->getActor(), rightCalf.iBone->getAbsolutePosition(), vector3df(1,0,0), NxReal(0*NxPi), NxReal(0.85*NxPi));
// NxRevoluteJointDesc jointDesc;
// jointDesc.flags |= NxRevoluteJointFlag::NX_RJF_LIMIT_ENABLEDNX_SJF_SWING_LIMIT_ENABLED; //|=
// jointDesc.swingLimit.value = NxReal(0.2*NxPi);
// jointDesc.flags |= NX_SJF_TWIST_LIMIT_ENABLED;
// jointDesc.twistLimit.low.value = NxReal(-0.04*NxPi);
// jointDesc.twistLimit.high.value = NxReal(0.04*NxPi);
//leftAnkle = CreateRevoluteJoint(leftFoot,leftCalf,NxVec3(0.6,1.3,0),NxVec3(1,0,0));
//rightAnkle = CreateRevoluteJoint(rightFoot,rightCalf,NxVec3(-0.6,1.3,0),NxVec3(-1,0,0));
Nodes.push_back(pelvis.actor);
Nodes.push_back(torso.actor);
Nodes.push_back(head.actor);
Nodes.push_back(pelvisRight.actor);
Nodes.push_back(pelvisLeft.actor);
Nodes.push_back(leftThigh.actor);
Nodes.push_back(rightThigh.actor);
Nodes.push_back(leftCalf.actor);
Nodes.push_back(rightCalf.actor);
Nodes.push_back(leftCollar.actor);
Nodes.push_back(rightCollar.actor);
Nodes.push_back(leftUpperArm.actor);
Nodes.push_back(rightUpperArm.actor);
Nodes.push_back(leftForeArm.actor);
Nodes.push_back(rightForeArm.actor);
Nodes.push_back(leftHand.actor);
Nodes.push_back(rightHand.actor);
}
void updateFamily(ISceneNode* Node)
{
Node->updateAbsolutePosition();
irr::core::list<ISceneNode*>::ConstIterator it = Node->getChildren().begin();
for (; it != Node->getChildren().end(); ++it)
{
updateFamily((*it));
}
}
static NxMat33 getMat33Rot(vector3df nodeRot)
{
// Quaternion
NxQuat q1, q2, q3;
q1.fromAngleAxis(nodeRot.X, NxVec3(1,0,0));
q2.fromAngleAxis(nodeRot.Y, NxVec3(0,1,0));
q3.fromAngleAxis(nodeRot.Z, NxVec3(0,0,1));
// NxQuat q;
// q = q3*q2*q1; // Use global axes
// q = q1*q2*q3; // Use local axes
// Orientation matrix
NxMat33 orient1, orient2, orient3;
orient1.fromQuat(q1);
orient2.fromQuat(q2);
orient3.fromQuat(q3);
NxMat33 orient;
orient = orient3*orient2*orient1; // Use global axes
// orient = orient1*orient2*orient3; // Use local axes
// 1. Set actor orientation from NxMat33
/////////////////////////////// nbullet->setGlobalOrientation(orient); <<----
// 2. Get NxMat33 from NxQuat
// orient.fromQuat(q);
// actor->setGlobalOrientation(orient);
// 3. Set actor orientation directly from NxQuat
// actor->setGlobalOrientationQuat(q);
return orient;
}
};