Home Website Youtube GitHub

Workflow for changing position of joints after skinning

I was wondering if there is a workflow I could use to change the position of a joint after skinning?

For context, I want to change the position the jaw hinges from to get a better deformation, but I have already done skinning weight painting work on the rig and do not want to re-build the rig again from guides.

Hello @Craig_Portnoy
You can simply offset the root transform/groupe node from the outliner and put it into the new possition. The joint will follow along. Now to avoid your current skinned asset having the offset created by that manipulation you can run the following you your selected geometries…

# maya imports
from maya import cmds

# gets skin cluster nodes from you selection
skin_nodes = cmds.ls(selection=True, type="skinCluster")
if not skin_nodes:
    cur_sel = cmds.ls(selection=True, type="transform")
    for sel in cur_sel:
        try:
            skin_nodes.append([x for x in cmds.ls(cmds.listHistory(sel), exactType="skinCluster")][0])
        except IndexError:
            continue

# reste skin cluster nodes
for skin in skin_nodes:
    plugs = cmds.listConnections("{}.matrix".format(skin), source=True, destination=False, plugs=False, connections=True)
    for idx in range(0, len(plugs), 2):
        index = plugs[idx].split("[")[-1].split("]")[0]
        if not cmds.getAttr("{}.bindPreMatrix[{}]".format(skin, index)):
            continue
        wi_matrix = cmds.getAttr("{}.worldInverseMatrix[0]".format(plugs[idx+1]))
        cmds.setAttr("{}.bindPreMatrix[{}]".format(skin, index), wi_matrix, type="matrix")

This is roughly made…

3 Likes

Thanks for the reply Jerome.
I just tried moving one of the root transform node in the guide group in the outliner, but I am finding that the joint is not following along.
Is there an attribute I need to change on either the “guide” group or “rig” group in the channel box?

I just tried moving one of the root transform node in the guide group in the outliner, but I am finding that the joint is not following along.
Is there an attribute I need to change on either the “guide” group or “rig” group in the channel box?

This completely depends on your rig. It’s hard to answer that without seeing what you’re trying to move.

But wait, did you say you are moving the “guide group”? If you aren’t rebuilding your rig, moving your guide isn’t going to do anything. You need to move the rig.

I don’t know your scripting knowledge. If you need a less technical approach:

  1. Export your skin with mGear’s skin export. mGear -> Skinning -> Export Skin
  2. Delete the skinCluster
  3. Adjust your jaw.
  4. Reload the skinning. mGear -> Skinning -> Import Skin (this function selects all your joints and makes the skinCluster for you, so you don’t need to rebind it first. Just select your unskinned geo and run that.)
2 Likes

@chrislesage my scripting knowledge is none. I’m an animator by trade!

This approach is great, will use this. Thanks!