78 import maya.OpenMaya 
as OpenMaya
 
   79 import maya.OpenMayaUI 
as OpenMayaUI
 
   80 import maya.OpenMayaRender 
as OpenMayaRender
 
   81 import maya.OpenMayaMPx 
as OpenMayaMPx
 
   85 glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer()
 
   86 glFT = glRenderer.glFunctionTable()
 
   88 kSwissArmyLocatorName = 
"spSwissArmyLocator" 
   90 kSwissArmyLocatorManipName = 
"spSwissArmyLocatorManip" 
   99 centre = [  [  0.10, 0.0,  0.10 ],
 
  100             [  0.10, 0.0, -0.10 ],
 
  101             [ -0.10, 0.0, -0.10 ],
 
  102             [ -0.10, 0.0,  0.10 ], 
 
  103             [  0.10, 0.0,  0.10 ] ] 
 
  104 state1 = [  [  1.00, 0.0,  1.00 ],
 
  108             [  1.00, 0.0,  1.00 ] ] 
 
  109 state2 = [  [  1.00, 0.0, -1.00 ],
 
  110             [  1.00, 0.0, -0.50 ],
 
  111             [  0.50, 0.0, -0.50 ],
 
  112             [  0.50, 0.0, -1.00 ], 
 
  113             [  1.00, 0.0, -1.00 ] ] 
 
  114 state3 = [  [ -1.00, 0.0, -1.00 ],
 
  115             [ -1.00, 0.0, -0.50 ],
 
  116             [ -0.50, 0.0, -0.50 ],
 
  117             [ -0.50, 0.0, -1.00 ], 
 
  118             [ -1.00, 0.0, -1.00 ] ] 
 
  119 state4 = [  [ -1.00, 0.0,  1.00 ],
 
  120             [ -1.00, 0.0,  0.50 ],
 
  121             [ -0.50, 0.0,  0.50 ],
 
  122             [ -0.50, 0.0,  1.00 ], 
 
  123             [ -1.00, 0.0,  1.00 ] ] 
 
  124 arrow1 = [  [  0.00, 0.0,  1.00 ],
 
  126             [ -0.10, 0.0,  0.20 ],
 
  127             [  0.00, 0.0,  1.00 ] ] 
 
  128 arrow2 = [  [  1.00, 0.0,  0.00 ],
 
  130             [  0.20, 0.0, -0.10 ],
 
  131             [  1.00, 0.0,  0.00 ] ] 
 
  132 arrow3 = [  [  0.00, 0.0, -1.00 ],
 
  133             [  0.10, 0.0, -0.20 ],
 
  134             [ -0.10, 0.0, -0.20 ],
 
  135             [  0.00, 0.0, -1.00 ] ] 
 
  136 arrow4 = [  [ -1.00, 0.0,  0.00 ],
 
  137             [ -0.20, 0.0,  0.10 ],
 
  138             [ -0.20, 0.0, -0.10 ],
 
  139             [ -1.00, 0.0,  0.00 ] ] 
 
  140 perimeter=[ [  1.10, 0.0,  1.10 ],
 
  141             [  1.10, 0.0, -1.10 ],
 
  142             [ -1.10, 0.0, -1.10 ],
 
  143             [ -1.10, 0.0,  1.10 ], 
 
  144             [  1.10, 0.0,  1.10 ] ] 
 
  162 class swissArmyLocatorManip(OpenMayaMPx.MPxManipContainer):
 
  164         OpenMayaMPx.MPxManipContainer.__init__(self)
 
  179     def createChildren(self):
 
  181         self.fFreePointTriadManip = self.addFreePointTriadManip(
"freePointTriadManip", 
"point")
 
  185         self.fDirectionManip = self.addDirectionManip(
"directionManip", 
"direction")
 
  189         self.fToggleManip = self.addToggleManip(
"toggleManip", 
"toggle")
 
  193         self.fStateManip = self.addStateManip(
"stateManip", 
"state")
 
  197         self.fDiscManip = self.addDiscManip(
"discManip", 
"angle")
 
  201         self.fCircleSweepManip = self.addCircleSweepManip(
"circleSweepManip", 
"angle")
 
  205         circleSweepManipFn.setRadius(2.0)
 
  206         circleSweepManipFn.setDrawAsArc(
True)
 
  209         self.fDistanceManip = self.addDistanceManip(
"distanceManip", 
"distance")
 
  215         self.fRotateManip = self.addRotateManip(
"RotateManip", 
"rotation")
 
  219         self.fScaleManip = self.addScaleManip(
"scaleManip", 
"scale")
 
  223     def connectToDependNode(self, node):
 
  226         dagNodeFn.getPath(self.fNodePath)
 
  227         parentNode = dagNodeFn.parent(0)
 
  232         nodeFn.setObject(node)   
 
  237             translationPlug = parentNodeFn.findPlug(
"t")
 
  238             freePointTriadManipFn.connectToPointPlug(translationPlug)
 
  244         directionManipFn.setObject(self.fDirectionManip)
 
  246             directionPlug = nodeFn.findPlug(
"arrow2Direction")
 
  247             directionManipFn.connectToDirectionPlug(directionPlug)
 
  248             startPointIndex = directionManipFn.startPointIndex()
 
  249             self.addPlugToManipConversion(startPointIndex)
 
  255         distanceManipFn.setObject(self.fDistanceManip)
 
  257             sizePlug = nodeFn.findPlug(
"size")
 
  258             distanceManipFn.connectToDistancePlug(sizePlug)
 
  259             startPointIndex = distanceManipFn.startPointIndex()
 
  260             self.addPlugToManipConversion(startPointIndex)
 
  267             arrow1AnglePlug = nodeFn.findPlug(
"arrow1Angle")
 
  268             circleSweepManipFn.connectToAnglePlug(arrow1AnglePlug)
 
  269             centerIndex = circleSweepManipFn.centerIndex()
 
  270             self.addPlugToManipConversion(centerIndex)
 
  277             arrow3AnglePlug = nodeFn.findPlug(
"arrow3Angle")
 
  278             discManipFn.connectToAnglePlug(arrow3AnglePlug)
 
  279             centerIndex = discManipFn.centerIndex()
 
  280             self.addPlugToManipConversion(centerIndex)
 
  287             statePlug = nodeFn.findPlug(
"state")
 
  288             stateManipFn.connectToStatePlug(statePlug)
 
  289             positionIndex = stateManipFn.positionIndex()
 
  290             self.addPlugToManipConversion(positionIndex)
 
  297             togglePlug = nodeFn.findPlug(
"toggle")
 
  298             toggleManipFn.connectToTogglePlug(togglePlug)
 
  299             startPointIndex = toggleManipFn.startPointIndex()
 
  300             self.addPlugToManipConversion(startPointIndex)
 
  313             rotatePlug = transformNode.findPlug(
"rotate")
 
  314             rotateManipFn.connectToRotationPlug(rotatePlug)
 
  315             rotateManipFn.displayWithNode(node)
 
  322             scalePlug = transformNode.findPlug(
"scale")
 
  323             scaleManipFn.connectToScalePlug(scalePlug)
 
  324             scaleManipFn.displayWithNode(node)
 
  328         self.finishAddingManips()
 
  329         OpenMayaMPx.MPxManipContainer.connectToDependNode(self, node)
 
  332     def draw(self, view, path, style, status):
 
  333         OpenMayaMPx.MPxManipContainer.draw(self, view, path, style, status)
 
  336         view.drawText(
"Swiss Army Manipulator", textPos, OpenMayaUI.M3dView.kLeft)
 
  340     def plugToManipConversion(self, theIndex):
 
  342         numDataObj = numData.create(OpenMaya.MFnNumericData.k3Float)
 
  343         vec = self.nodeTranslation()
 
  344         numData.setData3Float(vec.x, vec.y, vec.z)
 
  345         manipData = OpenMayaUI.MManipData(numDataObj)
 
  349     def nodeTranslation(self):
 
  355         return transformFn.getTranslation(OpenMaya.MSpace.kWorld)
 
  361 class swissArmyLocator(OpenMayaMPx.MPxLocatorNode):
 
  378         OpenMayaMPx.MPxLocatorNode.__init__(self)
 
  381     def compute(self, plug, data):
 
  382         return OpenMaya.kUnknownParameter
 
  385     def draw(self, view, path, style, status):
 
  388         thisNode = self.thisMObject()
 
  391         sizeVal = plug.asMDistance()
 
  393         arrow1AnglePlug = 
OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow1Angle)
 
  394         arrow1Angle = arrow1AnglePlug.asMAngle()
 
  395         angle1 = -arrow1Angle.asRadians() - 3.1415927/2.0
 
  397         arrow3AnglePlug = 
OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow3Angle)
 
  398         arrow3Angle = arrow3AnglePlug.asMAngle()
 
  399         angle3 = arrow3Angle.asRadians()
 
  402         state = statePlug.asInt()
 
  405         toggle = togglePlug.asBool()
 
  407         directionXPlug = 
OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow2DirectionX)
 
  408         directionYPlug = 
OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow2DirectionY)
 
  409         directionZPlug = 
OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow2DirectionZ)
 
  410         dirX = directionXPlug.asDouble()
 
  411         dirY = directionYPlug.asDouble()
 
  412         dirZ = directionZPlug.asDouble()
 
  414         angle2 = math.atan2(dirZ, dirX)
 
  417         multiplier = sizeVal.asCentimeters()
 
  421         if ((style == OpenMayaUI.M3dView.kFlatShaded) 
or 
  422                 (style == OpenMayaUI.M3dView.kGouraudShaded)):
 
  424             glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
 
  426             if (status == OpenMayaUI.M3dView.kActive):
 
  427                 view.setDrawColor(13, OpenMayaUI.M3dView.kActiveColors)
 
  429                 view.setDrawColor(13, OpenMayaUI.M3dView.kDormantColors)
 
  432                 if (status == OpenMayaUI.M3dView.kActive):
 
  433                     view.setDrawColor(15, OpenMayaUI.M3dView.kActiveColors)
 
  435                     view.setDrawColor(15, OpenMayaUI.M3dView.kDormantColors)
 
  436                 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  437                 last = kCentreCount - 1
 
  438                 for i 
