Monday 7 October 2024

random spin to particles/packed rigid bodies

stolen from a Toadstorm reply somewhere...

axis might be more finessed than just setting to z as shown.. Same goes for the angle, which I've brute forced to -90 times. Anyway, this will give a bit of spin to your packed rigid bodies


vector axis = set(0,0,1); // the random axis attribute you created

float angle = -90*fit01(rand(@ptnum), -1, 1); // change this to whatever range, in radians

vector4 q = quaternion(angle, axis);

v@w = qconvert(q);