Go to: Synopsis. Return value. Keywords. Related. Flags. MEL examples.
bakeDeformer [-colorizeSkeleton boolean] [-customRangeOfMotion timerange] [-dstMeshName string] [-dstSkeletonName string] [-hierarchy boolean] [-influences string[]] [-maxInfluences int] [-pruneWeights float] [-smoothWeights int] [-srcMeshName string] [-srcSkeletonName string]
bakeDeformer is undoable, NOT queryable, and NOT editable.
Given a rigged character, whose mesh shape is determined by a set of deformers, bakeDeformer calculates linear blend skin weights most closely approximating observed deformations. To do this, a test set of examples is generated by moving the rig through a range of motion. Results mesh and pose pairs are then used to solve a constrained optimization, solving for skinning weights. bakeDeformer automatically binds and applies resulting weights to the destination geometry. If the source and destination mesh/skeleton are identical, the command will replace the original deformations with a skinCluster and computed weights. See the below examples for sample usage.
bake, skinning, deformer
skinPercent
colorizeSkeleton, customRangeOfMotion, dstMeshName, dstSkeletonName, hierarchy, influences, maxInfluences, pruneWeights, smoothWeights, srcMeshName, srcSkeletonName
Long name (short name) |
Argument types |
Properties |
-colorizeSkeleton(-cs)
|
boolean
|
|
|
The new skin cluster created will have its skeleton colorized. Must be used with the -srcSkeletonName and -dstSkeletonName flags.
|
|
-customRangeOfMotion(-rom)
|
timerange
|
|
|
When this flag is specified with the frames for the range of motion to be used, the tool will step through
each frame as a separate pose. Otherwise the tool will use the existing range of motion in the tool
that rotates each influence 45 degrees.
Usage examples:
- -rom "10:20" means all frames in the range from 10 to 20, inclusive, in the current time unit.
- Omitting one end of a range means using either end of the animation range (or both), as in the following examples:
- -rom "10:" means all frames from time 10 (in the current time unit) onwards to the maximum time in the animation range (on the timeline).
- -rom ":10" means all frames from the minimum time on the animation range (on the timeline) up to (and including) time 10 (in the current time unit).
- -rom ":" is a short form to specify all frames, from minimum to maximum time on the current animation range.
When using this flag, some of the joints in the specified range of motion may not have changed sufficiently.
To improve bakeDeformer results or avoid algorithm errors, the command will return a list of influences that do not move enough in the specified range of motion.
To detect these joints, the local transformation of each joint is compared between subsequent frames.
We consider that a joint has sufficiently changed if any of the below criteria are met:
- There is a rotation of at least 5 degrees, as determined by the shortest rotation between transforms.
- There is a translation of 1% or greater of the size of the largest bounding box containing all joints for each frame.
- There is a scaling change of at least 1%. This percentage represents the smallest scaling value over the largest scaling value (in absolute value).
If a joint has not met any of the criteria, it will be added to the warning of joints that have not moved enough.
The custom range of motion should be considered experimental.
|
|
-dstMeshName(-dm)
|
string
|
|
|
The destination mesh name.
|
|
-dstSkeletonName(-ds)
|
string
|
|
|
The destination skeleton name.
|
|
-hierarchy(-hi)
|
boolean
|
|
|
All children of the passed joints that are used in the influences flag are used.
|
|
-influences(-i)
|
string[]
|
|
|
A list of joints that are used as the influences to determine new weights.
|
|
-maxInfluences(-mi)
|
int
|
|
|
The maximum number of influences per vertex.
|
|
-pruneWeights(-pw)
|
float
|
|
|
On the newly created skin cluster, set any weight below the given the value to zero (post-processing).
This will call the skinPercent command as follows: "skinPercent -pruneWeights [value] [skinClusterName] [dstMeshName]"
where [value] is the value passed into this flag, [skinClusterName] is the name of the new skinCluster node created
after running this tool, and [dstMeshName] is the mesh provided in the -dstMeshName flag.
|
|
-smoothWeights(-sw)
|
int
|
|
|
The number of smoothing iterations for smoothing weights (post-processing). This also renormalizes the remaining the weights.
|
|
-srcMeshName(-sm)
|
string
|
|
|
-srcSkeletonName(-ss)
|
string
|
|
|
The source skeleton name.
|
|
Flag can appear in Create mode of command
|
Flag can appear in Edit mode of command
|
Flag can appear in Query mode of command
|
Flag can be used more than once in a command.
|
proc string[] createJointsAndMesh(float $offset[])
{
string $root = `joint`;
joint; move -r 0 2 0;
joint; move -r 0 2 0;
joint; move -r 0 2 0;
joint; move -r 0 2 0;
joint; move -r 0 2 0;
string $meshes[] = `polyCube -sx 3 -sy 10 -sz 3 -h 10`;
move -r 0 5 0;
select -r $root $meshes;
move -r $offset[0] $offset[1] $offset[2];
select -cl;
return {$root, $meshes[0]};
}
proc bindMesh(string $object[])
{
string $rootJoint = $object[0];
string $mesh = $object[1];
select -r -hi $rootJoint;
select -add $mesh;
SmoothBindSkin;
select -cl;
}
proc randomizeJoints(string $object[])
{
string $rootJoint = $object[0];
select -r $rootJoint;
pickWalk -d down;
for ($i=0; $i<4; $i++)
{
float $rads[] = `sphrand 1.`;
rotate(
rad_to_deg($rads[0]),
rad_to_deg($rads[1]),
rad_to_deg($rads[2]));
pickWalk -d down;
}
}
proc matchRotations(string $src, string $dst)
{
select -r -hi $src;
string $srcChain[] = `ls -sl`;
select -r -hi $dst;
string $dstChain[] = `ls -sl`;
for ($i=0; $i<5; $i++)
{
select -r $dstChain[$i] $srcChain[$i];
MatchRotation;
}
}
{
// Create an empty scene
file -f -new;
// Create two joint chains/meshes
string $object1[] = createJointsAndMesh({0, 0, 0});
string $object2[] = createJointsAndMesh({5, 0, 0});
// Bind one of the joint chains to the mesh and rotate the weights
bindMesh($object1);
randomizeJoints($object1);
// Use bakeDeformer to learn and apply the linear blend skinning weights.
// Specify the source/destination skeletons and meshes and the number of maximum influences.
bakeDeformer
-ss $object1[0] -sm $object1[1]
-ds $object2[0] -dm $object2[1]
-mi 3;
// Match the rotations of the two chains to show the results are similar
matchRotations($object1[0], $object2[0]);
}