Archived

This topic is now archived and is closed to further replies.

rgreene

Need help with IK

Recommended Posts

I'm having some trouble getting IK to work with my animation system, and I need some help. I don't think the issue is with the IK solvers themselves, but rather with the architecture of my animation engine. All bones store rotation as quats, relative to their parent's bone rotation. I get these quats (in addition to bone offsets) from 3DSMax -- as such these quats are generated with the assumption that z is up, rather than y is up, which my engine natively understands. This is all well and good because I can apply a translation when it comes to render time -- the only caveat is that the actual animation of the character (ie applying rotation to bones) is done in "max space." So, I'm having trouble getting simple stuff to work, I'm trying to work in max's space. Here's the algorithm that I'm using to rotate a bone such that it points parallel to a given vector (this is a simple solver to try to take a leaf bone and point it at a given point): targetVector = *fFocusPoint - bone->fFinalWorldPosition; targetVector.mSwizzleYZ (); boneVector.mSet (1, 0, 0); bone->fParent->fOutput.mTransform (boneVector); targetVector.mNormalize (); boneVector.mNormalize (); orthoAxis = targetVector.mCrossProduct (boneVector); orthoAxis.mNormalize (); q.mCreateRotation (orthoAxis, -acos (boneVector.mDotProduct (targetVector))); parentRotation = bone->fOutput; parentRotation.mInverse (); q = parentRotation * q; At this point 'q' should have the localized rotation that points the bone in the proper direction... in theory. Some clarification: to build 'targetVector' I find the direction in y-up space, and then swizzle y/z in order to get into max-space. This is effectively how I get from max's bone space to my 3d space when it comes to draw time, so I believe this to be a valid step. [edited by - rgreene on April 5, 2004 5:55:51 PM]

Share this post


Link to post
Share on other sites
Hrm... I was looking at my output and realized that it looks like it might be correct, except only on one rotation plane. I pointed the camera down the orthoganol axis generated by getting the cross of the bone''s direction vector and my target vector and noticed that the bone looked correctly rotated. Is it possible that the rotation produced by my code above is insufficient to rotate a bone correctly in R(3)?

Share this post


Link to post
Share on other sites
Uhg... I feel stupid, it wasn''t a math problem at all, just me failing to realize how to use my own tQuaternion class...

Share this post


Link to post
Share on other sites