Extracting curves from polystrips

calendar_today

16.02.2024

label

Modeling, VEX

mouse

Houdini 20.0

Description

To project curves along the center of polystripes, maximize their UV islands and sample their world space positions to a new set of curves. Optionally, also transfer the path information from the first primitive found within each class.

1 Code discussion

// vertex wrangle:
// MAXIMIZE UV ISLANDS

string geo_uv = geounwrap(0, 'uv');

int class = prim(0, 'class', i@primnum);
string grp = '@class==' + itoa(class); 
vector bb = relbbox(geo_uv, grp, v@uv);

v@uv = bb;
// point wrangle:
// PROJECTS CURVES TO POLYSTRIPS

// PARAMETERIZATION
float u = vertexcurveparam(0, i@vtxnum);
vector uvw = set(0.5, u, 0.0);

// POSITION
string grp = '@class==' + itoa(i@primnum);
vector pos = uvsample(1, grp, 'P', 'uv', uvw);

// PATH
int pr = findattribval(1, 'prim', 'class', i@primnum, 0);
string path = prim(1, 'path', pr);

// ATTRIBUTES
v@P = pos;
s@path = path;
download

Downloads