Measure hair length (VEX)

This script creates two length attributes. One that measures the full length of the hair and one that measures the length from the root to the iterated point. Having the partial length attribute can be helpful in a situation where you need to cut hairs that are too long without deleting the hair.

Script:

//primitive wrangle
int pts[] = primpoints(0,@primnum);

vector posA,posB;
float length = 0;

posA = point(0,"P",pts[0]);

for ( int i=0; i<len(pts); i++ ){

    posB = point(0,"P",pts[i]);
    length += distance(posA,posB);
    
    posA = posB;
    
    setpointattrib(0,"length_point",pts[i],length);
}

f@length = length;
Previous
Previous

Move animation cache to origin (VEX)

Next
Next

Transfer skin normals to the groom curves (VEX)