Interface to tweak single attr float in the viewport?

   535   2   2
User Avatar
Member
10 posts
Joined: July 2012
Offline
Hello,
Can anyone provide me with an idea how would you approach solving this particular problem:

I am trying to create an interface with which I can click on a point and drag the mouse up, down, left or right in order to set and change a single float attribute interactively in the viewport. In my case I would like to interactively change the value of pscale in order to control the thickness of the sweep. I don't even need any feedback in the viewport of what the value is since I can visualize that point or just look at the finished sweep.
I know I need python view states. But I am a bit clueless where to go with this information, you know how it goes
First question how can I identify and bind the control to the specific point, especially since point count and id might change.
Any tips are welcome.
Thank you.

Attachments:
2024-03-20 19_56_33-untitled.hip - Houdini FX 20.0.625 - Py3.10.jpg (662.4 KB)

User Avatar
Member
143 posts
Joined: May 2017
Offline
Hi,
a good starting point is the viewer state documentation – there a lot of examples. And also some hip files [www.sidefx.com] that come with Houdini by default.

Here is a very rough attempt, hip file below:

Notes:
First, the data between the viewer state and the actual geometry must be stored somehow. The easiest way is to store the data for each point in a multi-parm. You could also use a string or dictionary parm, then read and set the pscale attribute in a wrangle.

To set a multi-parm instance for each point, you can use "OnInputChange" node type event that updates the instance count when you connect the geometry to the HDA. You can also implement an "InputDataChanged [www.sidefx.com]" that updates the multi-parm immediately when the point count of the input geometry changes. Look in the included HDA under Type Properties / Scripts / OnInputChaged, there is a simple script that handles this.

Next, you need to set up a viewer state. For this example I use a gatget drawable [www.sidefx.com]. This type of drawable has the ability to pick and locate geometry that we need to determine the distance between the start and the current/end position of the drag. We can then simply store this value in the multi-parms for each point. Look in the HDA under Type Properties / Interactive / State Script.

The last step is to put the multi-parm data into the pscale attribute. You can use a wrangle within the HDA for this, so look there.

Image Not Found
Edited by viklc - March 27, 2024 08:00:50

Attachments:
Drag_Point.gif (907.0 KB)
Drag_Point.hiplc (189.1 KB)

User Avatar
Member
10 posts
Joined: July 2012
Offline
Wow Thank you very much. This is excellent. It will help a lot. I think I am slowly starting to understand.
  • Quick Links