Hi All,
I am doing a dynamics solution where I am translating the joints in a chain and then reorienting them to make the X Axis follow the immediate child. I am using the API function MFnIkJoint::setOrientation to reorient the joint. It looks almost right, but I think I am doing something wrong. I have a dynamic array with x, y and z attributes that are connected to the joints I want to modify. Every joint is updated from an array of particles moving in world coordinates. The translations are working perfectly, but the problem I have is on the reorientation step.
This is the algorithm I am following:
// Updating translation
for every joint in the chain
Update the x, y and z elements in the array. So the joints connected are moving.
endfor
//Updating orientation
for every joint in the chain
parentinv = exclusivematrixinverse of joint
newXAxis = particle to aim in parent space of this joint (using parentinv)
newXAxis.normalize
xAxis = (1,0,0)
MQuaternion quat = MVector::xAxis.rotateTo( newxaxis)
MFIkJoint.SetOrientation( quat);
endfor
I tried to find the answer on several posts and I read the API documentation... I hope you guys can tell me where is the error.
Is this the correct way to reorient the joint? Should I use rotationAxis instead? It looks like for some joints it aims properly but not for others.
Thanks a lot in advance!
Mike