本文整理汇总了Python中maya.OpenMaya.MFloatArray方法的典型用法代码示例。如果您正苦于以下问题:Python OpenMaya.MFloatArray方法的具体用法?Python OpenMaya.MFloatArray怎么用?Python OpenMaya.MFloatArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类maya.OpenMaya
的用法示例。
在下文中一共展示了OpenMaya.MFloatArray方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: select
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFloatArray [as 别名]
def select(self):
# variables
selection = OpenMaya.MSelectionList()
weights = OpenMaya.MFloatArray()
# get infliences vertices
self.skinCluster.getPointsAffectedByInfluence(
self.influence,
selection,
weights
)
# if no vertices select joint
if not selection.isEmpty():
selection.add(self.influence)
# set selection
componentMode = OpenMaya.MGlobal.kSelectComponentMode
componentMaskMode = OpenMaya.MSelectionMask.kSelectMeshVerts
componentMask = OpenMaya.MSelectionMask(componentMaskMode)
OpenMaya.MGlobal.setSelectionMode(componentMode)
OpenMaya.MGlobal.setComponentSelectionMask(componentMask)
OpenMaya.MGlobal.setHiliteList(selection)
OpenMaya.MGlobal.setActiveSelectionList(selection)
# ------------------------------------------------------------------------
示例2: deform
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFloatArray [as 别名]
def deform(self, data_block, geometry_iterator, local_to_world_matrix, geometry_index):
"""do deformation
"""
envelope_attribute = OpenMayaMPx.cvar.MPxDeformerNode_envelope
envelope_value = data_block.inputValue(envelope_attribute).asFloat()
input_geometry_object = \
self.get_deformer_input_geometry(data_block, geometry_index)
# Obtain the list of normals for each vertex in the mesh.
mesh_fn = OpenMaya.MFnMesh(input_geometry_object)
uv_shell_array = OpenMaya.MIntArray()
u_array = OpenMaya.MFloatArray()
v_array = OpenMaya.MFloatArray()
script_util = OpenMaya.MScriptUtil(0)
shells_ptr = script_util.asUintPtr()
mesh_fn.getUvShellsIds(uv_shell_array, shells_ptr)
mesh_fn.getUVs(u_array, v_array)
max_offset_attr_handle = \
data_block.inputValue(RandomizeDeformer.aMaxOffset)
max_offset = max_offset_attr_handle.asInt()
# compute and write the new uvs
for uv_id in xrange(len(u_array)):
shell_id = uv_shell_array[uv_id]
offset_u = shell_id % max_offset
u_array[uv_id] += offset_u
mesh_fn.setUVs(u_array, v_array)
uv_shell_array.clear()
u_array.clear()
v_array.clear()
# # Iterate over the vertices to move them.
# while not geometry_iterator.isDone():
# # Obtain the vertex normal of the geometry.
# # This normal is the vertex's averaged normal value if that
# # vertex is shared among several polygons.
# vertex_index = geometry_iterator.index()
# normal = OpenMaya.MVector(normals[vertex_index])
# Cast the MFloatVector into a simple vector.
#
# # Increment the point along the vertex normal.
# point = geometry_iterator.position()
# newPoint = \
# point + (normal * vertexIncrement * meshInflation * envelopeValue)
#
# # Clamp the new point within the bounding box.
# self.clampPointInBoundingBox(newPoint, boundingBox)
#
# # Set the position of the current vertex to the new point.
# geometry_iterator.setPosition(newPoint)
#
# # Jump to the next vertex.
# geometry_iterator.next()
示例3: __init__
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFloatArray [as 别名]
def __init__(self, mObject, dataBlock, rampAttr, normalize, instanceCount):
self.ramp = OpenMaya.MRampAttribute(OpenMaya.MPlug(mObject, rampAttr.ramp))
self.rampOffset = dataBlock.inputValue(rampAttr.rampOffset).asFloat()
self.rampRandomAmplitude = dataBlock.inputValue(rampAttr.rampRandomAmplitude).asFloat()
self.rampAmplitude = dataBlock.inputValue(rampAttr.rampAmplitude).asFloat()
self.rampRepeat = dataBlock.inputValue(rampAttr.rampRepeat).asFloat()
if normalize:
self.rampAxis = dataBlock.inputValue(rampAttr.rampAxis.compound).asVector().normal()
else:
self.rampAxis = dataBlock.inputValue(rampAttr.rampAxis.compound).asVector()
self.useDynamicAmplitudeValues = False
amplitudePlug = OpenMaya.MPlug(mObject, rampAttr.rampAmplitude)
if amplitudePlug.isConnected():
# Get connected input plugs
connections = OpenMaya.MPlugArray()
amplitudePlug.connectedTo(connections, True, False)
# Find input transform
if connections.length() == 1:
node = connections[0].node()
nodeFn = OpenMaya.MFnDependencyNode(node)
resultColors = OpenMaya.MFloatVectorArray()
resultTransparencies = OpenMaya.MFloatVectorArray()
uValues = OpenMaya.MFloatArray(instanceCount, 0.0)
vValues = OpenMaya.MFloatArray(instanceCount, 0.0)
# Sample a line, for more user flexibility
for i in xrange(instanceCount):
uValues.set(i / float(instanceCount), i)
vValues.set(i / float(instanceCount), i)
# For now... then we can just use the plug (TODO)
if(node.hasFn(OpenMaya.MFn.kTexture2d)):
OpenMayaRender.MRenderUtil.sampleShadingNetwork(nodeFn.name() + ".outColor", instanceCount, False, False, OpenMaya.MFloatMatrix(), None, uValues, vValues, None, None, None, None, None, resultColors, resultTransparencies)
self.rampAmplitudeValues = []
self.useDynamicAmplitudeValues = True
for i in xrange(resultColors.length()):
self.rampAmplitudeValues.append(resultColors[i].length() / math.sqrt(3))
# Ramps base offset
示例4: flatten
# 需要导入模块: from maya import OpenMaya [as 别名]
# 或者: from maya.OpenMaya import MFloatArray [as 别名]
def flatten(mesh=None, uvset=None):
"""Creates a mesh from the UV layout of another mesh.
I use this to generate flattened versions of meshes from Marvelous Designer to easily use Quad
Draw to create clean meshes and then Transfer Attributes vertex positions through UVs.
:param mesh: Mesh to sample.
:param uvset: UV set name
"""
if mesh is None:
mesh = cmds.ls(sl=True)
if not mesh:
raise RuntimeError("No mesh selected.")
mesh = mesh[0]
o_mesh = shortcuts.get_mobject(shortcuts.get_shape(mesh))
fn_mesh = OpenMaya.MFnMesh(o_mesh)
if uvset is None:
uvset = fn_mesh.currentUVSetName()
vertex_count = fn_mesh.numUVs(uvset)
polygon_count = fn_mesh.numPolygons()
u_array = OpenMaya.MFloatArray()
v_array = OpenMaya.MFloatArray()
fn_mesh.getUVs(u_array, v_array, uvset)
vertex_array = OpenMaya.MPointArray(u_array.length())
for i in range(u_array.length()):
vertex_array.set(i, u_array[i], 0, -v_array[i])
polygon_counts = OpenMaya.MIntArray(polygon_count)
it_poly = OpenMaya.MItMeshPolygon(o_mesh)
polygon_connects = OpenMaya.MIntArray(fn_mesh.numFaceVertices())
face_vertex_index = 0
while not it_poly.isDone():
face_index = it_poly.index()
polygon_counts[face_index] = it_poly.polygonVertexCount()
for i in range(polygon_counts[face_index]):
int_ptr = shortcuts.get_int_ptr()
it_poly.getUVIndex(i, int_ptr)
uv_index = shortcuts.ptr_to_int(int_ptr)
polygon_connects[face_vertex_index] = uv_index
face_vertex_index += 1
it_poly.next()
new_mesh = OpenMaya.MFnMesh()
new_mesh.create(
vertex_count,
polygon_count,
vertex_array,
polygon_counts,
polygon_connects,
u_array,
v_array,
)
new_mesh.assignUVs(polygon_counts, polygon_connects)