67 import maya.OpenMaya
as OpenMaya
68 import maya.OpenMayaUI
as OpenMayaUI
69 import maya.OpenMayaRender
as OpenMayaRender
70 import maya.OpenMayaMPx
as OpenMayaMPx
74 glRenderer = OpenMayaRender.MHardwareRenderer.theRenderer()
75 glFT = glRenderer.glFunctionTable()
77 kSwissArmyLocatorName =
"spSwissArmyLocator"
78 kSwissArmyLocatorId = OpenMaya.MTypeId(0x87006)
79 kSwissArmyLocatorManipName =
"spSwissArmyLocatorManip"
80 kSwissArmyLocatorManipId = OpenMaya.MTypeId(0x87007)
88 centre = [ [ 0.10, 0.0, 0.10 ],
90 [ -0.10, 0.0, -0.10 ],
93 state1 = [ [ 1.00, 0.0, 1.00 ],
98 state2 = [ [ 1.00, 0.0, -1.00 ],
100 [ 0.50, 0.0, -0.50 ],
101 [ 0.50, 0.0, -1.00 ],
102 [ 1.00, 0.0, -1.00 ] ]
103 state3 = [ [ -1.00, 0.0, -1.00 ],
104 [ -1.00, 0.0, -0.50 ],
105 [ -0.50, 0.0, -0.50 ],
106 [ -0.50, 0.0, -1.00 ],
107 [ -1.00, 0.0, -1.00 ] ]
108 state4 = [ [ -1.00, 0.0, 1.00 ],
109 [ -1.00, 0.0, 0.50 ],
110 [ -0.50, 0.0, 0.50 ],
111 [ -0.50, 0.0, 1.00 ],
112 [ -1.00, 0.0, 1.00 ] ]
113 arrow1 = [ [ 0.00, 0.0, 1.00 ],
115 [ -0.10, 0.0, 0.20 ],
116 [ 0.00, 0.0, 1.00 ] ]
117 arrow2 = [ [ 1.00, 0.0, 0.00 ],
119 [ 0.20, 0.0, -0.10 ],
120 [ 1.00, 0.0, 0.00 ] ]
121 arrow3 = [ [ 0.00, 0.0, -1.00 ],
122 [ 0.10, 0.0, -0.20 ],
123 [ -0.10, 0.0, -0.20 ],
124 [ 0.00, 0.0, -1.00 ] ]
125 arrow4 = [ [ -1.00, 0.0, 0.00 ],
126 [ -0.20, 0.0, 0.10 ],
127 [ -0.20, 0.0, -0.10 ],
128 [ -1.00, 0.0, 0.00 ] ]
129 perimeter=[ [ 1.10, 0.0, 1.10 ],
130 [ 1.10, 0.0, -1.10 ],
131 [ -1.10, 0.0, -1.10 ],
132 [ -1.10, 0.0, 1.10 ],
133 [ 1.10, 0.0, 1.10 ] ]
151 class swissArmyLocatorManip(OpenMayaMPx.MPxManipContainer):
153 OpenMayaMPx.MPxManipContainer.__init__(self)
156 self.fCircleSweepManip = OpenMaya.MDagPath()
157 self.fDirectionManip = OpenMaya.MDagPath()
158 self.fDiscManip = OpenMaya.MDagPath()
159 self.fDistanceManip = OpenMaya.MDagPath()
160 self.fFreePointTriadManip = OpenMaya.MDagPath()
161 self.fStateManip = OpenMaya.MDagPath()
162 self.fToggleManip = OpenMaya.MDagPath()
163 self.fRotateManip = OpenMaya.MDagPath()
164 self.fScaleManip = OpenMaya.MDagPath()
165 self.fNodePath = OpenMaya.MDagPath()
168 def createChildren(self):
170 self.fFreePointTriadManip = self.addFreePointTriadManip(
"freePointTriadManip",
"point")
171 freePointTriadManipFn = OpenMayaUI.MFnFreePointTriadManip(self.fFreePointTriadManip)
174 self.fDirectionManip = self.addDirectionManip(
"directionManip",
"direction")
175 directionManipFn = OpenMayaUI.MFnDirectionManip(self.fDirectionManip)
178 self.fToggleManip = self.addToggleManip(
"toggleManip",
"toggle")
179 toggleManipFn = OpenMayaUI.MFnToggleManip(self.fToggleManip)
182 self.fStateManip = self.addStateManip(
"stateManip",
"state")
183 stateManipFn = OpenMayaUI.MFnStateManip(self.fStateManip)
186 self.fDiscManip = self.addDiscManip(
"discManip",
"angle")
187 discManipFn = OpenMayaUI.MFnDiscManip(self.fDiscManip)
190 self.fCircleSweepManip = self.addCircleSweepManip(
"circleSweepManip",
"angle")
191 circleSweepManipFn = OpenMayaUI.MFnCircleSweepManip(self.fCircleSweepManip)
192 circleSweepManipFn.setCenterPoint(OpenMaya.MPoint(0, 0, 0))
193 circleSweepManipFn.setNormal(OpenMaya.MVector(0, 1, 0))
194 circleSweepManipFn.setRadius(2.0)
195 circleSweepManipFn.setDrawAsArc(
True)
198 self.fDistanceManip = self.addDistanceManip(
"distanceManip",
"distance")
199 distanceManipFn = OpenMayaUI.MFnDistanceManip(self.fDistanceManip)
200 distanceManipFn.setStartPoint(OpenMaya.MPoint(0, 0, 0))
201 distanceManipFn.setDirection(OpenMaya.MVector(0, 1, 0))
204 self.fRotateManip = self.addRotateManip(
"RotateManip",
"rotation")
205 rotateManipFn = OpenMayaUI.MFnRotateManip(self.fRotateManip)
208 self.fScaleManip = self.addScaleManip(
"scaleManip",
"scale")
209 scaleManipFn = OpenMayaUI.MFnScaleManip(self.fScaleManip)
212 def connectToDependNode(self, node):
214 dagNodeFn = OpenMaya.MFnDagNode(node)
215 dagNodeFn.getPath(self.fNodePath)
216 parentNode = dagNodeFn.parent(0)
217 parentNodeFn = OpenMaya.MFnDagNode(parentNode)
220 nodeFn = OpenMaya.MFnDependencyNode()
221 nodeFn.setObject(node)
224 freePointTriadManipFn = OpenMayaUI.MFnFreePointTriadManip(self.fFreePointTriadManip)
226 translationPlug = parentNodeFn.findPlug(
"t")
227 freePointTriadManipFn.connectToPointPlug(translationPlug)
232 directionManipFn = OpenMayaUI.MFnDirectionManip()
233 directionManipFn.setObject(self.fDirectionManip)
235 directionPlug = nodeFn.findPlug(
"arrow2Direction")
236 directionManipFn.connectToDirectionPlug(directionPlug)
237 startPointIndex = directionManipFn.startPointIndex()
238 self.addPlugToManipConversion(startPointIndex)
243 distanceManipFn = OpenMayaUI.MFnDistanceManip()
244 distanceManipFn.setObject(self.fDistanceManip)
246 sizePlug = nodeFn.findPlug(
"size")
247 distanceManipFn.connectToDistancePlug(sizePlug)
248 startPointIndex = distanceManipFn.startPointIndex()
249 self.addPlugToManipConversion(startPointIndex)
254 circleSweepManipFn = OpenMayaUI.MFnCircleSweepManip(self.fCircleSweepManip)
256 arrow1AnglePlug = nodeFn.findPlug(
"arrow1Angle")
257 circleSweepManipFn.connectToAnglePlug(arrow1AnglePlug)
258 centerIndex = circleSweepManipFn.centerIndex()
259 self.addPlugToManipConversion(centerIndex)
264 discManipFn = OpenMayaUI.MFnDiscManip(self.fDiscManip)
266 arrow3AnglePlug = nodeFn.findPlug(
"arrow3Angle")
267 discManipFn.connectToAnglePlug(arrow3AnglePlug)
268 centerIndex = discManipFn.centerIndex()
269 self.addPlugToManipConversion(centerIndex)
274 stateManipFn = OpenMayaUI.MFnStateManip(self.fStateManip)
276 statePlug = nodeFn.findPlug(
"state")
277 stateManipFn.connectToStatePlug(statePlug)
278 positionIndex = stateManipFn.positionIndex()
279 self.addPlugToManipConversion(positionIndex)
284 toggleManipFn = OpenMayaUI.MFnToggleManip(self.fToggleManip)
286 togglePlug = nodeFn.findPlug(
"toggle")
287 toggleManipFn.connectToTogglePlug(togglePlug)
288 startPointIndex = toggleManipFn.startPointIndex()
289 self.addPlugToManipConversion(startPointIndex)
294 transformPath = OpenMaya.MDagPath(self.fNodePath)
297 transformNode = OpenMaya.MFnTransform(transformPath)
300 rotateManipFn = OpenMayaUI.MFnRotateManip(self.fRotateManip)
302 rotatePlug = transformNode.findPlug(
"rotate")
303 rotateManipFn.connectToRotationPlug(rotatePlug)
304 rotateManipFn.displayWithNode(node)
309 scaleManipFn = OpenMayaUI.MFnScaleManip(self.fScaleManip)
311 scalePlug = transformNode.findPlug(
"scale")
312 scaleManipFn.connectToScalePlug(scalePlug)
313 scaleManipFn.displayWithNode(node)
317 self.finishAddingManips()
318 OpenMayaMPx.MPxManipContainer.connectToDependNode(self, node)
321 def draw(self, view, path, style, status):
322 OpenMayaMPx.MPxManipContainer.draw(self, view, path, style, status)
324 textPos = OpenMaya.MPoint(self.nodeTranslation())
325 view.drawText(
"Swiss Army Manipulator", textPos, OpenMayaUI.M3dView.kLeft)
329 def plugToManipConversion(self, theIndex):
330 numData = OpenMaya.MFnNumericData()
331 numDataObj = numData.create(OpenMaya.MFnNumericData.k3Float)
332 vec = self.nodeTranslation()
333 numData.setData3Float(vec.x, vec.y, vec.z)
334 manipData = OpenMayaUI.MManipData(numDataObj)
338 def nodeTranslation(self):
339 dagFn = OpenMaya.MFnDagNode(self.fNodePath)
340 path = OpenMaya.MDagPath()
343 transformFn = OpenMaya.MFnTransform(path)
344 return transformFn.getTranslation(OpenMaya.MSpace.kWorld)
350 class swissArmyLocator(OpenMayaMPx.MPxLocatorNode):
351 aSize = OpenMaya.MObject()
352 aPoint = OpenMaya.MObject()
353 aPointX = OpenMaya.MObject()
354 aPointY = OpenMaya.MObject()
355 aPointZ = OpenMaya.MObject()
356 aArrow1Angle = OpenMaya.MObject()
357 aArrow2Direction = OpenMaya.MObject()
358 aArrow2DirectionX = OpenMaya.MObject()
359 aArrow2DirectionY = OpenMaya.MObject()
360 aArrow2DirectionZ = OpenMaya.MObject()
361 aArrow3Angle = OpenMaya.MObject()
362 aArrow4Distance = OpenMaya.MObject()
363 aState = OpenMaya.MObject()
364 aToggle = OpenMaya.MObject()
367 OpenMayaMPx.MPxLocatorNode.__init__(self)
370 def compute(self, plug, data):
371 return OpenMaya.kUnknownParameter
374 def draw(self, view, path, style, status):
377 thisNode = self.thisMObject()
379 plug = OpenMaya.MPlug(thisNode, swissArmyLocator.aSize)
380 sizeVal = plug.asMDistance()
382 arrow1AnglePlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow1Angle)
383 arrow1Angle = arrow1AnglePlug.asMAngle()
384 angle1 = -arrow1Angle.asRadians() - 3.1415927/2.0
386 arrow3AnglePlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow3Angle)
387 arrow3Angle = arrow3AnglePlug.asMAngle()
388 angle3 = arrow3Angle.asRadians()
390 statePlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aState)
391 state = statePlug.asInt()
393 togglePlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aToggle)
394 toggle = togglePlug.asBool()
396 directionXPlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow2DirectionX)
397 directionYPlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow2DirectionY)
398 directionZPlug = OpenMaya.MPlug(thisNode, swissArmyLocator.aArrow2DirectionZ)
399 dirX = directionXPlug.asDouble()
400 dirY = directionYPlug.asDouble()
401 dirZ = directionZPlug.asDouble()
403 angle2 = math.atan2(dirZ, dirX)
406 multiplier = sizeVal.asCentimeters()
410 if ((style == OpenMayaUI.M3dView.kFlatShaded)
or
411 (style == OpenMayaUI.M3dView.kGouraudShaded)):
413 glFT.glPushAttrib(OpenMayaRender.MGL_CURRENT_BIT)
415 if (status == OpenMayaUI.M3dView.kActive):
416 view.setDrawColor(13, OpenMayaUI.M3dView.kActiveColors)
418 view.setDrawColor(13, OpenMayaUI.M3dView.kDormantColors)
421 if (status == OpenMayaUI.M3dView.kActive):
422 view.setDrawColor(15, OpenMayaUI.M3dView.kActiveColors)
424 view.setDrawColor(15, OpenMayaUI.M3dView.kDormantColors)
425 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
426 last = kCentreCount - 1
427 for i
in range(last):
428 glFT.glVertex3f(centre[i][0] * multiplier,
429 centre[i][1] * multiplier,
430 centre[i][2] * multiplier)
434 if (status == OpenMayaUI.M3dView.kActive):
435 view.setDrawColor(19, OpenMayaUI.M3dView.kActiveColors)
437 view.setDrawColor(19, OpenMayaUI.M3dView.kDormantColors)
438 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
439 last = kState1Count - 1
440 for i
in range(last):
441 glFT.glVertex3f(state1[i][0] * multiplier,
442 state1[i][1] * multiplier,
443 state1[i][2] * multiplier)
447 if (status == OpenMayaUI.M3dView.kActive):
448 view.setDrawColor(21, OpenMayaUI.M3dView.kActiveColors)
450 view.setDrawColor(21, OpenMayaUI.M3dView.kDormantColors)
451 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
452 last = kState2Count - 1
453 for i
in range(last):
454 glFT.glVertex3f(state2[i][0] * multiplier,
455 state2[i][1] * multiplier,
456 state2[i][2] * multiplier)
460 if (status == OpenMayaUI.M3dView.kActive):
461 view.setDrawColor(18, OpenMayaUI.M3dView.kActiveColors)
463 view.setDrawColor(18, OpenMayaUI.M3dView.kDormantColors)
464 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
465 last = kState3Count - 1
466 for i
in range(last):
467 glFT.glVertex3f(state3[i][0] * multiplier,
468 state3[i][1] * multiplier,
469 state3[i][2] * multiplier)
473 if (status == OpenMayaUI.M3dView.kActive):
474 view.setDrawColor(17, OpenMayaUI.M3dView.kActiveColors)
476 view.setDrawColor(17, OpenMayaUI.M3dView.kDormantColors)
477 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
478 last = kState4Count - 1
479 for i
in range(last):
480 glFT.glVertex3f(state4[i][0] * multiplier,
481 state4[i][1] * multiplier,
482 state4[i][2] * multiplier)
485 if (status == OpenMayaUI.M3dView.kActive):
486 view.setDrawColor(12, OpenMayaUI.M3dView.kActiveColors)
488 view.setDrawColor(12, OpenMayaUI.M3dView.kDormantColors)
489 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
490 last = kArrow1Count - 1
491 for i
in range(last):
492 glFT.glVertex3f((-arrow1[i][0] * multiplier * math.cos(angle1) - arrow1[i][2] * multiplier * math.sin(angle1)),
493 (arrow1[i][1] * multiplier + delta1),
494 (arrow1[i][2] * multiplier * math.cos(angle1) - arrow1[i][0] * multiplier * math.sin(angle1)))
497 if (status == OpenMayaUI.M3dView.kActive):
498 view.setDrawColor(16, OpenMayaUI.M3dView.kActiveColors)
500 view.setDrawColor(16, OpenMayaUI.M3dView.kDormantColors)
501 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
502 last = kArrow2Count - 1
503 for i
in range(last):
504 glFT.glVertex3f((-arrow2[i][0] * multiplier * math.cos(angle2) - arrow2[i][2] * multiplier * math.sin(angle2)),
505 (arrow2[i][1] * multiplier + delta2),
506 (arrow2[i][2] * multiplier * math.cos(angle2) - arrow2[i][0] * multiplier * math.sin(angle2)))
509 if (status == OpenMayaUI.M3dView.kActive):
510 view.setDrawColor(13, OpenMayaUI.M3dView.kActiveColors)
512 view.setDrawColor(13, OpenMayaUI.M3dView.kDormantColors)
513 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
514 last = kArrow3Count - 1
515 for i
in range(last):
516 glFT.glVertex3f((-arrow3[i][0] * multiplier * math.cos(angle3) - arrow3[i][2] * multiplier * math.sin(angle3)),
517 (arrow3[i][1] * multiplier + delta3),
518 (arrow3[i][2] * multiplier * math.cos(angle3) - arrow3[i][0] * multiplier * math.sin(angle3)))
521 if (status == OpenMayaUI.M3dView.kActive):
522 view.setDrawColor(5, OpenMayaUI.M3dView.kActiveColors)
524 view.setDrawColor(5, OpenMayaUI.M3dView.kDormantColors)
525 glFT.glBegin(OpenMayaRender.MGL_TRIANGLE_FAN)
526 last = kArrow4Count - 1
527 for i
in range(last):
528 glFT.glVertex3f((arrow4[i][0] * multiplier),
529 (arrow4[i][1] * multiplier + delta4),
530 (arrow4[i][2] * multiplier))
536 glFT.glBegin(OpenMayaRender.MGL_LINES)
539 last = kCentreCount - 1
540 for i
in range(last):
541 glFT.glVertex3f(centre[i][0] * multiplier,
542 centre[i][1] * multiplier,
543 centre[i][2] * multiplier)
544 glFT.glVertex3f(centre[i+1][0] * multiplier,
545 centre[i+1][1] * multiplier,
546 centre[i+1][2] * multiplier)
549 last = kState1Count - 1
550 for i
in range(last):
551 glFT.glVertex3f(state1[i][0] * multiplier,
552 state1[i][1] * multiplier,
553 state1[i][2] * multiplier)
554 glFT.glVertex3f(state1[i+1][0] * multiplier,
555 state1[i+1][1] * multiplier,
556 state1[i+1][2] * multiplier)
559 last = kState2Count - 1
560 for i
in range(last):
561 glFT.glVertex3f(state2[i][0] * multiplier,
562 state2[i][1] * multiplier,
563 state2[i][2] * multiplier)
564 glFT.glVertex3f(state2[i+1][0] * multiplier,
565 state2[i+1][1] * multiplier,
566 state2[i+1][2] * multiplier)
569 last = kState3Count - 1
570 for i
in range(last):
571 glFT.glVertex3f(state3[i][0] * multiplier,
572 state3[i][1] * multiplier,
573 state3[i][2] * multiplier)
574 glFT.glVertex3f(state3[i+1][0] * multiplier,
575 state3[i+1][1] * multiplier,
576 state3[i+1][2] * multiplier)
579 last = kState4Count - 1
580 for i
in range(last):
581 glFT.glVertex3f(state4[i][0] * multiplier,
582 state4[i][1] * multiplier,
583 state4[i][2] * multiplier)
584 glFT.glVertex3f(state4[i+1][0] * multiplier,
585 state4[i+1][1] * multiplier,
586 state4[i+1][2] * multiplier)
588 last = kArrow1Count - 1
589 for i
in range(last):
590 glFT.glVertex3f((-arrow1[i][0] * multiplier * math.cos(angle1) - arrow1[i][2] * multiplier * math.sin(angle1)),
591 (arrow1[i][1] * multiplier + delta1),
592 (arrow1[i][2] * multiplier * math.cos(angle1) - arrow1[i][0] * multiplier * math.sin(angle1)))
593 glFT.glVertex3f((-arrow1[i+1][0] * multiplier * math.cos(angle1) - arrow1[i+1][2] * multiplier * math.sin(angle1)),
594 (arrow1[i+1][1] * multiplier + delta1),
595 (arrow1[i+1][2] * multiplier * math.cos(angle1) - arrow1[i+1][0] * multiplier * math.sin(angle1)))
597 last = kArrow2Count - 1
598 for i
in range(last):
599 glFT.glVertex3f((-arrow2[i][0] * multiplier * math.cos(angle2) - arrow2[i][2] * multiplier * math.sin(angle2)),
600 (arrow2[i][1] * multiplier + delta2),
601 (arrow2[i][2] * multiplier * math.cos(angle2) - arrow2[i][0] * multiplier * math.sin(angle2)))
602 glFT.glVertex3f((-arrow2[i+1][0] * multiplier * math.cos(angle2) - arrow2[i+1][2] * multiplier * math.sin(angle2)),
603 (arrow2[i+1][1] * multiplier + delta2),
604 (arrow2[i+1][2] * multiplier * math.cos(angle2) - arrow2[i+1][0] * multiplier * math.sin(angle2)))
606 last = kArrow3Count - 1
607 for i
in range(last):
608 glFT.glVertex3f((-arrow3[i][0] * multiplier * math.cos(angle3) - arrow3[i][2] * multiplier * math.sin(angle3)),
609 (arrow3[i][1] * multiplier + delta3),
610 (arrow3[i][2] * multiplier * math.cos(angle3) - arrow3[i][0] * multiplier * math.sin(angle3)))
611 glFT.glVertex3f((-arrow3[i+1][0] * multiplier * math.cos(angle3) - arrow3[i+1][2] * multiplier * math.sin(angle3)),
612 (arrow3[i+1][1] * multiplier + delta3),
613 (arrow3[i+1][2] * multiplier * math.cos(angle3) - arrow3[i+1][0] * multiplier * math.sin(angle3)))
615 last = kArrow4Count - 1
616 for i
in range(last):
617 glFT.glVertex3f((arrow4[i][0] * multiplier),
618 (arrow4[i][1] * multiplier + delta4),
619 (arrow4[i][2] * multiplier))
620 glFT.glVertex3f((arrow4[i+1][0] * multiplier),
621 (arrow4[i+1][1] * multiplier + delta4),
622 (arrow4[i+1][2] * multiplier))
624 last = kPerimeterCount - 1
625 for i
in range(last):
626 glFT.glVertex3f(perimeter[i][0] * multiplier,
627 perimeter[i][1] * multiplier,
628 perimeter[i][2] * multiplier)
629 glFT.glVertex3f(perimeter[i+1][0] * multiplier,
630 perimeter[i+1][1] * multiplier,
631 perimeter[i+1][2] * multiplier)
642 def boundingBox(self):
643 thisNode = self.thisMObject()
644 plug = OpenMaya.MPlug(thisNode, swissArmyLocator.aSize)
645 sizeVal = plug.asMDistance()
647 multiplier = sizeVal.asCentimeters()
649 corner1 = OpenMaya.MPoint(-1.1, 0.0, -1.1)
650 corner2 = OpenMaya.MPoint(1.1, 0.0, 1.1)
652 corner1 = corner1 * multiplier
653 corner2 = corner2 * multiplier
655 return OpenMaya.MBoundingBox(corner1, corner2)
663 def locatorCreator():
664 return OpenMayaMPx.asMPxPtr(swissArmyLocator())
668 unitFn = OpenMaya.MFnUnitAttribute()
669 numericFn = OpenMaya.MFnNumericAttribute()
672 swissArmyLocator.aSize = unitFn.create(
"size",
"sz", OpenMaya.MFnUnitAttribute.kDistance, 10.0)
673 unitFn.setStorable(
True)
674 unitFn.setWritable(
True)
677 swissArmyLocator.aPointX = numericFn.create(
"pointX",
"ptx", OpenMaya.MFnNumericData.kDouble, 0.0)
678 swissArmyLocator.aPointY = numericFn.create(
"pointY",
"pty", OpenMaya.MFnNumericData.kDouble, 0.0)
679 swissArmyLocator.aPointZ = numericFn.create(
"pointZ",
"ptz", OpenMaya.MFnNumericData.kDouble, 0.0)
680 swissArmyLocator.aPoint = numericFn.create(
"point",
"pt", swissArmyLocator.aPointX, swissArmyLocator.aPointY, swissArmyLocator.aPointZ)
683 swissArmyLocator.aArrow1Angle = unitFn.create(
"arrow1Angle",
"a1a", OpenMaya.MFnUnitAttribute.kAngle, 0.0)
686 swissArmyLocator.aArrow2DirectionX = numericFn.create(
"arrow2DirectionX",
"a2x", OpenMaya.MFnNumericData.kDouble, 1.0)
687 swissArmyLocator.aArrow2DirectionY = numericFn.create(
"arrow2DirectionY",
"a2y", OpenMaya.MFnNumericData.kDouble, 0.0)
688 swissArmyLocator.aArrow2DirectionZ = numericFn.create(
"arrow2DirectionZ",
"a2z", OpenMaya.MFnNumericData.kDouble, 0.0)
689 swissArmyLocator.aArrow2Direction = numericFn.create(
"arrow2Direction",
"dir", swissArmyLocator.aArrow2DirectionX, swissArmyLocator.aArrow2DirectionY, swissArmyLocator.aArrow2DirectionZ)
692 swissArmyLocator.aArrow3Angle = unitFn.create(
"arrow3Angle",
"a3a", OpenMaya.MFnUnitAttribute.kAngle, 0.0)
694 swissArmyLocator.aArrow4Distance = unitFn.create(
"arrow2Distance",
"dis", OpenMaya.MFnUnitAttribute.kDistance, 0.0)
697 swissArmyLocator.aState = numericFn.create(
"state",
"s", OpenMaya.MFnNumericData.kLong, 0)
700 swissArmyLocator.aToggle = numericFn.create(
"toggle",
"t", OpenMaya.MFnNumericData.kBoolean,
False)
702 swissArmyLocator.addAttribute(swissArmyLocator.aPoint)
703 swissArmyLocator.addAttribute(swissArmyLocator.aArrow1Angle)
704 swissArmyLocator.addAttribute(swissArmyLocator.aArrow2Direction)
705 swissArmyLocator.addAttribute(swissArmyLocator.aArrow3Angle)
706 swissArmyLocator.addAttribute(swissArmyLocator.aArrow4Distance)
707 swissArmyLocator.addAttribute(swissArmyLocator.aState)
708 swissArmyLocator.addAttribute(swissArmyLocator.aToggle)
709 swissArmyLocator.addAttribute(swissArmyLocator.aSize)
711 OpenMayaMPx.MPxManipContainer.addToManipConnectTable(kSwissArmyLocatorId)
714 def locatorManipCreator():
715 return OpenMayaMPx.asMPxPtr(swissArmyLocatorManip())
718 def locatorManipInit():
719 OpenMayaMPx.MPxManipContainer.initialize()
723 def initializePlugin(mobject):
724 mplugin = OpenMayaMPx.MFnPlugin(mobject,
"Autodesk",
"1.0",
"Any")
727 mplugin.registerNode(kSwissArmyLocatorName,
731 OpenMayaMPx.MPxNode.kLocatorNode)
733 print "Failed to register context command: %s" % kSwissArmyLocatorName
737 mplugin.registerNode(kSwissArmyLocatorManipName,
738 kSwissArmyLocatorManipId,
741 OpenMayaMPx.MPxNode.kManipContainer)
743 print "Failed to register node: %s" % kSwissArmyLocatorManipName
748 def uninitializePlugin(mobject):
749 mplugin = OpenMayaMPx.MFnPlugin(mobject)
752 mplugin.deregisterNode(kSwissArmyLocatorId)
754 print "Failed to deregister context command: %s" % kSwissArmyLocatorName
758 mplugin.deregisterNode(kSwissArmyLocatorManipId)
760 print "Failed to deregister node: %s" % kSwissArmyLocatorManipName