PDA

View Full Version : [C++]: Get mouse position and draw around it


Inos
12-25-2010, 02:57 PM
Hello everyone,

I need to draw a circle that follows the mouse cursor in the view. I suppose it can't just be done as a cursor itself, because I need to be able to change the circle's radius through the UI.
The first thing, of course, is to find a way to get the mouse coordinates whenever it moves. I've searched the web, and found some thread in which they say the code needs to be inserted between the operating system and maya in order to catch the mouse move events, but I don't want to do that.
I've seen the solution in which the context creates a temporary transform node, whose coordinates are changed by moving the mouse around. Does anyone have an idea as to how this could be implemented? Any help is appreciated.

Cheers,
Inos

Inos
01-04-2011, 04:44 PM
Could it be that the transform node's translate attributes are affected by mouse position, and just never set as clean, thus causing constant recalculation? Still, where to put the code for drawing the circle?

Thanks in advance.
Inos

RyanT
01-04-2011, 08:43 PM
This example from Autodesk does part of what your asking for:

http://download.autodesk.com/us/maya/2011help/API/marquee_tool_8cpp-example.html#_a8

You can get the mouse position within a active viewport by using MEvent.getPosition() inside of a context like MPxContext or MPxSelectionContext. However this is based on a event like drag, press, release. There must be another context or function somewhere that allows you to keep checking for whats going on under the cursor because Maya's paint skin weights context only turns on the manipulator when the cursor is over the paintable mesh.

CGTalk Moderation
01-04-2011, 08:43 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.