in range(last):
 
  439                     glFT.glVertex3f(centre[i][0] * multiplier,
 
  440                                centre[i][1] * multiplier,
 
  441                                centre[i][2] * multiplier)
 
  445                 if (status == OpenMayaUI.M3dView.kActive):
 
  446                     view.setDrawColor(19, OpenMayaUI.M3dView.kActiveColors)
 
  448                     view.setDrawColor(19, OpenMayaUI.M3dView.kDormantColors)
 
  449                 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  450                 last = kState1Count - 1
 
  451                 for i 
in range(last):
 
  452                     glFT.glVertex3f(state1[i][0] * multiplier,
 
  453                                     state1[i][1] * multiplier,
 
  454                                     state1[i][2] * multiplier)
 
  458                 if (status == OpenMayaUI.M3dView.kActive):
 
  459                     view.setDrawColor(21, OpenMayaUI.M3dView.kActiveColors)
 
  461                     view.setDrawColor(21, OpenMayaUI.M3dView.kDormantColors)
 
  462                 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  463                 last = kState2Count - 1
 
  464                 for i 
in range(last):
 
  465                     glFT.glVertex3f(state2[i][0] * multiplier,
 
  466                                     state2[i][1] * multiplier,
 
  467                                     state2[i][2] * multiplier)
 
  471                 if (status == OpenMayaUI.M3dView.kActive):
 
  472                     view.setDrawColor(18, OpenMayaUI.M3dView.kActiveColors)
 
  474                     view.setDrawColor(18, OpenMayaUI.M3dView.kDormantColors)
 
  475                     glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  476                     last = kState3Count - 1
 
  477                     for i 
