Last active
July 25, 2022 00:27
-
-
Save ylegall/f701ef8da40e853c1adc922adce5d55e to your computer and use it in GitHub Desktop.
houdini vex: procedural tetrahedron roll about center point
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float t = chf('time'); | |
float seed = chf('seed'); | |
int ti = int(6 * t) % 6; // integer time from 0-5 | |
float tf = frac(6 * t); // fraction time | |
// some random easing and motion reshaping: | |
float start = lerp(0.0, 0.05, rand(seed + 5 * ti)); | |
float stop = lerp(0.95, 1.0, rand(seed + 7 * ti)); | |
float shape = lerp(0.5, 0.65, rand(seed + 11 * ti)); | |
tf = fit(tf, start, stop, 0, 1); | |
tf = pow(tf, shape); | |
float dihedral = (PI - atan(2 * sqrt(2))); | |
vector axis = {0, 0, 1}; | |
matrix roty = ident(); | |
rotate(roty, -PI / 3, {0, 1, 0}); | |
vector pos = @P; | |
vector up = {0, 1, 0}; | |
vector N = {0, 0, 1}; | |
for (int i = 0; i < 6; i++) { | |
if (i > ti) break; | |
float angle = (i == ti)? tf * -dihedral : -dihedral; | |
matrix3 rot = ident(); | |
rotate(rot, angle, axis); | |
pos *= rot; | |
up *= rot; | |
N *= rot; | |
axis *= roty; | |
} | |
v@up = up; | |
v@N = N; | |
v@P = pos; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment