Пример #1
0
def setInfluenceSymmetry(*args):
    """Sets the symmetry attributes of the influences for the selected mesh(es).
    
    Parameters
    ----------
    *args : str
        List of skinned polygon meshes. If empty, the active selection is used.
        
    """

    selectedMeshes = _getSelectedMeshes(*args)

    if not selectedMeshes:
        _ERR("Select a skinned mesh and try again.")
        return

    with undoChunk():
        for mesh in selectedMeshes:
            skin = _getSkinCluster(mesh)

            if not skin:
                _WARN("Skipping '%s' since it is not skinned." % mesh)
                continue

            cmds.polySkinWeights(skin,
                                 edit=True,
                                 influenceSymmetry=("L_*", "R_*"))
Пример #2
0
def setInfluenceSymmetry(*args, **kwargs):
    """Sets the symmetry attributes of the influences for the selected mesh(es).
    
    Parameters
    ----------
    *args : str
        List of skinned polygon meshes. If empty, the active selection is used.
    **leftPattern : str
        Pattern for matching influences on the left side of the mesh. 
    **rightPattern : str 
        Pattern for matching influences on the right side of the mesh.         
    """

    selectedMeshes = _getSelectedMeshes(*args)

    leftPattern = kwargs.get('leftPattern', 'L_*')
    rightPattern = kwargs.get('leftPattern', 'R_*')

    if not selectedMeshes:
        raise polySymmetry.utils.InvalidSelection(
            "Select a skinned mesh and try again.")

    with undoChunk():
        for mesh in selectedMeshes:
            skin = _getSkinCluster(mesh)

            if not skin:
                _WARN("Skipping '%s' since it is not skinned." % mesh)
                continue

            cmds.polySkinWeights(skin,
                                 edit=True,
                                 influenceSymmetry=(leftPattern, rightPattern))
Пример #3
0
def mirrorPolySkinWeights(*args, **kwargs):
    """Mirrors the skinCluster weights on the selected mesh(es).
    
    Parameters
    ----------
    *args : str
        List of skinned polygon meshes. If empty, the active selection is used.
        
    Raises
    ------
    RuntimeError
        If the selected mesh(es) do not have poly symmetry data computed.

    """

    activeSelection = OpenMaya.MGlobal.getActiveSelectionList()
    numberOfSelectedItems = activeSelection.length()

    selectedMeshes = _getSelectedMeshes(*args)
    skinClusters = [_getSkinCluster(mesh) for mesh in selectedMeshes]

    if not selectedMeshes:
        raise polySymmetry.utils.InvalidSelection(
            "Select a skinned mesh and try again.")

    if not kwargs:
        options = polySymmetry.utils.loadOptions('polySkinWeights')

        kwargs = {'mirror': True}

        if options.get('normalize', False):
            kwargs['normalize'] = True

        if options.get('useInfluencePattern', True):
            kwargs['influenceSymmetry'] = (options.get('leftPattern', 'L_*'),
                                           options.get('rightPattern', 'R_*'))

        kwargs['direction'] = 1 if options.get('direction', 1) == 1 else -1

    with undoChunk():
        for mesh, skin in zip(selectedMeshes, skinClusters):

            if not skin:
                _WARN("Skipping '%s' since it is not skinned." % mesh)
                continue

            cmds.polySkinWeights(sourceMesh=mesh,
                                 sourceSkin=skin,
                                 destinationMesh=mesh,
                                 destinationSkin=skin,
                                 **kwargs)
Пример #4
0
def printInfluenceSymmetry(*args):
    """Sets the symmetry attributes of the influences for the selected mesh(es).
    
    Parameters
    ----------
    *args : str
        List of skinned polygon meshes. If empty, the active selection is used.
        
    """

    selectedMeshes = _getSelectedMeshes(*args)

    if not selectedMeshes:
        _ERR("Select a skinned mesh and try again.")
        return

    with undoChunk():
        for mesh in selectedMeshes:
            skin = _getSkinCluster(mesh)

            if not skin:
                _WARN("Skipping '%s' since it is not skinned." % mesh)
                continue

            result = cmds.polySkinWeights(skin,
                                          query=True,
                                          influenceSymmetry=True)

            print('Mesh: {}'.format(mesh))
            print('Skin: {}'.format(skin))
            print('\n'.join(
                ['{:>32} : {:>32}'.format(*sym.split(':')) for sym in result]))
Пример #5
0
def copyPolySkinWeights(*args):
    """Copies the skinCluster weights from one mesh to another.
    
    Parameters
    ----------
    *args : str
        Two skinned polygon meshes. If empty, the active selection is used.
        
    Raises
    ------
    RuntimeError
        If the source mesh and target mesh are not point compatible.

    """

    try:
        sourceMesh, destinationMesh = _getSelectedMeshes(*args)
    except ValueError:
        raise polySymmetry.utils.InvalidSelection(
            "Must select a souce mesh and a destination mesh.")
        return

    sourceSkin = _getSkinCluster(sourceMesh)
    destinationSkin = _getSkinCluster(destinationMesh)

    if not sourceSkin:
        raise polySymmetry.utils.InvalidSelection("'%s' is not skinned." %
                                                  sourceMesh)
        return

    if not destinationSkin:
        raise polySymmetry.utils.InvalidSelection("'%s' is not skinned." %
                                                  destinationMesh)
        return

    cmds.polySkinWeights(sourceMesh=sourceMesh,
                         sourceSkin=sourceSkin,
                         destinationMesh=destinationMesh,
                         destinationSkin=destinationSkin,
                         direction=1,
                         normalize=True)
Пример #6
0
def mirrorPolySkinWeights(*args):
    """Mirrors the skinCluster weights on the selected mesh(es).
    
    Parameters
    ----------
    *args : str
        List of skinned polygon meshes. If empty, the active selection is used.
        
    Raises
    ------
    RuntimeError
        If the selected mesh(es) do not have poly symmetry data computed.

    """

    activeSelection = OpenMaya.MGlobal.getActiveSelectionList()
    numberOfSelectedItems = activeSelection.length()

    selectedMeshes = _getSelectedMeshes(*args)
    skinClusters = [_getSkinCluster(mesh) for mesh in selectedMeshes]

    if not selectedMeshes:
        _ERR("Select a skinned mesh and try again.")
        return

    with undoChunk():
        for mesh, skin in zip(selectedMeshes, skinClusters):

            if not skin:
                _WARN("Skipping '%s' since it is not skinned." % mesh)
                continue

            cmds.polySkinWeights(sourceMesh=mesh,
                                 sourceSkin=skin,
                                 destinationMesh=mesh,
                                 destinationSkin=skin,
                                 direction=1,
                                 mirror=True,
                                 normalize=True)