in range(last):
 
  478                         glFT.glVertex3f(state3[i][0] * multiplier,
 
  479                                         state3[i][1] * multiplier,
 
  480                                         state3[i][2] * multiplier)
 
  484                 if (status == OpenMayaUI.M3dView.kActive):
 
  485                     view.setDrawColor(17, OpenMayaUI.M3dView.kActiveColors)
 
  487                     view.setDrawColor(17, OpenMayaUI.M3dView.kDormantColors)
 
  488                 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  489                 last = kState4Count - 1
 
  490                 for i 
in range(last):
 
  491                     glFT.glVertex3f(state4[i][0] * multiplier,
 
  492                                     state4[i][1] * multiplier,
 
  493                                     state4[i][2] * multiplier)
 
  496             if (status == OpenMayaUI.M3dView.kActive):
 
  497                 view.setDrawColor(12, OpenMayaUI.M3dView.kActiveColors)
 
  499                 view.setDrawColor(12, OpenMayaUI.M3dView.kDormantColors)
 
  500             glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  501             last = kArrow1Count - 1
 
  502             for i 
in range(last):
 
  503                 glFT.glVertex3f((-arrow1[i][0] * multiplier * math.cos(angle1) - arrow1[i][2] * multiplier * math.sin(angle1)),
 
  504                                 (arrow1[i][1] * multiplier + delta1),
 
  505                                 (arrow1[i][2] * multiplier * math.cos(angle1) - arrow1[i][0] * multiplier * math.sin(angle1)))
 
  508             if (status == OpenMayaUI.M3dView.kActive):
 
  509                 view.setDrawColor(16, OpenMayaUI.M3dView.kActiveColors)
 
  511                 view.setDrawColor(16, OpenMayaUI.M3dView.kDormantColors)
 
  512             glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  513             last = kArrow2Count - 1
 
  514             for i 
in range(last):
 
  515                 glFT.glVertex3f((-arrow2[i][0] * multiplier * math.cos(angle2) - arrow2[i][2] * multiplier * math.sin(angle2)),
 
  516                                 (arrow2[i][1] * multiplier + delta2),
 
  517                                 (arrow2[i][2] * multiplier * math.cos(angle2) - arrow2[i][0] * multiplier * math.sin(angle2)))
 
  520             if (status == OpenMayaUI.M3dView.kActive):
 
  521                 view.setDrawColor(13, OpenMayaUI.M3dView.kActiveColors)
 
  523                 view.setDrawColor(13, OpenMayaUI.M3dView.kDormantColors)
 
  524             glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  525             last = kArrow3Count - 1
 
  526             for i 
in range(last):
 
  527                 glFT.glVertex3f((-arrow3[i][0] * multiplier * math.cos(angle3) - arrow3[i][2] * multiplier * math.sin(angle3)),
 
  528                                 (arrow3[i][1] * multiplier + delta3),
 
  529                                 (arrow3[i][2] * multiplier * math.cos(angle3) - arrow3[i][0] * multiplier * math.sin(angle3)))
 
  532             if (status == OpenMayaUI.M3dView.kActive):
 
  533                 view.setDrawColor(5, OpenMayaUI.M3dView.kActiveColors)
 
  535                 view.setDrawColor(5, OpenMayaUI.M3dView.kDormantColors)
 
  536             glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
 
  537             last = kArrow4Count - 1
 
  538             for i 
