78 import maya.OpenMaya
as OpenMaya
79 import maya.OpenMayaMPx
as OpenMayaMPx
81 kPluginNodeName =
"spAnimCube"
84 class animCube(OpenMayaMPx.MPxNode):
89 OpenMayaMPx.MPxNode.__init__(self)
91 def createMesh(self, tempTime, outData):
92 frame = int(tempTime.asUnits(OpenMaya.MTime.kFilm))
96 cubeSize = 0.5 * float(frame % 10)
123 faceConnects.setLength(numFaceConnects)
124 faceConnects.set(0, 0)
125 faceConnects.set(1, 1)
126 faceConnects.set(2, 2)
127 faceConnects.set(3, 3)
128 faceConnects.set(4, 4)
129 faceConnects.set(5, 5)
130 faceConnects.set(6, 6)
131 faceConnects.set(7, 7)
132 faceConnects.set(3, 8)
133 faceConnects.set(2, 9)
134 faceConnects.set(6, 10)
135 faceConnects.set(5, 11)
136 faceConnects.set(0, 12)
137 faceConnects.set(3, 13)
138 faceConnects.set(5, 14)
139 faceConnects.set(4, 15)
140 faceConnects.set(0, 16)
141 faceConnects.set(4, 17)
142 faceConnects.set(7, 18)
143 faceConnects.set(1, 19)
144 faceConnects.set(1, 20)
145 faceConnects.set(7, 21)
146 faceConnects.set(6, 22)
147 faceConnects.set(2, 23)
150 faceCounts.setLength(6)
159 newMesh = meshFS.create(numVertices, numFaces, points, faceCounts, faceConnects, outData)
163 def compute(self, plug, data):
164 if plug == animCube.outputMesh:
165 timeData = data.inputValue(animCube.time)
166 tempTime = timeData.asTime()
168 outputHandle = data.outputValue(animCube.outputMesh)
171 newOutputData = dataCreator.create()
173 self.createMesh(tempTime, newOutputData)
175 outputHandle.setMObject(newOutputData)
178 return OpenMaya.kUnknownParameter
181 return OpenMayaMPx.asMPxPtr( animCube() )
183 def nodeInitializer():
187 animCube.time = unitAttr.create(
"time",
"tm", OpenMaya.MFnUnitAttribute.kTime, 0.0)
188 animCube.outputMesh = typedAttr.create(
"outputMesh",
"out", OpenMaya.MFnData.kMesh)
190 animCube.addAttribute(animCube.time)
191 animCube.addAttribute(animCube.outputMesh)
193 animCube.attributeAffects(animCube.time, animCube.outputMesh)
197 def initializePlugin(mobject):
198 mplugin = OpenMayaMPx.MFnPlugin(mobject)
200 mplugin.registerNode( kPluginNodeName, kPluginNodeId, nodeCreator, nodeInitializer)
202 sys.stderr.write(
"Failed to register node: %s" % kPluginNodeName )
206 def uninitializePlugin(mobject):
207 mplugin = OpenMayaMPx.MFnPlugin(mobject)
209 mplugin.deregisterNode( kPluginNodeId )
211 sys.stderr.write(
"Failed to deregister node: %s" % kPluginNodeName )