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


Python OpenMaya.MDagPathArray方法代碼示例

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


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

示例1: collectInfluenceWeights

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def collectInfluenceWeights(skinCls, dagPath, components, dataDic):
    weights = getCurrentWeights(skinCls, dagPath, components)

    influencePaths = OpenMaya.MDagPathArray()
    numInfluences = skinCls.__apimfn__().influenceObjects(influencePaths)
    numComponentsPerInfluence = weights.length() / numInfluences
    for ii in range(influencePaths.length()):
        influenceName = influencePaths[ii].partialPathName()
        influenceWithoutNamespace = pm.PyNode(influenceName).stripNamespace()
        # build a dictionary of {vtx: weight}. Skip 0.0 weights.
        inf_w = {
                jj: weights[jj * numInfluences + ii]
                for jj in range(numComponentsPerInfluence)
                if weights[jj * numInfluences + ii] != 0.0
                }
        # cast to float to avoid rounding errors when dividing integers?
        dataDic['vertexCount'] = int(weights.length() / float(numInfluences))
        # cast influenceWithoutNamespace as string otherwise it can end up
        # as DependNodeName(u'jointName') in the data.
        dataDic['weights'][str(influenceWithoutNamespace)] = inf_w 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:22,代碼來源:skin.py

示例2: gather_influence_weights

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def gather_influence_weights(self, dag_path, components):
        """Gathers all the influence weights

        :param dag_path: MDagPath of the deformed geometry.
        :param components: Component MObject of the deformed components.
        """
        weights = self.__get_current_weights(dag_path, components)

        influence_paths = OpenMaya.MDagPathArray()
        influence_count = self.fn.influenceObjects(influence_paths)
        components_per_influence = weights.length() // influence_count
        for ii in range(influence_paths.length()):
            influence_name = influence_paths[ii].partialPathName()
            # We want to store the weights by influence without the namespace so it is easier
            # to import if the namespace is different
            influence_without_namespace = shortcuts.remove_namespace_from_name(
                influence_name
            )
            self.data["weights"][influence_without_namespace] = [
                weights[jj * influence_count + ii]
                for jj in range(components_per_influence)
            ] 
開發者ID:chadmv,項目名稱:cmt,代碼行數:24,代碼來源:skinio.py

示例3: setInfluenceWeights

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def setInfluenceWeights(skinCls, dagPath, components, dataDic, compressed):
    unusedImports = []
    weights = getCurrentWeights(skinCls, dagPath, components)
    influencePaths = OpenMaya.MDagPathArray()
    numInfluences = skinCls.__apimfn__().influenceObjects(influencePaths)
    numComponentsPerInfluence = weights.length() / numInfluences

    for importedInfluence, wtValues in dataDic['weights'].items():
        for ii in range(influencePaths.length()):
            influenceName = influencePaths[ii].partialPathName()
            nnspace = pm.PyNode(influenceName).stripNamespace()
            influenceWithoutNamespace = nnspace
            if influenceWithoutNamespace == importedInfluence:
                if compressed:
                    for jj in range(numComponentsPerInfluence):
                        # json keys can't be integers. The vtx number key
                        # is unicode. example: vtx[35] would be: u"35": 0.6974,
                        # But the binary format is still an int, so check both.
                        # if the key doesn't exist, set it to 0.0
                        wt = wtValues.get(jj) or wtValues.get(str(jj)) or 0.0
                        weights.set(wt, jj * numInfluences + ii)
                else:
                    for jj in range(numComponentsPerInfluence):
                        wt = wtValues[jj]
                        weights.set(wt, jj * numInfluences + ii)
                    break
        else:
            unusedImports.append(importedInfluence)

    influenceIndices = OpenMaya.MIntArray(numInfluences)
    for ii in range(numInfluences):
        influenceIndices.set(ii, ii)
    skinCls.__apimfn__().setWeights(dagPath,
                                    components,
                                    influenceIndices,
                                    weights,
                                    False) 
開發者ID:mgear-dev,項目名稱:mgear_core,代碼行數:39,代碼來源:skin.py

示例4: listInfluences

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def listInfluences(self, asDagPath=True):
        """
        Returns:
          list
        """
        dagPaths = om.MDagPathArray()
        self.fn.influenceObjects(dagPaths)
        if asDagPath: return dagPaths
        else: return [dagPaths[i].partialPathName() for i in xrange(dagPaths.length())]

    #---------------------------------------------------------------------- 
開發者ID:WebberHuang,項目名稱:DeformationLearningSolver,代碼行數:13,代碼來源:fnData.py

