Python viewer state: selection handle and manipulator handle

   2497   5   3
User Avatar
Member
359 posts
Joined: April 2017
Offline
I'm building a node that has a transform-style handle that manipulates geometry. It also needs to be able to select geometry on the fly, just like built-in SOPs like Edit that can quickly change selections if Safe Selection is disabled. I'm unsure how to implement this in my custom state, though. Either I can be in a selection state, or I can be in my transform handle state, but not both at the same time. Is this possible with Python states? I just want to be able to click on another primitive and then immediately start transforming, without having to hit S to go back to selection and then enter to go back to my handle state.

If someone could link me to some example code demonstrating this, that would be perfect. Thanks!
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Staff
397 posts
Joined: Feb. 2018
Offline
Here's a simple state example to demonstrate how to display a transform handle from a selected prim.
Image Not Found

Attachments:
test_selection_and_transform.hip (84.4 KB)

User Avatar
Member
359 posts
Joined: April 2017
Offline
That's perfect, thank you!
MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
User Avatar
Member
453 posts
Joined: Feb. 2013
Online
Sorry, I know this is a lot to ask for, but I would really like a more complex and complete example. Specifically I would like a viewer state that is identical to the curve sop interaction (as a starting point to further develop).

From there I want to go towards arbitrary amount of curves in one hda with arbitrary additional attributes and editing of multiple points at the same time.

I feel that I can get there on my own eventually, but I would really like a better starting point. It feels like an example that would be really good to have built-in, because it is probably the first thing people dream of doing with Python states.
User Avatar
Staff
397 posts
Joined: Feb. 2018
Offline
DASD
Sorry, I know this is a lot to ask for, but I would really like a more complex and complete example. Specifically I would like a viewer state that is identical to the curve sop interaction (as a starting point to further develop).

From there I want to go towards arbitrary amount of curves in one hda with arbitrary additional attributes and editing of multiple points at the same time.

I feel that I can get there on my own eventually, but I would really like a better starting point. It feels like an example that would be really good to have built-in, because it is probably the first thing people dream of doing with Python states.

Ok no problem, I'll look into that. In the meantime, check out `$HH/viewer_states/examples/add_point_demo.hip` in 18.0.311. The scene contains a python state which demonstrates how to draw points at the mouse position on the viewport construction plane or on the state connected geometry. You could probably extend this python state for drawing curves between points interactively.
Edited by mabelzile - Dec. 15, 2019 20:33:39
User Avatar
Member
453 posts
Joined: Feb. 2013
Online
I already looked into all python state examples in the HDA submenu and some of the ones in the example directory, but I will look again at this one. I made a little progress, but it's quite hard.
My problem is the combination of all the different examples. I need to combine all those features in one state.
My final goal is to have these features in one state:
Add points, move/rotate/scale one or more points, add additional curves, remove points, and more.

As you can see, that is a lot.
So I am currently trying to combine the add point example, your dynamic handle example and the keyboard input example.
I am confused about your example in that I don't quite get how to get the handle changes to parameters.

Then I still need to expand it for adding multiple curves.
Adding multiple curves could be solved with nested multiparm parameters and an editable sub-network where I spawn “add sops”, and then I need to make a shortcut to select the current curve to edit…
I barely got past the point where I can toggle adding points via keyboard input. This is why I would like a more complex example to start from, so I can see how different and multiple keypress events could be made to interact with each other.
I am trying to keep track of the current keypress state in variables in the main class, but maybe you have a better idea.
Edited by DASD - Dec. 16, 2019 02:48:41
  • Quick Links