Turning a 3d mesh into a waffle structure. Inspired by the waffle video tutorial by Entagma. Main difference is the avoidance of for loops and a more compact setup.
int slices = chi('slices');
int copy = prim(0, 'copynum', i@primnum);
float side = copy ? v@P.x : v@P.z;
v@P.y = sin(side * M_PI * slices) * 0.01;
Before the attribute wrangle, we store the rest position and create a copy of the input mesh using the "copy transform"-node with the copynum-attribute activated. Based on whether the the copy number is 0 or 1, we'll choose either the X or the Z axis using copy ? v@P.x : v@P.z
.
To prepare cutting the slices, we'll assign a sine wave running along these axis to v@P.y
.