mavencolby
9/25/2019 - 11:16 PM

Orient Blend

Blend orients - useful for POP instances that rotate. In this example, as the point gets closer to P.y=0, the orient blends to be flat, with a random y-rotation.

Useful in conjunction with pop rotate snippet in pops

@dist = chramp('blend', fit(@P.y, 0, 3, 0, 1));

vector4 extrarot = quaternion(radians(rand(@id+12355)*360),set(0,1,0));
@orient = slerp(@orient, qmultiply(set(0,0,0,1),extrarot), 1-@dist);


// ============ RANDOMLY ROTATE Y AT REST =======================
@dist = chramp('blend', fit(@P.y, 0, 2, 0, 1));
 
vector4 extrarot = quaternion(radians(rand(@id+12355)*360),set(0,1,0))*360;

vector axis = set(0,1,0);
vector4 target = quaternion(axis);
matrix3 m = ident();
float angle = radians(fit01(rand(@id),-360, 360));
rotate(m, angle, axis);
target *= quaternion(m);



@orient = slerp(@orient, target, 1-@dist);