in range(last):
 
  539                 glFT.glVertex3f((arrow4[i][0] * multiplier),
 
  540                                 (arrow4[i][1] * multiplier + delta4),
 
  541                                 (arrow4[i][2] * multiplier))
 
  547         glFT.glBegin(OpenMayaRender.MGL_LINES)
 
  550             last = kCentreCount - 1
 
  551             for i 
in range(last): 
 
  552                 glFT.glVertex3f(centre[i][0] * multiplier, 
 
  553                                 centre[i][1] * multiplier, 
 
  554                                 centre[i][2] * multiplier)
 
  555                 glFT.glVertex3f(centre[i+1][0] * multiplier, 
 
  556                                 centre[i+1][1] * multiplier, 
 
  557                                 centre[i+1][2] * multiplier)
 
  560             last = kState1Count - 1
 
  561             for i 
in range(last): 
 
  562                 glFT.glVertex3f(state1[i][0] * multiplier, 
 
  563                                 state1[i][1] * multiplier, 
 
  564                                 state1[i][2] * multiplier)
 
  565                 glFT.glVertex3f(state1[i+1][0] * multiplier, 
 
  566                                 state1[i+1][1] * multiplier, 
 
  567                                 state1[i+1][2] * multiplier)
 
  570             last = kState2Count - 1
 
  571             for i 
in range(last): 
 
  572                 glFT.glVertex3f(state2[i][0] * multiplier, 
 
  573                                 state2[i][1] * multiplier, 
 
  574                                 state2[i][2] * multiplier)
 
  575                 glFT.glVertex3f(state2[i+1][0] * multiplier, 
 
  576                                 state2[i+1][1] * multiplier, 
 
  577                                 state2[i+1][2] * multiplier)
 
  580             last = kState3Count - 1
 
  581             for i 
in range(last): 
 
  582                 glFT.glVertex3f(state3[i][0] * multiplier, 
 
  583                                 state3[i][1] * multiplier, 
 
  584                                 state3[i][2] * multiplier)
 
  585                 glFT.glVertex3f(state3[i+1][0] * multiplier, 
 
  586                                 state3[i+1][1] * multiplier, 
 
  587                                 state3[i+1][2] * multiplier)
 
  590             last = kState4Count - 1
 
  591             for i 
in range(last): 
 
  592                 glFT.glVertex3f(state4[i][0] * multiplier, 
 
  593                                 state4[i][1] * multiplier, 
 
  594                                 state4[i][2] * multiplier)
 
  595                 glFT.glVertex3f(state4[i+1][0] * multiplier, 
 
  596                                 state4[i+1][1] * multiplier, 
 
  597                                 state4[i+1][2] * multiplier)
 
  599         last = kArrow1Count - 1
 
  600         for i 
in range(last): 
 
  601             glFT.glVertex3f((-arrow1[i][0] * multiplier * math.cos(angle1) - arrow1[i][2] * multiplier * math.sin(angle1)),
 
  602                             (arrow1[i][1] * multiplier + delta1),
 
  603                             (arrow1[i][2] * multiplier * math.cos(angle1) - arrow1[i][0] * multiplier * math.sin(angle1)))
 
  604             glFT.glVertex3f((-arrow1[i+1][0] * multiplier * math.cos(angle1) - arrow1[i+1][2] * multiplier * math.sin(angle1)),
 
  605                             (arrow1[i+1][1] * multiplier + delta1),
 
  606                             (arrow1[i+1][2] * multiplier * math.cos(angle1) - arrow1[i+1][0] * multiplier * math.sin(angle1)))
 
  608         last = kArrow2Count - 1
 
  609         for i 
