本文整理匯總了Python中maya.OpenMaya.MIntArray方法的典型用法代碼示例。如果您正苦於以下問題:Python OpenMaya.MIntArray方法的具體用法?Python OpenMaya.MIntArray怎麽用?Python OpenMaya.MIntArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類maya.OpenMaya
的用法示例。
在下文中一共展示了OpenMaya.MIntArray方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: undo_int_action
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def undo_int_action(self, attr, undo_command):
""" undo the last action that modified an integer value on the
instance data object
:param attr: the name of the attribute to undo
:type attr: str
:param undo_command: the commond built from the undo journal
:type undo_command: list
:return: """
if not hasattr(self.instance_data, attr):
self.logger.error('Instance data has not attribute: {}'.format(attr))
return
ids = []
values = om.MIntArray()
for i in range(len(undo_command) / 2):
ids.append(int(undo_command[i * 2]))
values.append(int(undo_command[i * 2 + 1]))
self.instance_data.set_points(ids, **{attr: values})
self.instance_data.set_state()
示例2: cache
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def cache(self):
""" cache getter
:return: tuple of entire geo cache:
id content data type
0 - p0 - MPointArray
1 - p2 - MPointArray
2 - p1 - MPointArray
3 - face normal - MVectorArray
4 - polygon id - MIntArray
5 - vector AB - MVectorArray
6 - vector AC - MvectorArray
"""
return self.p0,\
self.p1,\
self.p2,\
self.normals,\
self.poly_id,\
self.AB,\
self.AC
示例3: asComponent
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def asComponent(index, t=OpenMaya.MFn.kMeshVertComponent):
"""
index -> OpenMaya.MFn.kComponent
Based on the input type it will create a component type for this tool
the following components are being used.
* OpenMaya.MFn.kMeshVertComponent
* OpenMaya.MFn.kMeshEdgeComponent
:param int/OpenMaya.MIntArray index: indices to create component for
:param OpenMaya.MFn.kComponent t: can be all of OpenMaya component types.
:return: Initialized components
:rtype: OpenMaya.MFnSingleIndexedComponent
"""
# convert input to an MIntArray if it not already is one
array = asMIntArray(index)
# initialize component
component = OpenMaya.MFnSingleIndexedComponent().create(t)
OpenMaya.MFnSingleIndexedComponent(component).addElements(array)
return component
# ----------------------------------------------------------------------------
示例4: getWeightData
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [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)
#----------------------------------------------------------------------
示例5: setWeightData
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [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)
#----------------------------------------------------------------------
示例6: asMIntArray
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def asMIntArray(index):
"""
index -> OpenMaya.MIntArray
:param int/list of ints/OpenMaya.MIntArray index: indices
:return: Array of indices
:rtype: OpenMaya.MIntArray
"""
if type(index) != OpenMaya.MIntArray:
array = OpenMaya.MIntArray()
if type(index) == list:
for i in index:
array.append(i)
else:
array.append(index)
return array
return index
示例7: asComponent
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def asComponent(index):
"""
index -> OpenMaya.MFn.kMeshVertComponent
:param int/OpenMaya.MIntArray index: indices to create component for
:return: Initialized component(s)
:rtype: OpenMaya.MFn.kMeshVertComponent
"""
# convert input to an MIntArray if it not already is one
indices = asMIntArray(index)
# initialize component(s)
t = OpenMaya.MFn.kMeshVertComponent
component = OpenMaya.MFnSingleIndexedComponent().create(t)
OpenMaya.MFnSingleIndexedComponent(component).addElements(indices)
return component
示例8: getConnectedVertices
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def getConnectedVertices(dag, component):
"""
index -> OpenMaya.MFn.kMeshVertComponent
:param OpenMaya.MDagPath dag:
:param OpenMaya.MFn.kMeshVertComponent component:
:return: Initialized component(s), number of connected vertices
:rtype: tuple(OpenMaya.MFn.kMeshVertComponent, int)
"""
connected = OpenMaya.MIntArray()
# get connected vertices
iter = OpenMaya.MItMeshVertex(dag, component)
iter.getConnectedVertices(connected)
# get component of connected vertices
component = asComponent(connected)
return component, len(connected)
示例9: getConnectedVerticesMapper
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def getConnectedVerticesMapper(dag):
"""
Create a dictionary where the keys are the indices of the vertices and the
values a list of indices of the connected vertices.
:param OpenMaya.MDagPath dag:
:return: Connected vertices mapper
:rtype: dict
"""
# variable
data = {}
# get connected vertices
connected = OpenMaya.MIntArray()
iter = OpenMaya.MItMeshVertex(dag)
while not iter.isDone():
# get connected data
iter.getConnectedVertices(connected)
data[iter.index()] = [c for c in connected]
# go next
iter.next()
return data
示例10: __init__
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [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()
示例11: undoIt
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def undoIt(self):
visibility = om.MIntArray()
for i in range(*self.undo_range):
self.instance_data.visibility.set(0, i)
# visibility.append(0)
self.instance_data.clean_up()
self.instance_data.set_state()
示例12: __init__
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [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 = []
示例13: undo_place_action
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def undo_place_action(self, start, end):
""" undo the last place action
:param start: start index
:param end: end index
:return: """
visibility = om.MIntArray()
ids = range(start, end + 1)
[visibility.append(0) for i in ids]
self.instance_data.set_points(ids, visibility=visibility)
self.instance_data.clean_up()
self.instance_data.set_state()
示例14: create_test_data
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [as 別名]
def create_test_data(length):
""" helper function to create an instance data set of the given length """
position = om.MVectorArray()
scale = om.MVectorArray()
rotation = om.MVectorArray()
instance_id = om.MIntArray()
visibility = om.MIntArray()
normal = om.MVectorArray()
tangent = om.MVectorArray()
u_coord = om.MIntArray()
v_coord = om.MIntArray()
poly_id = om.MIntArray()
color = om.MVectorArray()
for i in xrange(length):
position.append(om.MVector(i, i, i))
scale.append(om.MVector(i, i, i))
rotation.append(om.MVector(i, i, i))
instance_id.append(i)
visibility.append(1)
normal.append(om.MVector(i, i, i))
tangent.append(om.MVector(i, i, i))
u_coord.append(i)
v_coord.append(i)
poly_id.append(i)
color.append(om.MVector(i, i, i))
return position, scale, rotation, instance_id, visibility, normal, tangent, u_coord, v_coord, poly_id, color
示例15: __init__
# 需要導入模塊: from maya import OpenMaya [as 別名]
# 或者: from maya.OpenMaya import MIntArray [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))