Bake/record to IPO from constraints and IK?

I want to be able to use IK and constraints and all that so I can switch between IK and FK using two armatures- but in the end, in order to get it all to play in the GE, I need to bake all the keys to the main armature such that I can remove all the constraints and IK after I’m done so it’ll work in the GE.

Is there a script or method for doing this?

I’ve thought about this before. It would be great to have a script that ‘bakes’ actions defined using IK into a FK action. IK is so much faster for creating actions, but currently only FK supports action blending in the game engine. (IK defined actions can be used, but not too sure about constraints.)

My thoughts were to iterate through all actions on an armature and define a new action. This new action would have ‘Rot’ keys inserted for every bone on every frame so the action is then defined entirely using FK. This would result in a very heavy file due to the high number of keys. The keys could then be iterated through and if no change in rotaion is found then all keys except the first key defining a particular rotaion and the last key for that rotation could be removed. This would leave a potentially heavy, but probably manageable action.

Since an action is stored in it’s own data block (I think), it would be trivial to link actions to a different armature, provided all bones effected by the action have identical names in both armatures.

Like I said… I’ve thought about it, and it’s on my todo list, but I’ve not actually done anything on this yet. I think the method that I outlined above should work, though.

i would insert the keys in the same place the IK armature’s keys are, wouldn’t make much sense anywhere else, and every frame is just insane. plus once you put those keys, you can do a final frame-per-frame scan to measure the deviation of the keyed FK mesh bones respect to the fk-controlled bones, if it’s greater than a certain amount, it inserts a key (that process can be iterated an adjustable number of times, maybe as a two-value “fidelity” setting)

Even if it was on every key, would it be all that heavy? I’ve read BVH files for Second Life animations, and they record a location and rotation for every frame- and they work just fine. I wouldn’t think this would slow anything down really.

Also, I bet you could iterate through the entire FK base with something like this script (modified of course)
I guess loop through every animation frame and record each bone rotation. Quick, dirty, and may just get the job done. I don’t think speed will be an issue as far as the game engine is concerned.

Ideasman pointed me to this script:

Which can be found in Blender already under the scripts window > Animation > Bake Constraints

So this might be the solution I was looking for! :smiley: