Add spin on multiple vellum objects

   674   1   1
User Avatar
Member
2 posts
Joined: Jan. 2022
Offline
Hi there,

I want to make a simple confetti animation with vellum.

But how do I add a custom spin on each confettis ?

I saw this expression on reddit that can be a great start :

vector towardscenter=normalize(v@P-getbbox_center(0) );
vector rotAxis=set(0,0,1);
v@v=cross( towardscenter, rotAxis) * ch('speed');

But of course it doesn't get the bbox center for each confetti.


I tried adding a custom spin before the copy to point. It works as small kick at the begining of the sim, but it's not enough.
User Avatar
Member
402 posts
Joined: April 2017
Offline
Much of the reason why confetti spins is because of the way it's shaped... it's usually bent and twisted in such a way that one side is going to have more drag than the other, forcing it to spin. If you bend and twist your source confetti geometry a bit and add a lot of drag to your simulation, it'll likely behave more like you'd expect.

If you really need that extra spin, it's not too hard to do in a SOP Solver. Use an Assemble SOP to create a name attribute on the Vellum geometry to get a unique name per confetti piece, and then promote that to points. Then in a SOP Solver use Extract Centroid to get the center of each piece based on that name, and copy that name attribute across to the centroid. Then in a Point Wrangle use the centroids in the second input as a reference point for computing the spin: you take the normalized vector between each point on the confetti and the matching centroid and then cross-multiply it with the world up vector to get a spin. Then bind that spin vector to an attribute (v@spin in my case but this is arbitrary):

// find matching centroid by name
int matchpt = nametopoint(1, s@name);

// get centroid position
vector center = point(1, "P", matchpt);

// compute spin vector
vector fwd = normalize(@P - center);
vector up = {0,1,0};
vector spin = cross(fwd, up);

// save this vector as an attribute we can use in pop wind
v@spin = spin;


In a POP Wind DOP you can then mix that spin force in by setting `wind = v@spin;` in a VEXpression. I also slowed the spin force down towards the ground with a simple fit function:

wind = v@spin;
// blend force to zero when near ground
float s = fit(@P.y, 0, 0.1, 0, 1);
wind *= s;

Attaching a file you can check out.

Attachments:
confetti_toadstorm.hip (715.1 KB)

MOPs (Motion Operators for Houdini): http://www.motionoperators.com [www.motionoperators.com]
  • Quick Links