Dec 2010
1 / 5
Dec 2010
Dec 2010

hello!

I'm new to Maya and Maya's API and I find it very difficult to start.
I would appreciate if anyone colud give me brief idea, how to create a drawing plugin?
What class/method should I use?

Let's say i want to draw my logo in viewport (using for example M3deview::drawText(...) ). I want to redraw this logo every time user change something in vieport (for example camera's settings). Can I catch "something changed" event somehow, and add my piece of code there?

best regards
S.

  • created

    Dec '10
  • last reply

    Dec '10
  • 4

    replies

  • 2.3k

    views

  • 1

    user

  • 1

    link

Hello Stachu!

I'm trying to learn the Maya API as well.  In fact, I was thinking about looking at open gl tonight by following some of the examples Rob Bateman put up.  Does this help at all with what you're trying to do?
5http://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mayaapi.html#25 

As for getting things to update when an attribute changed, I imagine you could connect a camera's settings to an attribute on the node you're trying to make.  It should cause the dg to update your node.  Possibly it would need an attributeAffects() set on something as well.  I bet you could also do this with a script job, but I think just connecting the attribute would be a much better solution. 

What class/method should I use?

MPxImagePlane, MPxSurfaceShape + MPxSurfaceShapeUI, MPxLocatorNode or in maya 2011 you may want to use QT. Alternatively you want to use a headsup display node.*

Can I catch "something changed" event somehow, and add my piece of code there?

well err yes but thats exavctly the way you should avoid thinking. Mayas designed to only do the absolutely minimum neccesery work. So your actually supposed to use connections to resolve your update needs in genral, otherwise you end up updating a LOT EXTRA.

connect a camera's settings to an attribute on the node you're trying to make. 

Well yes except that maya does not work that way. maya evaluetes things in reverse so just having a node connected to a attribute helps nothing, it must ALSO be or be connected to a node that participates in updating to evaluate -> basically a shape, so i would really use a MPxLocatorNode.

Reason is that maya does not update because a value is changed, but rether because something downsteram detects the need of evalueating your node.

  • toygh i would consider really HARD the actual need to do this in the api, because the api is very unconductive when you do something you do not understand fully. And quite frankly you can draw your logo and text without teh api much more easily with much less work.

thank you for your anserws.

I tried

MPxImagePlane, MPxSurfaceShape + MPxSurfaceShapeUI, MPxLocatorNode
and it is great, because Maya takes care of refreshing vieport for it's nodes.But what if I would like to draw sometking like a XYZ "cross" in lower left corner of the viewport?
I managed how to draw something using M3dview::beginOverlayDrawing(), but what is wise method to refresh this drawing?

you may want to use QT.
Can You explain, what drawing methods Qt provides?

best regards
S

and it is great, because Maya takes care of refreshing vieport for it's nodes.
But what if I would like to draw sometking like a XYZ "cross" in lower left corner of the viewport?

Why would that make any difference? Just because its a node does not mean it can not do whatever you like during the refresh or be visible in whatever viewport you like only etc.

I see no reason (and i have tested this before) why you cant do this same drwaing within a shape node. The M3dView class is needed for you to draw stuff anyways.

but what is wise method to refresh this drawing?

Its a overlay it dont need to be refreshed in this way. Its not actually meant for overly presitent data anyhow. So no its not very wise to refresh it.

But if you must theres events for this stuff in MUiMessage such as MUiMessage::add3dViewPostRenderMsgCallback see the api example lensDistortionCallback

Be a bit carefull when you draw to overlays tough, since most consumer grad egraphics cards do NOT work right when drawing on the ovrelay. Which would mean that it wouldnt work out right on anything but nvidida quadros or ati fire GL cards anyway.

Can You explain, what drawing methods Qt provides?

About a few thousand I havent got time to read manuals for you, read the docs yourself first.

Anyway looks to me that you want to use:

Suggested Topics

Want to read more? Browse other topics in Maya or view latest topics.