Swapping between meshes that are bound to the same skeleton

I’m setting up a character creation system that will allow swapping of clothing. So for instance, we have a nude mesh in body.ma, that’s rigged to a skeleton. Then we have Shirt01.ma and Shirt02.ma, plus Pants01.ma and Pants02.ma. The shirts and pants are designed to be interchangable. In each of the shirt and pants assets, the same skeleton will be referenced/imported in so that the they can be weight painted. Now how do I go about setting up a Maya scene that contains only one skeleton, and will allow me to either reference or import each asset (body, 1 shirt, 1 pants) so that when they are brought in to the scene they will all be weighted to the same single skeleton? I worked at another studio on a similar project and they had a system that worked like that, but I can’t remember if we just ended up with multiple duplicate skeletons in the scene or not.

Hope that makes sense. Thanks!

I would start with having the naked mesh rig file.

Bring in all your clothing models, skin to the same skeleton.

Then export the skinWeights (preferably with a nicer tool than the OOTB export weights tool - I really like the mGear one) for each of the clothing assets. You can then remove the clothing meshes from the rig file.

Then make a little utility window that lists the available clothing assets for that character, and a button that when pressed, imports the relevant clothing model(s) and re-imports the skin weights from the files you exported earlier.

Then you would save that rig off as a new version (assuming you’re referencing). Which does suggest that you needn’t actually go through all of that exporting weights part - you could just save out all the different options as different rig files which is what you’d end up with anyway.

I reference one skeleton into multiple character parts (or whole characters). These are exported on their own.
For animator preview (animation X on skeleton Y with character Z), I just hide the original character/part’s mesh, reference in the alternate character/parts, and direct-connect the animated skeleton in the animation file to a referenced proxy file. The rig and animation are still on the original skeleton but it looks to the animator like they are working with the alternate.

Thanks for the replies! I ended up coming up with an iffy workaround by writing a script that takes two joint lists as input and transfers the skinCluster connections of a mesh from one skeleton to the other. So if you have a rigged mesh called Body and one called Shirt, and each one is skinned to a separate (but duplicate) skeleton, it disconnects the Shirt’s skinClusters from its skeleton, and reconnects it to the Body’s skeleton. Surprisingly, it works, but after running it (in Maya 2014 64bit) the resultant mesh will be kinda messed up. Selecting the root bone and moving it a little fixes it so I’m thinking it’s just a viewport display issue.

def connectJointToSkinCluster(old_source_joints, new_source_joints):
    i = 0
    for old_joint in old_source_joints:
        if cmds.listConnections(old_joint, s=0, p=1, type='skinCluster'):
            for dest_conn in cmds.listConnections(old_joint, s=0, p=1, type='skinCluster'):
                attr = cmds.listConnections(dest_conn, d=0, p=1)[0].split('.')[1]
                cmds.disconnectAttr(cmds.listConnections(dest_conn, d=0, p=1)[0] , dest_conn )
                new_joint = new_source_joints[i]
                cmds.connectAttr("{0}.{1}".format(new_joint, attr), dest_conn )
        i+=1

Now I have a different issue. After successfully running this in a scene where I have a Body, Shirt, Pants, and Hair mesh piece all under a transform node called NewMesh, I need to transfer those weights to a similar mesh created from the same assets, but merged into one simplified (via Simplygon) mesh that’s under a transform called OldMesh.

When I select NewMesh, then OldMesh, and run Skin > Edit Smooth Skin > Copy Skin Weights, it also works surprisingly well and the vert weights from the individual meshes under NewMesh successfully transfer over to the verts in the mesh under OldMesh. However, it fails when I try to do it in script. I even tried selecting the two transforms first, and then running the exact same line of code the command uses.

cmds.copySkinWeights(ss=NewMesh, ds=OldMesh, nm=1, sa='closestPoint', ia=['closestJoint', 'closestBone', 'oneToOne'])

Any ideas? Thanks!