8 from builtins
import range
10 import maya.api.OpenMayaRender
as omr
11 import maya.api.OpenMaya
as om
25 The presence of this function tells Maya that the plugin produces, and
26 expects to be passed, objects created using the Maya Python API 2.0.
30 class MyCustomBufferMutator(omr.MPxVertexBufferMutator):
32 omr.MPxVertexBufferMutator.__init__(self)
34 def modifyVertexStream(self, object, vertexBuffer, targetIndexing):
37 descriptor = vertexBuffer.descriptor()
40 if descriptor.dataType != omr.MGeometry.kFloat:
44 if descriptor.dimension != 3:
48 if descriptor.semantic != omr.MGeometry.kPosition:
53 mesh = om.MFnMesh(object)
55 vertexCount = vertexBuffer.vertexCount()
60 buffer = vertexBuffer.acquire(vertexCount,
False)
65 for i
in range(0, vertexCount):
72 x = c_float.from_address(xaddr).value
73 c_float.from_address(xaddr).value = c_float.from_address(yaddr).value
74 c_float.from_address(yaddr).value = c_float.from_address(zaddr).value
75 c_float.from_address(zaddr).value = x
78 vertexBuffer.commit(buffer)
82 def createMyCustomBufferMutator():
83 return MyCustomBufferMutator()
87 def initializePlugin(obj):
89 omr.MDrawRegistry.registerVertexBufferMutator(
"swizzlePosition_py", createMyCustomBufferMutator)
91 def uninitializePlugin(obj):
93 omr.MDrawRegistry.deregisterVertexBufferMutator(
"swizzlePosition_py")