Happy to see it coming in handy xD Not sure how you found it though, maybe Google?
I can’t help you with MPxLocatorNode::draw
other than to say “don’t use it”. That’s Legacy Viewport stuff.
If you absolutely have to use it - some are still stuck on Legacy Viewport unfortunately - then read no further as this only applies to Viewport 2.
MPxDrawOverride
for your MPxLocatorNode
addUIDrawables
MUIDrawManager
for your debug drawThe draw manager has a fantastic and simple API for drawing the basic stuff you need for debugging, like lines, spheres, HUD elements, you name it.
Just look at this API, it’s great. Especially compared to drawing with barebones OpenGL.
MColor red(1.0f, 0.0f, 0.0f);
painter.beginDrawable();
painter.setColor( red );
painter.line( MPoint(0, 0, 0), MPoint(1, 1, 1) );
painter.line( MPoint(0, 0, 0), MPoint(-1, -1, 5) );
painter.endDrawable();
With this, your the addUIDrawables
function is called under 3 conditions.
You can tell it to always be dirty, in which case it’ll update alongside any update to the viewport. See isAlwaysDirty
Without that, you can tell it to be dirty from within itself or another node, by calling:
MHWRender::MRenderer::setGeometryDrawDirty(thisMObject());
This should be what you’re looking for. Ideally it would happen in your MPxLocatorNode::compute
, whereby your locator has an attribute that is affected by your deformer. E.g. MyDeformer::deformed -> MyLocator::wasDeformed
. Then your deformed could just MPlug::setBool()
on that attribute, and your locator would oblige.
Side question, is it a good approach to link 2 nodes, with one for debugging ? It sounds clean and maya-friendly to me, but I’d be curious to know if there are other valid approaches?
Totally reasonable. Draw nodes for drawing things, deform nodes for deforming things. You’d normally wrap these up in a command that creates, names and connects these as appropriate. Also mark one of the nodes as automatically deleted once the connections between them is removed.
--
You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python_inside_m...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/9be7e4ae-1108-4f8e-901d-ad2d7e591010n%40googlegroups.com.
Remembered there was another question at the end of your last message, have a look at existWithoutInConnections
.
Best,
Marcus
To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/30b690d3-7d2a-4907-a9c0-40b8ebaec12en%40googlegroups.com.