in range(last): 
 
  610             glFT.glVertex3f((-arrow2[i][0] * multiplier * math.cos(angle2) - arrow2[i][2] * multiplier * math.sin(angle2)),
 
  611                             (arrow2[i][1] * multiplier + delta2),
 
  612                             (arrow2[i][2] * multiplier * math.cos(angle2) - arrow2[i][0] * multiplier * math.sin(angle2)))
 
  613             glFT.glVertex3f((-arrow2[i+1][0] * multiplier * math.cos(angle2) - arrow2[i+1][2] * multiplier * math.sin(angle2)),
 
  614                             (arrow2[i+1][1] * multiplier + delta2),
 
  615                             (arrow2[i+1][2] * multiplier * math.cos(angle2) - arrow2[i+1][0] * multiplier * math.sin(angle2)))
 
  617         last = kArrow3Count - 1
 
  618         for i 
in range(last): 
 
  619             glFT.glVertex3f((-arrow3[i][0] * multiplier * math.cos(angle3) - arrow3[i][2] * multiplier * math.sin(angle3)),
 
  620                             (arrow3[i][1] * multiplier + delta3),
 
  621                             (arrow3[i][2] * multiplier * math.cos(angle3) - arrow3[i][0] * multiplier * math.sin(angle3)))
 
  622             glFT.glVertex3f((-arrow3[i+1][0] * multiplier * math.cos(angle3) - arrow3[i+1][2] * multiplier * math.sin(angle3)),
 
  623                             (arrow3[i+1][1] * multiplier + delta3),
 
  624                             (arrow3[i+1][2] * multiplier * math.cos(angle3) - arrow3[i+1][0] * multiplier * math.sin(angle3)))
 
  626         last = kArrow4Count - 1
 
  627         for i 
in range(last): 
 
  628             glFT.glVertex3f((arrow4[i][0] * multiplier),
 
  629                             (arrow4[i][1] * multiplier + delta4),
 
  630                             (arrow4[i][2] * multiplier))
 
  631             glFT.glVertex3f((arrow4[i+1][0] * multiplier),
 
  632                             (arrow4[i+1][1] * multiplier + delta4),
 
  633                             (arrow4[i+1][2] * multiplier))
 
  635         last = kPerimeterCount - 1
 
  636         for i 
