Custom context while not having to reimplement manipulators from the ground up?

Custom context while not having to reimplement manipulators from the ground up?

143110913
Enthusiast Enthusiast
770 Views
1 Reply
Message 1 of 2

Custom context while not having to reimplement manipulators from the ground up?

143110913
Enthusiast
Enthusiast

I am working on a custom context that has a mode similar to the face/vertex selection, if the user hovers the mouse over the shape it will highlight specific groups of faces (depending on where the mouse is on the shape), the issue is that once those faces are selected, I'd like to use the maya built-in manipulators (or reimplement my own) to interact with those faces.

 

Here is my thought process so far:

 

- If I'd like to use the built-in ones such as the translate manipulator:

As soon as I enter another maya manipulator, maya will exit my custom context and I'll lose my custom hover view. (Makes sense as the translate manip is another context)

 

-If I use MFnFreePointTriadManip in conjunction with MPxManipContainer 

I can't use MPxToolCommand to get a delta from the mouse events, doPress and doRelease and invoke a move command that works relative to each object affected by the manipulator. So I can't use if for multiple objects (among other limiations)

This is due to MPxSelectionContext mouse events not firing up when a manipulator is being used and MPxManipContainer doPress and doRelease don't get passed any M3dView object.

 

Only solution I can think of so far:

I am assuming the only way would be to implement the move manipulator from the ground up by using a MPxManipulatorNode but it feels like a lot of work when I just need to extend the drawing functionality while using the vanilla manipulators.

 

- Is there another way to draw to the viewport from the API that lets me interact with the built-in manipulators? 

 

- Did I miss something on my research?

 

Some crazy ideas without success:

I was thinking I could somehow use MPxSelectionContext::addManipulator to add a vanilla manipulator but I haven't found a way to do that dirty trick.

 

As a side note, I've been having to use MPxContext::doPtrMoved since MPxSelectionContext::doPtrMoved won't get called but I haven't found any difference from using MPxContext

 

 

0 Likes
771 Views
1 Reply
Reply (1)
Message 2 of 2

jmreinhart
Advisor
Advisor

So you can add existing Maya manipulators to the the a custom context, using classes like MFnFreePointTriadManip.

jmreinhart_1-1674222501867.png

 

 

But adding themanipulator doesn't actually replicate all the behaviors of the context that Maya uses that manipulator in. You have to manually re-implement a lot of the logic about spaces, and how deforming two object at once works, and you'd need to manually recreate the tool settings ui too.

 

Ideally we could redefine how the selection portion of those contexts work by overriding the context they inherit that selection behavior from, but unfortunately there's no way to do that.

jmreinhart_0-1674222089158.png

 

 MPxSelectionContext::doPtrMoved not getting called is actually a bug that has been reported:

https://forums.autodesk.com/t5/maya-programming/is-it-possible-to-use-the-doptrmoved-with-mpxselecti... 

 

What is the end goal of what you are trying to create? There may be a workaround that will help you achieve somethin close to what you need. It sounds a bit like direct manip controls:

https://youtu.be/qLEyHkwrdWk?t=31 

0 Likes