60 import maya.OpenMaya
as OpenMaya
61 import maya.OpenMayaMPx
as OpenMayaMPx
63 kPluginNodeTypeName =
"spSineNode"
68 class sineNode(OpenMayaMPx.MPxNode):
73 OpenMayaMPx.MPxNode.__init__(self)
74 def compute(self,plug,dataBlock):
75 if ( plug == sineNode.output ):
76 dataHandle = dataBlock.inputValue( sineNode.input )
78 inputFloat = dataHandle.asFloat()
79 result = math.sin( inputFloat ) * 10.0
80 outputHandle = dataBlock.outputValue( sineNode.output )
81 outputHandle.setFloat( result )
82 dataBlock.setClean( plug )
84 return OpenMaya.kUnknownParameter
88 return OpenMayaMPx.asMPxPtr( sineNode() )
91 def nodeInitializer():
94 sineNode.input = nAttr.create(
"input",
"in", OpenMaya.MFnNumericData.kFloat, 0.0 )
98 sineNode.output = nAttr.create(
"output",
"out", OpenMaya.MFnNumericData.kFloat, 0.0 )
102 sineNode.addAttribute( sineNode.input )
103 sineNode.addAttribute( sineNode.output )
104 sineNode.attributeAffects( sineNode.input, sineNode.output )
107 def initializePlugin(mobject):
108 mplugin = OpenMayaMPx.MFnPlugin(mobject)
110 mplugin.registerNode( kPluginNodeTypeName, sineNodeId, nodeCreator, nodeInitializer )
112 sys.stderr.write(
"Failed to register node: %s" % kPluginNodeTypeName )
116 def uninitializePlugin(mobject):
117 mplugin = OpenMayaMPx.MFnPlugin(mobject)
119 mplugin.deregisterNode( sineNodeId )
121 sys.stderr.write(
"Failed to deregister node: %s" % kPluginNodeTypeName )