Houdini VEX - Snippets

Transform

We have control over the distribution of various sizes (bias), the size over life (note that we use the internal @nage i.e. normalized age an attr that comes by default when we do a popsim), min and max scale as well as an overall multiplier.

pscale

float ps_life = chramp('ps_life', @nage);
float ps_bias = fit01(chramp('ps_bias', rand(@id)), chf('ps_min'), chf('ps_max'));
@pscale = ps_life*ps_bias*chf('ps_mult');

Formatting

Zero padding

int i = int(rand(@ptnum+chi('seed'))*(chi('max_num')+1));
s@z_padded = sprintf('hello_%03i', i);

Edit Primitves

adjustPrimLength

Here we can use a measure sop measure the perimeter of the prim. This is needed for the function to work. Note that if we does not clamp the length it will extend the prims to match the length of the longest prim.

#include <groom.h>

float length = clamp(chf('length'), 0, @perimeter);
adjustPrimLength(0, @primnum, @perimeter, length);

Functions

frac()