當前位置: 首頁>>代碼示例>>Python>>正文


Python cmds.skinPercent方法代碼示例

本文整理匯總了Python中maya.cmds.skinPercent方法的典型用法代碼示例。如果您正苦於以下問題:Python cmds.skinPercent方法的具體用法?Python cmds.skinPercent怎麽用?Python cmds.skinPercent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在maya.cmds的用法示例。


在下文中一共展示了cmds.skinPercent方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_import_skin_on_selected_subset

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [as 別名]
def test_import_skin_on_selected_subset(self):
        file_path = self.get_temp_filename("temp.skin")
        skinio.export_skin(file_path, self.shape)
        cmds.skinPercent(
            self.skin,
            "{0}.vtx[0]".format(self.shape),
            transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)],
        )
        cmds.skinPercent(
            self.skin,
            "{0}.vtx[1]".format(self.shape),
            transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)],
        )
        cmds.select("{}.vtx[1]".format(self.shape))
        skinio.import_skin(file_path, to_selected_shapes=True)

        skin = skinio.SkinCluster(self.skin)
        data = skin.gather_data()

        w1 = [0.1, 0.5, 0.5, 0.0, 0.5, 0.0, 0.9, 0.5]
        w2 = [0.2, 0.5, 0.5, 0.5, 0.5, 0.5, 0.1, 0.5]
        w3 = [0.7, 0.0, 0.0, 0.5, 0.0, 0.5, 0.0, 0.0]
        self.assertListAlmostEqual(w1, data["weights"]["joint1"])
        self.assertListAlmostEqual(w2, data["weights"]["joint2"])
        self.assertListAlmostEqual(w3, data["weights"]["joint3"]) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:27,代碼來源:test_cmt_skinio.py

示例2: setWeights

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [as 別名]
def setWeights(self, data):
        """
        Set the weights on the Maya vertex.
        
        :param list data: List of list with influences and weights data
        """
        cmds.skinPercent(self.skinCluster, self.vertex, transformValue=data)


# ---------------------------------------------------------------------------- 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:12,代碼來源:ui.py