示例5: reset

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def reset(self):
        self._obj = None
        self._dag = None
        self._index = None
        self._influence = None
        self._influences = OpenMaya.MDagPathArray()
        self._influencesLocked = []
        
        self._skinCluster = None
        self._normalizeMode = None
        
        self.beforeSelection = OpenMaya.MIntArray()
        self.afterSelection = OpenMaya.MIntArray() 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:15,代碼來源:paintRemoveInfluenceCtxCommands.py

示例6: reset

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def reset(self):
        self._obj = None
        self._dag = None
        self._skinCluster = None
        
        self._maxInfluences = 0
        self._normalizeMode = 0
        self._maintainMaxInfluences = False
        
        self._influences = OpenMaya.MDagPathArray()
        self._influencesLocked = [] 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:13,代碼來源:paintSmoothWeightsCtxCommands.py

示例7: initialize

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def initialize(self, obj):
        # if no obj reset variables
        if not obj:
            self.reset()
            return 

        # get object data
        self._obj = api.asMObject(obj)
        self._dag = api.asMDagPath(self.obj)
        
        # get skin cluster
        self._skinCluster = api.asMFnSkinCluster(self.obj)
        
        # get skin cluster data
        maxPlug = self.skinCluster.findPlug("maxInfluences")
        normalPlug = self.skinCluster.findPlug("normalizeWeights")
        maintainPlug = self.skinCluster.findPlug("maintainMaxInfluences")
        
        self._maxInfluences = maxPlug.asInt()
        self._normalizeMode = normalPlug.asInt()
        self._maintainMaxInfluences = maintainPlug.asBool()
        
        # get influences
        self._influences = OpenMaya.MDagPathArray()
        self.skinCluster.influenceObjects(self._influences)
            
        # get locked influences
        self._influencesLocked = []
        for i in range(self.influences.length()):
            path = self.influences[i].fullPathName()
            locked = cmds.getAttr("{0}.liw".format(path))
            
            self._influencesLocked.append(locked)

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

示例8: getInfluences

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def getInfluences(skinCluster):
    """
    Get all of the influence data connected to the skinCluster. This is a
    OpenMaya.MDagPathArray, OpenMaya.MIntArray() and a regular list of partial
    names.

    :param OpenMaya.MFnSkinCluster skinCluster:
    :return: Dag paths, integer and partial names
    :rtype: tuple(
        OpenMaya.MDagPathArray
        OpenMaya.MIntArray
        list of strings
    )
    """
    # variables
    influencesDag = OpenMaya.MDagPathArray()
    influencesI = OpenMaya.MIntArray()
    influencesN = []

    # get influences
    skinCluster.influenceObjects(influencesDag)

    # get influences data
    for i in range(influencesDag.length()):
        influencesI.append(i)
        influencesN.append(influencesDag[i].partialPathName())

    return influencesDag, influencesI, influencesN 
開發者ID:robertjoosten,項目名稱:maya-skinning-tools,代碼行數:30,代碼來源:influence.py

示例9: set_influence_weights

# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MDagPathArray [as 別名]
def set_influence_weights(self, dag_path, components):
        """Sets all the influence weights.

        :param dag_path: MDagPath of the deformed geometry.
        :param components: Component MObject of the deformed components.
        """
        influence_paths = OpenMaya.MDagPathArray()
        influence_count = self.fn.influenceObjects(influence_paths)

        elements = OpenMaya.MIntArray()
        fncomp = OpenMaya.MFnSingleIndexedComponent(components)
        fncomp.getElements(elements)
        weights = OpenMaya.MDoubleArray(elements.length() * influence_count)

        components_per_influence = elements.length()

        for imported_influence, imported_weights in self.data["weights"].items():
            imported_influence = imported_influence.split("|")[-1]
            for ii in range(influence_paths.length()):
                influence_name = influence_paths[ii].partialPathName()
                influence_without_namespace = shortcuts.remove_namespace_from_name(
                    influence_name
                )
                if influence_without_namespace == imported_influence:
                    # Store the imported weights into the MDoubleArray
                    for jj in range(components_per_influence):
                        weights.set(imported_weights[elements[jj]], jj * influence_count + ii)
                    break

        influence_indices = OpenMaya.MIntArray(influence_count)
        for ii in range(influence_count):
            influence_indices.set(ii, ii)
        self.fn.setWeights(dag_path, components, influence_indices, weights, False) 
開發者ID:chadmv,項目名稱:cmt,代碼行數:35,代碼來源:skinio.py


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