「利用者:Roger/Bake Constraints」の版間の差分

提供: wiki
移動先: 案内検索
(相違点なし)

2012年1月2日 (月) 19:57時点における版

user manual for bake constraints python script

The actual location and rotation of an object can be set by an IPO curve, but then altered by a constraint. This script creates a shadow copy of the object, and computes an ipo curve with Loc and Rot points that reflect the actual location of the real object at each frame. It thus 'bakes' in the effects of any constraints, like softbody physics or copy location. If the original object was called "Man", then the shadow copy is called "a.Man". The a.Man object will start at a location behind the real Man (offset by a Y of 5 more than Man, but with the same X and Z). This location offset will remain constant throughout the animation. If the animation frame range baked is from 318 to 617, the new ipo curve will be from 1 to 300. This frame offset will remain constant throughout the animation.

If you have an armature object, then you have two kinds of IPOs: object and pose. The object IPO is derived from the computed location of the object during the animation; you established this based on the movement of some "root" empties, usually the lower back. Each bone in the shadow armature will have a pose IPO that reflects its actual location and rotation of the real bone, within the armature space, instead of constraints.

Uses: Just as you can do two renders to compare the effects of changes in materials on the colors of the render, now you can do two animations to compare the effects of changes in constraints In using MoCap, you now have a rig that is free from constraints and can be analyzed and motion split up into actions.

Operation: Set the frame range to be baked. Select the object to be baked. Run the script. Run the animation to confirm



You can then apply this curve Use this script to make an ipo curve for the actual location of an object.

Future enahncement

UI allows user to specify offset in location and frames, or stretch out animation.

Pseudocode: Initialize If there is an object selected

   set the name of the clone to "a." plus the object name
   if an object by that name exists, delete it #only one clone, please!
   if the original object is not in Object mode, 
     reset it to object mode #since it cannot be duplicated in edit or pose mode
   duplicate it (including constraints and IPO curve, if any)
   remove any constraints from the shadow object
   clear any IPO curve from the shadow, or create a blank one if none exist
   If the object is an armature
     for each bone in the armature
       clear any IPO curve from the shadow, or create a blank one if none exist
   #so now we have a fresh clean copy
   for each frame in the animation
     advance to that frame and compute the location and rotation of the object
     add the object's location plus the offset to the clone's ipo curve 
     add the object's rotation as bezier points to the clone's ipo curve 
     if it is an armature
       for each bone in the armature
         copy the pose LocRot information to the clone's ipo

else:

 Error - must select an object to clone