Question About Custom Loacator Plug-in in Maya API (C++)

I’m pretty noob to Maya and working with the Maya API.

I created a simple custom plugin locator for use as a hard-point node in our new Maya pipeline. (I override the draw() function and draw some custom geometry for the representation in the Maya viewport.)

The plugin works but I have a problem in that after a “createNode HardPointNode” command is issued, I cannot select the custom node in the viewport until I go to the parent transform of the newly created hard-point node and in the attribute editor under ‘Display’, enable “Display Handle” - at which point a little ‘+’ appears at the origin allowing me to select the node in the viewport.

I would like to do this automatically in the HardPointNode::postConstructor() but am having problems googling/figuring out how to do so. I think I need to get the parent of the new node’s DAGpath which would be the transform (?) but creating a DAG function set in the postConstructor() with “MFnDagPath nodeDpath(this);” doesn’t work/compile :?:

Any suggestions?

Marc

It sounds like you subclassed MPxNode instead of MPxLocatorNode. The former will only create a transform and doesn’t really hae any real visual representation. The LocatorNode is a shape and will actually draw. If this is incorrect and you have in fact subclassed MPxLocatorNode, the draw() override will only work in the legacy viewport (opengl). In order for this to work in viewport 2.0 (directx) you’ll have to do a little extra work. see below for a complete example:
http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__cpp_ref_rawfoot_print_node_2rawfoot_print_node_8cpp_example_html

[QUOTE=TheMaxx;28640]If this is incorrect and you have in fact subclassed MPxLocatorNode, the draw() override will only work in the legacy viewport (opengl). In order for this to work in viewport 2.0 (directx) you’ll have to do a little extra work. see below for a complete example:
http://help.autodesk.com/view/MAYAUL/2015/ENU/?guid=__cpp_ref_rawfoot_print_node_2rawfoot_print_node_8cpp_example_html[/QUOTE]

Yes, I have to switch to legacy in order to see my custom shape. Thanks for the link on how to get it to work for viewport 2.0. Does this have anything to do with my inability to select my MPxLocatorNode derived class or is this a separate issue?

Thank you so much for your help!!

Marc

thats usually a bounding box issue. i cant recall if your in the wrong renderer if you can select at all. Does the viewport 2 drawOverride have a bounding box override? if so, then i’d assume they are called differently depending on the renderer

Not sure if its related, but i noticed that if I implimented a draw for VP2.0 but completely ignored the legacy viewport drawing selection wouldnt work when in Viewport 2. I found this a little odd as i expected selection to be based on the VP2 drawing when in VP2. However it appeared that it always uses the legacy drawing for selection purposes.

I believe the bounding box is not used for selection directly - its used for draw culling etc.