« Autodesk FBX 2013.3 update released | Main | Building Qt, PyQt, PySide for Maya 2013 - Part 1 »

September 30, 2012


Feed You can follow this conversation by subscribing to the comment feed for this post.

Martin Karlsson

I'm extending OpenMayaMPx.MPxLocatorNode. How do I know when the node is selected, please?

Goal is to draw lines with different color when selected.

Cyrille Fauvel

Hi Martin,

We posted a utility (with source code) recently on http://labs.autodesk.com/utilities/ADN_plugins in case you want to see a full sample (LocatorLib utility).

All is done in the draw() method, something like this:

void locatorLibBase::draw (M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) {
view.beginGL () ;
if ( (style == M3dView::kFlatShaded)
|| (style == M3dView::kGouraudShaded)
) {
// Push the color settings
glPushAttrib (GL_CURRENT_BIT) ;
if ( status == M3dView::kActive )
view.setDrawColor (13, M3dView::kActiveColors);
view.setDrawColor (13, M3dView::kDormantColors);
myShadedDraw () ;
glPopAttrib () ;
myWireFrameDraw () ; // Draw the outline of the locator
view.endGL () ;

The ( status == M3dView::kActive ) will tell you if it is selected or not, and like above you decide what colors you want.

Now this is for the legacy viewport. If you also want to support the Maya Viewport 2.0, you need another class and do something similar again. So you would need to derive an additional class from the MHWRender::MPxDrawOverride class and use the draw()' MHWRender::MDrawContext argument.

Hope that helps,

The comments to this entry are closed.

The Authors
Cyrille Fauvel Lanh Hong Cheng Xi Li