How to transfer skinning influence of a joint to another joint?


#1

Is it possible to replace in a skinCluster the influences of a certain joint by a new joint?

I want to replace all the joints of a skinned mesh by new joints, those new joints would be placed at the exact same spot as the old ones and with the same skin weights but in a single hierarchy joint chain so that I can export those joints easily to a game engine.

So it would be like this in the skinCluster:
oldJoint_1 influence ==> newJoint_1 influence

I need to do this by script because I must do this for a lot of different joints (preferably Python).


#2

Hi
Why don’t you parent the skin joints and rename too, if needed and still there will not a need to export and import skin weights. I suppose you are going to export only the skin joints to the game engine.
still have a look at manual process @ https://charactertdprem.blogspot.com/search?q=skin
Regards
Prem
https://charactertdprem.blogspot.com/


#3

Hello shinyprem,
Yes I will export that rig in a game engine. But how do I do this in python?
I want to create a function to the skin weight a new joint.

Here’s my attempt at how it would work:

def transferSkinOverToNewJoint(joint1, joint2):
clusters = get_skin_clusters(joint1);
for skin in clusters:
    print("==> Transferring in cluster: " + skin + " | jnt1: " + joint1 + " to jnt2: " + joint2)
    transferSkinFromJoint1ToJoint2(skin, joint1, joint2);

def transferSkinFromJoint1ToJoint2(skinCluster, joint1, joint2):
vertices = cmds.skinCluster(skinCluster, selectInfluenceVerts=joint1) # THIS DOESN'T WORK
for v in vertices:
    print (v)
cmds.select(vertices, r=True)
cmds.skinPercent(skinCluster, transformValue=[(joint1, 0), (joint2, 1)]) # How to transfer properly?

def get_skin_clusters(joint): # this does the job properly
    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))