Updating physX with bone Orientation

medo87

14-11-2009 21:29:02

Hello Everyone,

I have been using physX + NxOgre for a ragdoll simulation. My ragdoll class is based on the work done by caphalor. I got every thing work fine so far.
The next step in my project is to superimpose my animation on top of what I get from physX. For example the ragdoll is falling down and I try to move the bones of the hand to a specific world position.
My question now is that How can I achieve this ?. I have tried using the setDriveOrientation() of a D6 joint, used setGlobalOrientation of the actors. Doing any of these two will cause the figure to fly around like crazy.

This is th code snip it that I used
for (std::map<std::string,sBoneActorBind>::iterator i = mSkeleton.begin(); i != mSkeleton.end(); i++)
{
//update Bone Actor
Ogre::Bone* bone = (i->second).mBone;
index = mHandles[i->first];
if ((i->second).mParent != NULL)
{
Ogre::Quaternion q(Ogre::Degree(90), Ogre::Vector3(1,0,0));
Ogre::Quaternion orientation = (i->second).mBone->_getDerivedOrientation() * q;
orientation = nodeOrientation * orientation; //Ogre World Position

(i->second).mActor->setGlobalOrientationQuat(toNxQuat(orientation));
}

}

I am doing this every frame, right before I call simulate()
UpdateBoneActors();

mNxScene->simulate(_time);
mNxScene->flushStream();
mNxScene->fetchResults(NX_RIGID_BODY_FINISHED,true);

Any advice on how I can achieve this, or a pointer to the righ direction will be greatly apprieciatd

Thanks
Medo