本文整理汇总了Python中maya.OpenMaya.MDoubleArray方法的典型用法代码示例。如果您正苦于以下问题:Python OpenMaya.MDoubleArray方法的具体用法?Python OpenMaya.MDoubleArray怎么用?Python OpenMaya.MDoubleArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.OpenMaya
的用法示例。
在下文中一共展示了OpenMaya.MDoubleArray方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getCurrentWeights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def getCurrentWeights(skinCls, dagPath, components):
"""Get the skincluster weights
Arguments:
skinCls (PyNode): The skincluster node
dagPath (MDagPath): The skincluster dagpath
components (MObject): The skincluster components
Returns:
MDoubleArray: The skincluster weights
"""
weights = OpenMaya.MDoubleArray()
util = OpenMaya.MScriptUtil()
util.createFromInt(0)
pUInt = util.asUintPtr()
skinCls.__apimfn__().getWeights(dagPath, components, weights, pUInt)
return weights
######################################
# Skin Collectors
######################################
示例2: setBlendWeights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def setBlendWeights(skinCls, dagPath, components, dataDic, compressed):
if compressed:
# The compressed format skips 0.0 weights. If the key is empty,
# set it to 0.0. 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 cast the key to int.
blendWeights = OpenMaya.MDoubleArray(dataDic['vertexCount'])
for key, value in dataDic['blendWeights'].items():
blendWeights.set(value, int(key))
else:
# The original weight format was a full list for every vertex
# For backwards compatibility on older skin files:
blendWeights = OpenMaya.MDoubleArray(len(dataDic['blendWeights']))
for ii, w in enumerate(dataDic['blendWeights']):
blendWeights.set(w, ii)
skinCls.__apimfn__().setBlendWeights(dagPath, components, blendWeights)
示例3: getWeightData
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def getWeightData(self, elements):
"""
Args:
elements (list)
Returns:
SkinWeightData
"""
dagPath, components = utils.getDagPathComponents(elements)
# Get all influences
infs = self.listInfluences(asDagPath=False)
influenceIndices = om.MIntArray()
[influenceIndices.append(self.getPhysicalInfluenceIndex(inf)) for inf in infs]
# Get all weights
weights = om.MDoubleArray()
self.fn.getWeights(dagPath, components, influenceIndices, weights)
weights = [w for w in weights]
return SkinWeightData(elements, infs, weights)
#----------------------------------------------------------------------
示例4: setWeightData
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def setWeightData(self, data, normalize=True):
"""
Args:
data (SkinWeightData)
normalize (bool, Optional): Defaults to True
"""
# Construct dagPath and components
compList = data.getComponents()
dagPath, components = utils.getDagPathComponents(compList)
# Construct influence indices
influenceIndices = om.MIntArray()
[influenceIndices.append(self.getPhysicalInfluenceIndex(inf)) for inf in data.getInfluences()]
# Construct weights
weights = om.MDoubleArray()
[weights.append(w) for w in data.getWeights()]
oldValues = om.MDoubleArray()
self.fn.getWeights(dagPath, components, influenceIndices, oldValues)
self.fn.setWeights(dagPath, components, influenceIndices, weights, normalize, oldValues)
#----------------------------------------------------------------------
示例5: getSkinWeights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def getSkinWeights(dag, skinCluster, component):
"""
Get the skin weights of the original vertex and of its connected vertices.
:param OpenMaya.MDagPath dag:
:param OpenMayaAnim.MFnSkinCluster skinCluster:
:param OpenMaya.MFn.kMeshVertComponent component:
:return: skin weights and number of influences
:rtype: tuple(OpenMaya.MDoubleArray, int)
"""
# weights variables
weights = OpenMaya.MDoubleArray()
# influences variables
influenceMSU = OpenMaya.MScriptUtil()
influencePTR = influenceMSU.asUintPtr()
# get weights
skinCluster.getWeights(dag, component, weights, influencePTR)
# get num influences
num = OpenMaya.MScriptUtil.getUint(influencePTR)
return weights, num
示例6: __init__
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def __init__(self):
self.position = om.MPointArray()
self.normal = om.MVectorArray()
self.poly_id = om.MIntArray()
self.u_coord = [] # om.MDoubleArray()
self.v_coord = [] # om.MDoubleArray()
示例7: __init__
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def __init__(self):
ompx.MPxToolCommand.__init__(self)
self.setCommandString(K_TOOL_CMD_NAME)
K_TRACKING_DICTIONARY[ompx.asHashable(self)] = self
log_lvl = sys._global_spore_dispatcher.spore_globals['LOG_LEVEL']
self.logger = logging_util.SporeLogger(__name__, log_lvl)
self.brush_state = None
self.instance_data = None
self.last_brush_position = None
self.last_undo_journal = ''
self.last_count = 0
self.last_state = {}
self.next_redo_journal = ''
self.position = om.MVectorArray()
self.scale = om.MVectorArray()
self.rotation = om.MVectorArray()
self.instance_id = om.MIntArray()
self.visibility = om.MIntArray()
self.normal = om.MVectorArray()
self.tangent = om.MVectorArray()
self.u_coord = om.MDoubleArray()
self.v_coord = om.MDoubleArray()
self.poly_id = om.MIntArray()
self.color = om.MVectorArray()
self.point_id = om.MIntArray()
self.initial_rotation = om.MVectorArray()
self.initial_scale = om.MVectorArray()
self.initial_offset = om.MDoubleArray()
self.initial_id = om.MIntArray()
self.spray_coords = []
示例8: __init__
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def __init__(self, node):
log_lvl = sys._global_spore_dispatcher.spore_globals['LOG_LEVEL']
self.logger = logging_util.SporeLogger(__name__, log_lvl)
dg_fn = om.MFnDependencyNode(node)
self.node_name = dg_fn.name()
self.node = node # TODO - hold on to selection list instead of mobj
# self.bounding_box = None
self.state = None
self.data_plug = om.MPlug()
self.data_object = om.MObject()
# instance data attributes
self.position = om.MVectorArray()
self.scale = om.MVectorArray()
self.rotation = om.MVectorArray()
self.instance_id = om.MIntArray()
self.visibility = om.MIntArray()
self.normal = om.MVectorArray()
self.tangent = om.MVectorArray()
self.u_coord = om.MDoubleArray()
self.v_coord = om.MDoubleArray()
self.poly_id = om.MIntArray()
self.color = om.MVectorArray()
self.unique_id = om.MIntArray()
self.exclusive_paint = []
# collect points for kd tree
self.np_position = np.empty((0,3), float)
self.tree = None
self.logger.info('Instanciate new InstanceData object for: {}'.format(self.node_name))
示例9: __init__
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def __init__(self):
self._locked = False
# sampled data from the ptc
self.points = om.MPointArray()
self.normals = om.MVectorArray()
self.poly_ids = om.MIntArray()
self.u_coords = om.MDoubleArray()
self.v_coords = om.MDoubleArray()
self.user = []
self.bb = None
示例10: get_points
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def get_points(self):
"""
return all points from the cache
:return: MPointArray - list of all point positions
MVectorArray - list of all normals
MIntArray - list of all polygon ids
MDoubleArray - list of all u_coordinates
MDoubleArray - list of all v coordinates
"""
return self.points, self.normals, self.poly_ids, self.u_coords, self.v_coords, self.user
示例11: collectBlendWeights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def collectBlendWeights(skinCls, dagPath, components, dataDic):
weights = OpenMaya.MDoubleArray()
skinCls.__apimfn__().getBlendWeights(dagPath, components, weights)
# round the weights down. This should be safe on Dual Quat blends
# because it is not normalized. And 6 should be more than accurate enough.
dataDic['blendWeights'] = {
i: round(weights[i], 6)
for i in range(weights.length())
if round(weights[i], 6) != 0.0
}
示例12: getInfluenceData
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def getInfluenceData(self, influence):
"""
Args:
influence (str)
Returns:
WeightData
"""
try:
dagPath = utils.getDagPath(influence)
except:
raise utils.UserInputError("Could not find influence '%s' in %s" %
(influence, self.skinCluster))
selList = om.MSelectionList()
weights = om.MDoubleArray()
self.fn.getPointsAffectedByInfluence(dagPath, selList, weights)
componentStr = []
selList.getSelectionStrings(componentStr)
componentStr = cmds.ls(componentStr, ap=1, fl=1)
weights = [w for w in weights]
return WeightData(componentStr, weights)
#----------------------------------------------------------------------
示例13: gather_blend_weights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def gather_blend_weights(self, dag_path, components):
"""Gathers the blendWeights
:param dag_path: MDagPath of the deformed geometry.
:param components: Component MObject of the deformed components.
"""
weights = OpenMaya.MDoubleArray()
self.fn.getBlendWeights(dag_path, components, weights)
self.data["blendWeights"] = [weights[i] for i in range(weights.length())]
示例14: __get_current_weights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [as 别名]
def __get_current_weights(self, dag_path, components):
"""Get the current skin weight array.
:param dag_path: MDagPath of the deformed geometry.
:param components: Component MObject of the deformed components.
:return: An MDoubleArray of the weights.
"""
weights = OpenMaya.MDoubleArray()
util = OpenMaya.MScriptUtil()
util.createFromInt(0)
ptr = util.asUintPtr()
self.fn.getWeights(dag_path, components, weights, ptr)
return weights
示例15: set_influence_weights
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MDoubleArray [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)