Toy Rocket

calendar_today

02.12.2023

label

Modeling, VEX

mouse

Houdini 20

1 Code discussion

This VEX code is used to transform a box into a wing and adjust it to the body of the rocket.

// PARAMETERS
float a = chf('amount_body');
float b = chf('amount_ground');
float in = chf('in');
float out = chf('out');
float start = chf('start');
float end = chf('end');
float t_start = chf('thickness_start');
float t_end = chf('thickness_end');

// REMAPPING BOUNDING BOX 
vector bb = relbbox(0, v@P);
vector uvw = set(bb.x, bb.z, bb.y);
uvw[0] = (uvw[0] * t_start - t_start / 2.0) % 1.0;
uvw[1] = fit01(uvw[1], start, end);

// SAMPLING POSITIONS AND NORMALS FROM THE BODY
vector pos_0 = uvsample(1, 'P', 'uv', uvw);
vector nml_0 = uvsample(1, 'N', 'uv', uvw);

// GROUND POSITIONS AND NORMALS
vector pos_1 = set(bb.x * t_end - t_end / 2.0, 0.0, fit01(bb.z, in, out));
vector nml_1 = {0,1,0};

// INTERPOLATING POSITIONS BTW. BODY AND GROUND
vector pos_a = lerp(pos_0 + nml_0 * 2e-3, pos_0 + nml_0 * a, bb.y);
vector pos_b = lerp(pos_1 + nml_1 * b, pos_1, bb.y);
vector pos = lerp(pos_a, pos_b, bb.y);

v@P = pos;
download

downloads