in range(last): 
 
  637             glFT.glVertex3f(perimeter[i][0] * multiplier,
 
  638                             perimeter[i][1] * multiplier,
 
  639                             perimeter[i][2] * multiplier)
 
  640             glFT.glVertex3f(perimeter[i+1][0] * multiplier,
 
  641                             perimeter[i+1][1] * multiplier,
 
  642                             perimeter[i+1][2] * multiplier)
 
  653     def boundingBox(self):
 
  654         thisNode = self.thisMObject()
 
  656         sizeVal = plug.asMDistance()
 
  658         multiplier = sizeVal.asCentimeters()
 
  663         corner1 = corner1 * multiplier
 
  664         corner2 = corner2 * multiplier
 
  674 def locatorCreator():
 
  675     return OpenMayaMPx.asMPxPtr(swissArmyLocator())
 
  683     swissArmyLocator.aSize = unitFn.create(
"size", 
"sz", OpenMaya.MFnUnitAttribute.kDistance, 10.0)
 
  684     unitFn.setStorable(
True)
 
  685     unitFn.setWritable(
True)
 
  688     swissArmyLocator.aPointX = numericFn.create(
"pointX", 
"ptx", OpenMaya.MFnNumericData.kDouble, 0.0)
 
  689     swissArmyLocator.aPointY = numericFn.create(
"pointY", 
"pty", OpenMaya.MFnNumericData.kDouble, 0.0)
 
  690     swissArmyLocator.aPointZ = numericFn.create(
"pointZ", 
"ptz", OpenMaya.MFnNumericData.kDouble, 0.0)
 
  691     swissArmyLocator.aPoint = numericFn.create(
"point", 
"pt", swissArmyLocator.aPointX, swissArmyLocator.aPointY, swissArmyLocator.aPointZ)
 
  694     swissArmyLocator.aArrow1Angle = unitFn.create(
"arrow1Angle", 
"a1a", OpenMaya.MFnUnitAttribute.kAngle, 0.0)
 
  697     swissArmyLocator.aArrow2DirectionX = numericFn.create(
"arrow2DirectionX", 
"a2x", OpenMaya.MFnNumericData.kDouble, 1.0)
 
  698     swissArmyLocator.aArrow2DirectionY = numericFn.create(
"arrow2DirectionY", 
"a2y", OpenMaya.MFnNumericData.kDouble, 0.0)
 
  699     swissArmyLocator.aArrow2DirectionZ = numericFn.create(
"arrow2DirectionZ", 
"a2z", OpenMaya.MFnNumericData.kDouble, 0.0)
 
  700     swissArmyLocator.aArrow2Direction = numericFn.create(
"arrow2Direction", 
"dir", swissArmyLocator.aArrow2DirectionX, swissArmyLocator.aArrow2DirectionY, swissArmyLocator.aArrow2DirectionZ)
 
  703     swissArmyLocator.aArrow3Angle = unitFn.create(
"arrow3Angle", 
"a3a", OpenMaya.MFnUnitAttribute.kAngle, 0.0)
 
  705     swissArmyLocator.aArrow4Distance = unitFn.create(
"arrow2Distance", 
"dis", OpenMaya.MFnUnitAttribute.kDistance, 0.0)
 
  708     swissArmyLocator.aState = numericFn.create(
"state", 
"s", OpenMaya.MFnNumericData.kLong, 0)
 
  711     swissArmyLocator.aToggle = numericFn.create(
"toggle", 
"t", OpenMaya.MFnNumericData.kBoolean, 
False)
 
  713     swissArmyLocator.addAttribute(swissArmyLocator.aPoint)
 
  714     swissArmyLocator.addAttribute(swissArmyLocator.aArrow1Angle)
 
  715     swissArmyLocator.addAttribute(swissArmyLocator.aArrow2Direction)
 
  716     swissArmyLocator.addAttribute(swissArmyLocator.aArrow3Angle)
 
  717     swissArmyLocator.addAttribute(swissArmyLocator.aArrow4Distance)
 
  718     swissArmyLocator.addAttribute(swissArmyLocator.aState)
 
  719     swissArmyLocator.addAttribute(swissArmyLocator.aToggle)
 
  720     swissArmyLocator.addAttribute(swissArmyLocator.aSize)
 
  722     OpenMayaMPx.MPxManipContainer.addToManipConnectTable(kSwissArmyLocatorId)
 
  725 def locatorManipCreator():
 
  726      return OpenMayaMPx.asMPxPtr(swissArmyLocatorManip())
 
  729 def locatorManipInit():
 
  730     OpenMayaMPx.MPxManipContainer.initialize()
 
  734 def initializePlugin(mobject):
 
  735     mplugin = OpenMayaMPx.MFnPlugin(mobject, 
"Autodesk", 
"1.0", 
"Any")
 
  738         mplugin.registerNode(kSwissArmyLocatorName, 
 
  742                                 OpenMayaMPx.MPxNode.kLocatorNode)
 
  744         print "Failed to register context command: %s" % kSwissArmyLocatorName
 
  748         mplugin.registerNode(kSwissArmyLocatorManipName, 
 
  749                                 kSwissArmyLocatorManipId, 
 
  752                                 OpenMayaMPx.MPxNode.kManipContainer)
 
  754         print "Failed to register node: %s" % kSwissArmyLocatorManipName
 
  759 def uninitializePlugin(mobject):
 
  760     mplugin = OpenMayaMPx.MFnPlugin(mobject)
 
  763         mplugin.deregisterNode(kSwissArmyLocatorId)
 
  765         print "Failed to deregister context command: %s" % kSwissArmyLocatorName
 
  769         mplugin.deregisterNode(kSwissArmyLocatorManipId)
 
  771         print "Failed to deregister node: %s" % kSwissArmyLocatorManipName