当前位置: 首页>>代码示例>>Python>>正文


Python cmds.skinCluster方法代码示例

本文整理汇总了Python中maya.cmds.skinCluster方法的典型用法代码示例。如果您正苦于以下问题:Python cmds.skinCluster方法的具体用法?Python cmds.skinCluster怎么用?Python cmds.skinCluster使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.skinCluster方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: dpCheckSkinCluster

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def dpCheckSkinCluster(self, shapeList, *args):
        """ Verify if there's a skinCluster node in the list of history of the shape.
            Return True if yes.
            Return False if no.
            Return -1 if there's another node with the same name.
        """
        for shapeNode in shapeList:
            if not shapeNode.endswith("Orig"):
                try:
                    histList = cmds.listHistory(shapeNode)
                    if histList:
                        for histItem in histList:
                            if cmds.objectType(histItem) == "skinCluster":
                                return True
                except:
                    return -1
        return False 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:19,代码来源:dpCopySkin.py

示例2: dpCopySkin

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def dpCopySkin(self, sourceItem, destinationList, skinInfList, *args):
        """ Do the copy skin from sourceItem to destinationList using the skinInfList.
        """
        for item in destinationList:
            # get correct naming
            skinClusterName = utils.extractSuffix(item)
            if "|" in skinClusterName:
                skinClusterName = skinClusterName[skinClusterName.rfind("|")+1:]
            # create skinCluster node
            cmds.skinCluster(skinInfList, item, name=skinClusterName+"_SC", toSelectedBones=True, maximumInfluences=3, skinMethod=0)
            cmds.select(sourceItem)
            cmds.select(item, toggle=True)
            # copy skin weights from sourceItem to item node
            cmds.copySkinWeights(noMirror=True, surfaceAssociation="closestPoint", influenceAssociation=["label", "oneToOne", "closestJoint"])
            # log result
            print self.langDic[self.langName]['i083_copiedSkin'], sourceItem, item 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:18,代码来源:dpCopySkin.py

示例3: __init__

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def __init__(self, skin_cluster):
        """Constructor"""
        self.node = skin_cluster
        self.shape = cmds.listRelatives(
            cmds.deformer(skin_cluster, q=True, g=True)[0], parent=True, path=True
        )[0]

        # Get the skinCluster MObject
        self.mobject = shortcuts.get_mobject(self.node)
        self.fn = OpenMayaAnim.MFnSkinCluster(self.mobject)
        self.data = {
            "weights": {},
            "blendWeights": [],
            "name": self.node,
            "shape": self.shape,
        } 
开发者ID:chadmv,项目名称:cmt,代码行数:18,代码来源:skinio.py

示例4: copySkinInfluences

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def copySkinInfluences(source, dest):

    sourceSkin = utl.getSkinCluster(source)
    if not sourceSkin:
        return False

    joints = mc.skinCluster(sourceSkin, query=True, influence=True)

    destSkin = utl.getSkinCluster(dest)

    if not destSkin:
        destSkin = mc.skinCluster(joints, dest, toSelectedBones=True)[0]
    else:
        destJoints = mc.skinCluster(destSkin, query=True, influence=True)
        for joint in [x for x in joints if x not in destJoints]:
            mc.skinCluster(destSkin, edit=True, addInfluence=joint, lockWeights=False, weight=0)

    return destSkin 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:20,代码来源:ml_copySkin.py

示例5: copySkinComponents

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def copySkinComponents(source, destinationVerts):

    if not mc.listRelatives(source, shapes=True):
        raise RuntimeError('Source object must be geometry.')

    sourceSkin = utl.getSkinCluster(source)

    if not sourceSkin:
        raise RuntimeError("Source mesh doesn't have a skinCluster to copy from.")

    destMesh = mc.ls(destinationVerts[0], o=True)[0]
    destMesh = mc.listRelatives(destMesh, parent=True)[0]
    destSkin = copySkinInfluences(source, destMesh)

    tempSet = mc.sets(destinationVerts)

    mc.select(source, tempSet)

    mc.copySkinWeights(noMirror=True,
                       surfaceAssociation='closestPoint',
                       influenceAssociation='closestJoint',
                       normalize=True)

    mc.delete(tempSet)
    mc.select(destinationVerts) 
开发者ID:morganloomis,项目名称:ml_tools,代码行数:27,代码来源:ml_copySkin.py

示例6: stock_copy_mesh

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def stock_copy_mesh(self):
        hl_node = cmds.ls(hl=True, l=True)
        sel_node = cmds.ls(sl=True, l=True)
        temp_copy_mesh = common.search_polygon_mesh(hl_node+sel_node, fullPath=True)
        self.copy_mesh = []
        for node in temp_copy_mesh:
            skin_cluster = cmds.ls(cmds.listHistory(node), type='skinCluster')
            if skin_cluster:
                self.copy_mesh.append(node)
        
        if not self.copy_mesh:
            cmds.confirmDialog( title='Error',
                  message= self.msg02)
            return self.msg02
        return 'Set Copy Mesh :\n'+str(self.copy_mesh)
        #print 'copy mesh :',self.copy_mesh 