示例3: dm2skin_getLargestInfluenceOnVert

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [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

示例4: test_import_skin_sets_correct_data

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [as 別名]
def test_import_skin_sets_correct_data(self):
        file_path = self.get_temp_filename("temp.skin")
        skinio.export_skin(file_path, self.shape)
        cmds.skinPercent(
            self.skin,
            "{0}.vtx[0]".format(self.shape),
            transformValue=[(self.joint1, 0.1), (self.joint2, 0.2), (self.joint3, 0.7)],
        )
        skinio.import_skin(file_path)
        self.test_skincluster_data_is_correct() 
開發者ID:chadmv,項目名稱:cmt,代碼行數:12,代碼來源:test_cmt_skinio.py

示例5: softSelectionSkinWeights

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [as 別名]
def softSelectionSkinWeights(*args):

    model = mc.ls(sl=True, o=True)
    joints = mc.ls(model, type='joint')
    mc.select(joints, deselect=True)
    weights = getSoftSelectionWeights()

    if not model or not joints or not weights:
        raise RuntimeError('Select vertices followed by a joint')

    if len(joints) > 1:
        raise RuntimeError('Only one joint can be selected at a time')

    joint = joints[0]

    skin = utl.getSkinCluster(model[0])

    if not skin:
        raise RuntimeError('Mesh must have an existing skinCluster')

    influences = mc.skinCluster(skin, query=True, influence=True)
    if joint not in influences:
        mc.skinCluster(skin, edit=True, addInfluence=joint, lockWeights=False, weight=0)

    for influence in influences:
        mc.skinCluster(skin, edit=True, influence=influence, lockWeights=False)

    for vertex, weight in weights.items():
        mc.skinPercent(skin, vertex, transformValue=(joint, weight))

    mc.select(joint)


#      ______________________
# - -/__ Revision History __/- - - - - - - - - - - - - - - - - - - - - - - -
#
# Revision 1: 2016-12-31 : Initial publish
#
# Revision 2: 2018-02-17 : Updating license to MIT. 
開發者ID:morganloomis,項目名稱:ml_tools,代碼行數:41,代碼來源:ml_softWeights.py

示例6: __init__

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [as 別名]
def __init__(self, parent, vertex):
        Qt.QWidget.__init__(self, parent)
        
        # variables
        self.vertex = vertex
        self.mesh, _ = vertex.split(".", 1)
        self.skinCluster = skin.getSkinCluster(self.mesh)
        
        # get skinned data
        influences = cmds.skinPercent(
            self.skinCluster, vertex, query=True, transform=None
        )
        
        values = cmds.skinPercent(
            self.skinCluster, vertex, query=True, value=True
        )
        
        # order data
        data = zip(values, influences)
        data.sort()
        data.reverse()

        # create layout
        layout = Qt.QVBoxLayout(self)
        layout.setContentsMargins(3, 3, 3, 3)
        layout.setSpacing(3)
        
        # create divider
        divider = widgets.Divider(self)
        layout.addWidget(divider)
        
        # create label
        self.label = VertexLabelWidget(self, vertex)
        layout.addWidget(self.label)
        
        # create divider
        divider = widgets.Divider(self)
        layout.addWidget(divider)
        
        # create frame
        self.frame = VertexInfluencesWidget(self, self.skinCluster, data)
        self.frame.signal.connect(self.setWeights)
        layout.addWidget(self.frame)
        
        # connect influences toggle
        self.label.signal.connect(self.frame.displayInfluences)
        self.frame.warningSignal.connect(self.label.displayWarning)
        
        # force display
        self.frame.displayMaxInfluences()
        
    # ------------------------------------------------------------------------ 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:54,代碼來源:ui.py

示例7: LOD_transferWeights

# 需要導入模塊: from maya import cmds [as 別名]
# 或者: from maya.cmds import skinPercent [as 別名]
def LOD_transferWeights(meshes, jointsToRemove, jointToTransferTo, debug=1, pruneWeights=0.001, *args):
        '''
        Original function by Charles Anderson @ Epic Games
        '''
        for mesh in meshes:

            # Find the skin cluster for the current mesh
            cluster = findCluster(mesh)

            if debug:
                print "MESH: ", mesh
                print "CLUSTER: ", cluster

            # Prune weights on the current mesh
            if pruneWeights:
                cmds.skinPercent(cluster, mesh, prw=pruneWeights)

            # Find all of the current influences on the current skin cluster.
            meshInfluences = cmds.skinCluster(cluster, q=True, inf=True)
            #print "Current Influences: ", meshInfluences

            for joint in jointsToRemove:
                if joint in meshInfluences:
                    #print "Current Joint: ", joint

                    # If the jointToTransferTo is not already an influence on the current mesh then add it.
                    currentInfluences = cmds.skinCluster(cluster, q=True, inf=True)
                    if jointToTransferTo not in currentInfluences:
                        cmds.skinCluster(cluster, e=True, wt=0, ai=jointToTransferTo)

                    # Now transfer all of the influences we want to remove onto the jointToTransferTo.
                    for x in range(cmds.polyEvaluate(mesh, v=True)):
                        #print "TRANSFERRING DATA....."
                        value = cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), t=joint, q=True)
                        if value > 0:
                            cmds.skinPercent(cluster, (mesh+".vtx["+str(x)+"]"), tmw=[joint, jointToTransferTo])

            # Remove unused influences
            currentInfluences = cmds.skinCluster(cluster, q=True, inf=True)
            #print "Current Influences: ", currentInfluences
            influencesToRemove = []
            weightedInfs = cmds.skinCluster(cluster, q=True, weightedInfluence=True)
            #print "Weighted Influences: ", weightedInfs
            for inf in currentInfluences:
                #print "Influence: ", inf
                if inf not in weightedInfs:
                    #print "Update Influences to Remove List: ", inf
                    influencesToRemove.append(inf)

            #print "ToRemove Influences: ", influencesToRemove
            if influencesToRemove != []:
                for inf in influencesToRemove:
                    cmds.skinCluster(cluster, e=True, ri=inf)

## UI RELATED
########################################################################

    #event filter to grab and discern right/left click 
開發者ID:chrisevans3d,項目名稱:uExport,代碼行數:60,代碼來源:uExport.py


注:本文中的maya.cmds.skinPercent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。