当前位置: 首页>>代码示例>>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;未经允许,请勿转载。