Locator Node viewport 2.0 question

python
maya

#1

Good day all,

I have been writing a simple locator node that looks like the normal x,y,z manipulators that you see using the Maya API 2.0.

One problem that I am having is that when I select it, you can’t really see if it has been selected or not. Which brings me to my question. I know that it has to do with the kActive, kLead and so on, which I can do when setting one overall color to the locator. But as you can see in the picture above, I have three colors set. Has anyone come right with something like this?

This is the implementation what I have found online so far for the state:

state = OpenMayaRender.MGeometryUtilities.displayStatus(objPath)
if state & OpenMayaRender.MGeometryUtilities.kActive:
       color= OpenMaya.MColor((1.0, 1.0, 1.0))

       data.color=color

else:
    data.color = OpenMayaRender.MGeometryUtilities.wireframeColor(objPath)

This is how I am drawing and setting the colors:

drawManager.setColor(x_axis_color)
drawManager.setLineWidth(line_width)
drawManager.line(origin_point, x_point * data.draw)

If anyone has any suggestions on this, I would really appreciate any help.

I look forward hearing your responses. Thanks!


#2

I’m not 100% sure how to do this, but did a little research and saw this:

import maya.OpenMayaUI as OpenMayaUI # on top
if status == OpenMayaUI.M3dView.kLead:
	glFT.glColor4f(1, 0, 0, 0.3)	#rouge
if status == OpenMayaUI.M3dView.kActive:
	glFT.glColor4f(1, 1, 0, 0.4)	#jaune
if status == OpenMayaUI.M3dView.kDormant:
	glFT.glColor4f(1, 0, 1, 0.5)	#mauve

From this site:
http://www.fevrierdorian.com/blog/post/2010/02/12/Creating-custom-locator-with-Maya-s-Python-API


#3

Thank you for the response @RiggerRyan, so this is for the Maya API version 1.0 basically for the legacy viewport opengl. I have done this in the past and works perfectly. That’s were I am running into a problem currently, with the “newer” API 2.0 they have changed almost the whole procedure of creating a custom locator node.


#4

Oh snap, I see your issue. It’s been a while since I used the API stuff. Wish I could be more helpful, but I’ll come back if I find anything :slight_smile:


#5

I really appreciate you taking the time! And please, if you do find anything I’d be happy to hear what you have got. :slight_smile: