#### Archived

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

# Need help with IK

This topic is 5285 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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 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...

1. 1
2. 2
3. 3
Rutin
18
4. 4
5. 5
JoeJ
13

• 14
• 10
• 23
• 9
• 49
• ### Forum Statistics

• Total Topics
632639
• Total Posts
3007590
• ### Who's Online (See full list)

There are no registered users currently online

×

## Important Information

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!