Does someone know how to transfer the skinning weights between 2 joints?
I thought what I want to do is simple but it seems that transferring skin is actually complicated and slow. Now I don’t mind it being slow that much I think I won’t need to use to use it all that much, but I’m in quite the pickle because I need to get this function to work asap because it’s blocking me in creating my game.
The script attached does not work, it’s only an attempt to show what I’m trying to do.
def transfer_skin_to_new_joint(oldJoint, newJoint):
clusters = get_skin_clusters(oldJoint);
for skin in clusters:
print("==> Transferring in cluster: " + skin + " | jnt1: " + oldJoint + " to jnt2: " + newJoint)
#if (cmds.skinCluster(influence=True, query=True)) #get the joints in the cluster, if not in, add it
#cmds.skinCluster(skin, edit=True, addInfluence=joint2, wt = 0);
transfer_skin_between_joints(skin, oldJoint, newJoint);
#cmds.skinCluster(skin, edit=True, removeInfluence=joint1)
def transfer_skin_between_joints(skinCluster, joint1, joint2):
vertices = cmds.skinCluster(skinCluster, selectInfluenceVerts=joint1)
for v in vertices:
print (v)
# joints = cmds.skinCluster(skinCluster, query=True, inf=True)
# for j in joints:
# print(j)
cmds.select(vertices, r=True)
cmds.skinPercent(skinCluster, transformValue=[(joint1, 0), (joint2, 1)])
def get_skin_clusters(joint):
all_skins = []
skins = list(set(cmds.listConnections(joint, type="skinCluster")))
for skin in skins:
print(skin)
all_skins.append(skin)
return list(set(all_skins))