SamuZai
DavidKahlVFX
DavidKahlVFX

patreon


Quicktip #14 Curve length from intrinsics

This is a fairly simple on but its easy to overlook.

A friend wanted to group hair for different shading based on the length. One way would be to use the measure sop with perimeter.

But is there a way to get that info in VEX and for giggles create the group right away all in one wrangle? Sure you can! :)

So lets start with a simple example. A bunch of randomly painted curves with different lengths. 


When you take a look at the spreadsheet on the primitives you can see... well nothing

The data we need is hidden in the intrinsics, named arclength


Now we only need to read that data, compare it to a threshold and put the curve into a group when it is long enough.

The function to read intrinsic data is primintrinsic( ) which can be used as the prim( ) function to read attributes - just on another layer.

With a channel we can create the threshold and compare it to the arclength. If the length is above it use setprimgroup( ).


float len = primintrinsic(0,"arclength",@primnum);

if(len>ch("thresh"))setprimgroup(0,"long",@primnum,1,"set"); 


And if we take another look at the spreadsheet we can see that it worked.


Cheers

Dave

Quicktip #14 Curve length from intrinsics

More Creators