67 from builtins
import next
70 import maya.OpenMaya
as OpenMaya
71 import maya.OpenMayaAnim
as OpenMayaAnim
72 import maya.OpenMayaMPx
as OpenMayaMPx
73 import maya.cmds
as cmds
75 kPluginNodeTypeName =
"spyTwistNode"
79 kApiVersion = cmds.about(apiVersion=
True)
80 if kApiVersion < 201600:
81 outputGeom = OpenMayaMPx.cvar.MPxDeformerNode_outputGeom
82 envelope = OpenMayaMPx.cvar.MPxDeformerNode_envelope
84 outputGeom = OpenMayaMPx.cvar.MPxGeometryFilter_outputGeom
85 envelope = OpenMayaMPx.cvar.MPxGeometryFilter_envelope
88 class yTwistNode(OpenMayaMPx.MPxDeformerNode):
93 OpenMayaMPx.MPxDeformerNode.__init__(self)
95 def deform(self,dataBlock,geomIter,matrix,multiIndex):
98 angleHandle = dataBlock.inputValue( self.angle )
99 angleValue = angleHandle.asDouble()
102 envelopeHandle = dataBlock.inputValue( envelope )
103 envelopeValue = envelopeHandle.asFloat()
106 while geomIter.isDone() ==
False:
107 point = geomIter.position()
108 ff = angleValue * point.y * envelopeValue
112 tt= point.x*cct-point.z*cst
113 point.z= point.x*cst + point.z*cct
115 geomIter.setPosition( point )
120 return OpenMayaMPx.asMPxPtr( yTwistNode() )
123 def nodeInitializer():
126 yTwistNode.angle = nAttr.create(
"angle",
"fa", OpenMaya.MFnNumericData.kDouble, 0.0 )
128 nAttr.setKeyable(
True)
131 yTwistNode.addAttribute( yTwistNode.angle )
132 yTwistNode.attributeAffects( yTwistNode.angle, outputGeom )
134 sys.stderr.write(
"Failed to create attributes of %s node\n", kPluginNodeTypeName )
137 def initializePlugin(mobject):
138 mplugin = OpenMayaMPx.MFnPlugin(mobject)
140 mplugin.registerNode( kPluginNodeTypeName, yTwistNodeId, nodeCreator, nodeInitializer, OpenMayaMPx.MPxNode.kDeformerNode )
142 sys.stderr.write(
"Failed to register node: %s\n" % kPluginNodeTypeName )
145 def uninitializePlugin(mobject):
146 mplugin = OpenMayaMPx.MFnPlugin(mobject)
148 mplugin.deregisterNode( yTwistNodeId )
150 sys.stderr.write(
"Failed to unregister node: %s\n" % kPluginNodeTypeName )