开发者ID:ShikouYamaue,项目名称:SIWeightEditor,代码行数:18,代码来源:weight_transfer_multiple.py

示例7: pre_transfer_for_noskin_comp

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def pre_transfer_for_noskin_comp(self):
        reselection_flag = False
        for node in self.hl_nodes:
            skin_cluster = cmds.ls(cmds.listHistory(node), type='skinCluster')
            if not skin_cluster:
                #print 'pre transfer :', node, self.copy_mesh[0]
                weight.transfer_weight(self.copy_mesh[0], node, transferWeight=False)
                cmds.bakePartialHistory(node, ppt=True)
                reselection_flag = True
        if reselection_flag:
            #print 'reselect for undo :'
            #アンドゥ、リドゥのためにエディタ側のスキン情報を更新しておく
            cmds.select(self.transfer_comp, r=True)
            siweighteditor.WINDOW.get_set_skin_weight()
                
    #インフルエンス合わせのために転送側の全てのインフルエンスを格納しておく 
开发者ID:ShikouYamaue,项目名称:SIWeightEditor,代码行数:18,代码来源:weight_transfer_multiple.py

示例8: dpMain

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def dpMain(self, *args):
        """ Main function to analise and call copy skin process. 
        """
        selList = cmds.ls(selection=True)
        if selList and len(selList) > 1:
            # get first selected item
            sourceItem = selList[0]
            # get other selected items
            destinationList = selList[1:]
            # validade unique node name
            if len(cmds.ls(sourceItem)) == 1:
                shapeList = cmds.listRelatives(sourceItem, shapes=True)
                if shapeList:
                    # check if there's a skinCluster node connected to the first selected item
                    checkSkin = self.dpCheckSkinCluster(shapeList)
                    if checkSkin == True:
                        # get joints influence from skinCluster
                        skinInfList = cmds.skinCluster(sourceItem, query=True, influence=True)
                        if skinInfList:
                            # call copySkin function
                            self.dpCopySkin(sourceItem, destinationList, skinInfList)
                    elif checkSkin == -1:
                        mel.eval("warning \""+self.langDic[self.langName]["i163_sameName"]+" "+sourceItem+"\";")
                    else:
                        print self.langDic[self.langName]['e007_notSkinFound']
                else:
                    print self.langDic[self.langName]['e006_firstSkinnedGeo']
            else:
                mel.eval("warning \""+self.langDic[self.langName]["i163_sameName"]+" "+sourceItem+"\";")
        else:
            print self.langDic[self.langName]['e005_selectOneObj'] 
开发者ID:nilouco,项目名称:dpAutoRigSystem,代码行数:33,代码来源:dpCopySkin.py

示例9: symmetry_weight

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def symmetry_weight(srcNode=None, dstNode=None, symWeight=True):
    '''
    ウェイトシンメトリする関数
    srcNode→反転元
    dstNode→反転先
    symWeight→ウェイトミラーするかどうか
    '''
    # スキンクラスタを取得
    if srcNode is None:
        return
    srcShapes = cmds.listRelatives(srcNode, s=True, pa=True, type='mesh')
    if srcShapes:
        srcSkinCluster = cmds.ls(cmds.listHistory(srcNode), type='skinCluster')
        # スキンクラスタがあったらジョイントラベルを設定してウェイトミラー
        if srcSkinCluster:
            # バインド状態を転送する関数呼び出し
            skinJointAll = cmds.skinCluster(srcSkinCluster, q=True, inf=True) #ジョイントを取得
            for skinJoint in skinJointAll:
                # ジョイントラベル設定関数呼び出し
                joint_label(skinJoint, visibility=False)
            if symWeight is False or dstNode is None:
                return
            transfer_weight(srcNode, dstNode, transferWeight=False, returnInfluences=True)
            dstShapes = cmds.listRelatives(dstNode, s=True, pa=True, type='mesh')
            dstSkinCluster = cmds.listConnections(dstShapes[0] + '.inMesh', s=True, d=False)
            cmds.copySkinWeights(ss=srcSkinCluster[0], ds=dstSkinCluster[0],
                                 mirrorMode='YZ', surfaceAssociation='closestComponent',
                                 influenceAssociation='label', normalize=True) 
开发者ID:ShikouYamaue,项目名称:SISideBar,代码行数:30,代码来源:weight.py

示例10: applyRigidSkin

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def applyRigidSkin():
    """"""
    sel = cmds.ls(sl=1, ap=1)
    if len(sel) < 2:
        om.MGlobal.displayError("Please select joints first, then mesh.")
        return
    mesh = sel.pop()
    cmds.skinCluster(sel, mesh, tsb=1, mi=0, nw=1, bm=1)

#---------------------------------------------------------------------- 
开发者ID:WebberHuang,项目名称:DeformationLearningSolver,代码行数:12,代码来源:miscFunc.py

