本文整理汇总了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
示例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)
]
示例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)
示例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())]
#----------------------------------------------------------------------
示例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()
示例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 = []
示例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)
# ------------------------------------------------------------------------
示例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
示例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)