Splatter example file
This example shows how to apply different behaviors when events happen. The particles fall from the sky onto the sphere and stick to the collision object. Only when a second particle strikes the sphere do the particles then fall off the sphere.
This effect is accomplished by having different POPs applied to the particles over time. Initially particles are birthed from the grid and a gravitation force is applied. Let’s take a look at the input selection rule in the Switch POP.
----- popevent(“release”) || popevent(“switch”) -----
The popevent() function returns a 1 when the event is occurring and 0 otherwise. So, this statement says that whenever the event “release” or “switch” occur, use input 1, otherwise use input 0. To start, none of these events are occurring, so the first branch is cooked.
So, to start, the particles are processed by collision1 which collides them against sphere2 and stops them on contact.
Now, let’s look at source2 and collision3. At frame 100, a single particle is birthed which travels towards the sphere. In the Collision POP, an event, “release” will be generated when the particle hits the sphere. The generation of this event will cause the switch to start evaluating the other branch.
Instead of being processed by collision1, the original particles will be processed by state1, collision2, and event1. The State POP will “unstick” the particles so that they will continue to move.
The Collision POP now collides them against the sphere again, this time bouncing them with no gain normal. This will cause the particles to slide off the sphere.
Finally, an Event POP is used to generate the “switch” event, which will cause this branch to continue to be evaluated.
Note that there are actually two collision spheres, sphere1 and sphere2. sphere1 is just a little bit bigger and is the first object to test for collision. This is so that when they are released, they will bounce off the slightly smaller sphere2. Otherwise, the particles might continue to stick even after they have been unstuck because they are right on the boundary of the collision object. By making the second sphere slightly smaller, this numerical accuracy issue is relieved.