示例11: selectInfluenceJoints

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def selectInfluenceJoints():
    try:
        sel = cmds.ls(sl=1, ap=1)[0]
        try:
            skinNode = utils.findRelatedSkinCluster(sel)
            infs = cmds.skinCluster(skinNode, q=1, inf=1)
        except:
            om.MGlobal.displayError("No skinCluster found in history of %s." % sel)
            return             
        cmds.select(infs)
    except:
        om.MGlobal.displayError("Please select something.")
        return 
开发者ID:WebberHuang,项目名称:DeformationLearningSolver,代码行数:15,代码来源:miscFunc.py

示例12: addInfluences

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def addInfluences(skinCluster, influences):
    """
    Add influences to the skin cluster. Expects full path influences. Will
    try to reach the bind pose before attached the new influences to the skin
    cluster.

    :param str skinCluster:
    :param list influences:
    """
    # get existing influences
    existing = cmds.skinCluster(skinCluster, query=True, influence=True)
    existing = cmds.ls(existing, l=True)

    # try restoring dag pose
    try:
        cmds.dagPose(existing, restore=True, g=True, bindPose=True)
    except:
        cmds.warning("Unable to reach dagPose!")

    # add influences
    for influence in influences:
        if influence not in existing:
            cmds.skinCluster(
                skinCluster,
                edit=True,
                addInfluence=influence,
                weight=0.0
            ) 
开发者ID:robertjoosten,项目名称:maya-skinning-tools,代码行数:30,代码来源:influence.py

示例13: getSkinCluster

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def getSkinCluster(mesh, joints):
    """
    This function will check if the provided mesh has a skin cluster attached
    to it. If it doesn't a new skin cluster will be created with the provided
    joints as influences. No additional arguments are used to setup the skin
    cluster. This is something that needs to be done afterwards by the user.
    If a skin cluster already exists all provided joints will be added to the
    skin cluster as an influence.

    :param str mesh:
    :param list joints:
    :return: Skin cluster
    :rtype: str
    """
    # full path joints
    joints = cmds.ls(joints, l=True)

    # get skin cluster
    sk = skin.getSkinCluster(mesh)
    if not sk:
        # create skin cluster
        sk = cmds.skinCluster(
            joints,
            mesh,
            dropoffRate=0.1,
        )[0]

    else:
        # make sure all provided joints are an influence of the skin cluster
        # that is already attached to the mesh
        influence.addInfluences(sk, joints)

    return sk 
开发者ID:robertjoosten,项目名称:maya-skinning-tools,代码行数:35,代码来源:skin.py

示例14: dm2skin_getLargestInfluenceOnVert

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def dm2skin_getLargestInfluenceOnVert(vertex, skinCluster=None):
    """Given a vertex returns the largest influence in the provided
    skin cluster that acts upon it."""
    if not skinCluster:
        return False

    vertInfs = cmds.skinCluster(skinCluster, q=True, inf=True)
    vertVals = cmds.skinPercent(skinCluster, vertex, q=True, value=True)
    return vertInfs[vertVals.index(max(vertVals))] 
开发者ID:duncanskertchly,项目名称:dm2skin,代码行数:11,代码来源:dm2skin.py

示例15: dm2skin_getNeighbouringJoints

# 需要导入模块: from maya import cmds [as 别名]
# 或者: from maya.cmds import skinCluster [as 别名]
def dm2skin_getNeighbouringJoints(joint, vertexString=None, cluster=None, influences=3):
    """This gets a list of nearby joints in the skin cluster to joint up to
    the number of influences. These will be the ones we use in our minimization
    later"""

    if not cmds.objExists(joint):
        return False
    if influences < 3:
        return False
    if not cluster:
        return False

    clusterJoints = cmds.skinCluster(cluster, q=True, inf=True)

    pos1 = cmds.xform(vertexString, q=True, ws=True, t=True)

    parentJoint = cmds.listRelatives(joint, parent=True)

    subtract = 1
    # add the main joint
    resultList = [joint]
    # i've found it works best to always include the parent
    if parentJoint and parentJoint in clusterJoints:
        resultList.insert(0, parentJoint[0])
        subtract = 2

    # for the rest of the available influences get a list of nearby joints in space
    measureList = []
    for measureJnt in clusterJoints:
        if measureJnt not in resultList:
            jntPos2 = cmds.xform(measureJnt, q=True, ws=True, t=True)
            #this just gets the length of the vector between the two joints
            dist = math.sqrt(reduce(lambda x, y: x + y, [math.pow(jntPos2[i] - pos1[i], 2) for i in range(len(pos1))]))
            measureList.append((measureJnt, dist))

    # sort the list in ascending order so we get the closest joints first
    measureList.sort(key=lambda dist: dist[1])
    ascendingList = [entry[0] for entry in measureList[0:influences - subtract]]
    return resultList + ascendingList 
开发者ID:duncanskertchly,项目名称:dm2skin,代码行数:41,代码来源:dm2skin.py


注:本文中的maya.cmds.skinCluster方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。