Adjusting Uniform scale of pscale based on point length ?

   1009   1   0
User Avatar
1 posts
Joined: Jan. 2023
Hello guy.

Very new to Houdini and VEX but I am in the second semester of VFX so I have some very very basic knowledge.

So I would like to figure out how to modify the uniform scale / pscale of a transform node wired to an attrib wrangle based on the length of two points from a curve.

I know there is a function called points to read the value of a specific point and I know pscale adjusts the scale uniformly.
What I don't know is how to write the VEX code to get the vectors of the points.

Thank you in advance for your help.
User Avatar
5 posts
Joined: May 2021
Hi RSoklater,

Great question, I had some issues when I first started reading that data as well.

Assuming you want to just compare the distance between 2 points in space, you can use the following. If you want to take into consideration the full distance of a curve including any arcs, you will probably have to use the curvearclen function.

Accessing the point data
You can get the point data using the point() function, which reads as the following.
point(geohandle, string_attribute name, int_point number)
If you plug your curve into the first input on the attribute wrangle you can set your geohandle to 0.
Next we need the positional data @P for later to compare the 2 points, so we can set the next value to "P", with the quotation marks because its a calling the attribute as a string.
Finally set the point number of the point you want to access.

Do this a second time with a different point number to get your second point.
You can then use a distance function between points a & b to generate distance between the 2 points.
In the case bellow I just assigned the point number to a channel int so you can easily change them.

vector point_a = point(0, "P", chi('point_a'));
vector point_b = point(0, "P", chi("point_b"));

@dist = distance(point_a, point_b);

If you run your attribute wrangle over detail you can use the detail expression in the uniform scale channel of your transformation node to read it out.

detail(surface_node, attrib_name, attrib_index)
  • Quick Links