PDA

View Full Version : How to bake IK/bone animation?


martinB
04-28-2009, 10:56 PM
This has been nagging me for a while...:
How would you go about baking down bone animation produced by an HI IK controller?

I would like to create one keyframe per frame for each bone in the scene, using standard PRS controllers and no IK.
Additionally, the bone object itself should remain the original one - so I cannot simply create a new bone without IK and then copy the IK'ed transform over to the new bone (this would not work if the original IK bone is used in a Skin modifier, for example).

So the first difficulty I encounter is that I seem not to be able to remove an 'IKControl' controller from a bone. Also, I could not find a way to figure out which IK handle a certain IKControl controller is affected by. And given an IK Handle, I could not even find a way to get all affected bones, so I am fairly stuck.... ;)

Any ideas welcome!
-- MartinB

Guibou
04-29-2009, 03:49 AM
Maybe you could try to create a new set of bones as reference for your IK Bones. So you copie the transform of your IK Bones to your New Bones and than delete your IK controllers and put PRS controllers on your IK Bones. After that you copie back the transform of your New Bones (copied from IK Bones with IK controllers) onto your IK Bones with the PRS controllers. When all is finish you can delete your New Bones from your scene if you want to.

I don't know if it's the most optimal way to do this, but it might help you out. ciao

phoelix
04-29-2009, 03:57 AM
try this:

first look for all the bones in the scene and store their animation in matrix arrays (a Transform matrix per each frame, per each bone), then look for all the ikChain controls and delete them (it removes the Ik control in the bones), asign prs controllers in bones that have any constraint, script or expression controller. And finally set back the animation to the bones using the matrix array:


undo on
(
TMArray=#()
--gety the bones in the scene
bonesArray=for o in objects where (classof o)==BoneGeometry collect o
--get the animation of the bones, a TM per each frame in the animation range
for b=1 to bonesArray.count do
(
append TMArray #()
for f=animationrange.start to animationrange.end do
(
at time f append TMArray[b] bonesArray[b].transform
)
)
--delete ikcontrol objects
for o in objects where (classof o)==IK_Chain_Object do delete o
--assign a new prs controller (to delete any constraint or undesirible controller) and set back the animation
animate on
(
for b=1 to bonesArray.count do
(
bonesArray[b].controller=PRS()
ff=1
for f=animationrange.start to animationrange.end do
(
at time f bonesArray[b].transform=TMArray[b][ff]
ff+=1
)
)
)
)

martinB
04-29-2009, 03:30 PM
Thanks!

I initially asked about bones driven by HI IK, and I will try your solution as soon as I have time, but what about HD IK, which does not have an IK handle as such? And any thoughts on Bipeds?!

It seems all of these are special cases that need separate treatment. :(
I am considering updating my motion baking script, and right now it won't handle any of these situations well.

Thanks again!
-- MartinB

CGTalk Moderation
04-29-2009, 03:30 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.