def weight_transfer(skin_cluster, verts, old_deformers, new_deformer):
'''
------------------------------------------------------------------------
Purpose:
Transfers the weights from the old deformers to the new deformer while
keeping any other weights the same
------------------------------------------------------------------------
verts = list;
- list of verts to search for weight values and transfer them
old_deformers = list;
- list of the deformers you want to query the values from and get
rid of
new_deformer = string;
- the deformer that you want to have take the values of the old
deformers into itself
'''
active_deformers_list = cmds.skinCluster(skin_cluster, q=1, deformerTools=1)
old_deformers = [each_deformer for each_deformer in old_deformers
if each_deformer in active_deformers_list]
cmds.setAttr("%s.normalizeWeights" % skin_cluster, 0)
for each_vert in verts:
for each_deformer in old_deformers:
old_value = cmds.skinPercent(skin_cluster, each_vert, q=1,
transform=each_deformer, value=1)
cmds.skinPercent(skin_cluster, each_vert,
transformValue=[each_deformer,0])
cmds.skinPercent(skin_cluster, each_vert, transformValue = [new_deformer, old_value], relative=1 )
cmds.setAttr("%s.normalizeWeights" % skin_cluster, 1)
Thursday, November 29, 2012
Some skinning code
So while I was doing corrective skinning this past week on one of the characters on Them Greeks, I noticed there was no quick way to transfer all the weights from one or multiple joints to another quickly so you don't lose previous work by trying to reskin an area.
Subscribe to:
Comments (Atom)