54 from builtins
import range
55 import maya.OpenMaya
as OpenMaya
56 import maya.OpenMayaMPx
as OpenMayaMPx
57 import maya.OpenMayaRender
as OpenMayaRender
58 import maya.OpenMayaUI
as OpenMayaUI
63 kPluginNodeTypeName =
"spFootPrintNode"
66 glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer()
67 glFT = glRenderer.glFunctionTable()
69 sole = ( [ 0.00, 0.0, -0.70 ],
81 [ -0.15, 0.0, -0.14 ],
82 [ -0.16, 0.0, -0.25 ],
83 [ -0.17, 0.0, -0.35 ],
84 [ -0.17, 0.0, -0.46 ],
85 [ -0.16, 0.0, -0.54 ],
86 [ -0.13, 0.0, -0.61 ],
87 [ -0.09, 0.0, -0.65 ],
88 [ -0.04, 0.0, -0.69 ],
89 [ -0.00, 0.0, -0.70 ] )
91 heel = ( [ 0.00, 0.0, 0.06 ],
100 [ -0.04, 0.0, 0.30 ],
101 [ -0.09, 0.0, 0.29 ],
102 [ -0.11, 0.0, 0.28 ],
103 [ -0.13, 0.0, 0.25 ],
104 [ -0.14, 0.0, 0.21 ],
105 [ -0.14, 0.0, 0.15 ],
106 [ -0.13, 0.0, 0.06 ],
107 [ -0.00, 0.0, 0.06 ] )
109 class footPrintNode(OpenMayaMPx.MPxLocatorNode):
113 OpenMayaMPx.MPxLocatorNode.__init__(self)
115 def compute(self, plug, dataBlock):
116 return OpenMaya.kUnknownParameter
118 def draw(self, view, path, style, status):
119 thisNode = self.thisMObject()
123 sizeVal = plug.asMDistance()
125 multiplier = sizeVal.asCentimeters()
129 if style == OpenMayaUI.M3dView.kFlatShaded
or style == OpenMayaUI.M3dView.kGouraudShaded:
130 glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
132 if status == OpenMayaUI.M3dView.kActive:
133 view.setDrawColor( 13, OpenMayaUI.M3dView.kActiveColors )
135 view.setDrawColor( 13, OpenMayaUI.M3dView.kDormantColors )
138 glFT.glBegin( OpenMayaRender.MGL_TRIANGLE_FAN )
139 for i
in range(last):
140 glFT.glVertex3f(sole[i][0]*multiplier, sole[i][1]*multiplier, sole[i][2]*multiplier)
144 glFT.glBegin( OpenMayaRender.MGL_TRIANGLE_FAN )
145 for i
in range(last):
146 glFT.glVertex3f(heel[i][0]*multiplier, heel[i][1]*multiplier, heel[i][2]*multiplier)
151 glFT.glBegin(OpenMayaRender.MGL_LINES)
154 for i
in range(last):
155 glFT.glVertex3f( sole[i][0]*multiplier, sole[i][1]*multiplier, sole[i][2]*multiplier )
156 glFT.glVertex3f( sole[i+1][0]*multiplier, sole[i+1][1]*multiplier, sole[i+1][2]*multiplier )
159 for i
in range(last):
160 glFT.glVertex3f( heel[i][0]*multiplier, heel[i][1]*multiplier, heel[i][2]*multiplier )
161 glFT.glVertex3f( heel[i+1][0]*multiplier, heel[i+1][1]*multiplier, heel[i+1][2]*multiplier )
170 def boundingBox(self):
171 thisNode = self.thisMObject()
174 sizeVal = plug.asMDistance()
176 multiplier = sizeVal.asCentimeters()
181 corner1 = corner1 * multiplier
182 corner2 = corner2 * multiplier
190 return OpenMayaMPx.asMPxPtr( footPrintNode() )
193 def nodeInitializer():
195 footPrintNode.size = unitFn.create(
"size",
"in", OpenMaya.MFnUnitAttribute.kDistance)
196 unitFn.setDefault(1.0)
197 footPrintNode.addAttribute( footPrintNode.size )
200 def initializePlugin(mobject):
201 mplugin = OpenMayaMPx.MFnPlugin(mobject)
203 mplugin.registerNode( kPluginNodeTypeName, footPrintNodeId, nodeCreator, nodeInitializer, OpenMayaMPx.MPxNode.kLocatorNode )
205 sys.stderr.write(
"Failed to register node: %s" % kPluginNodeTypeName )
209 def uninitializePlugin(mobject):
210 mplugin = OpenMayaMPx.MFnPlugin(mobject)
212 mplugin.deregisterNode( footPrintNodeId )
214 sys.stderr.write(
"Failed to deregister node: %s" % kPluginNodeTypeName )