What is a Particle Event?

Particle Events are a combination of two things which you can use to have different actions occur that are triggered according to certain conditions you set:

• Trigger—determines what causes the event to occur. Possible triggers include:

- Particle Age: Event is triggered at the specified frame.

- Particle Age %: Event is triggered when it reaches the percentage of the particle type’s Max Lifetime value (the number of seconds that the particle lives).

- Every nth Particle: Event is triggered as every nth particle is born (where n represents the interval specified in the Value text box in the UI).

- Every nth Frame: Event is triggered at every nth frame (where n represents the interval specified in the Value text box in the UI).

- X/Y/Z Position: Event is triggered when a particle reaches the specified percentage of its position on either the X, Y, or Z axis.

- X/Y/Z Speed: Event is triggered when a particle reaches the specified percentage of its velocity on either the X, Y, or Z axis.

- Speed: Event is triggered when a particle reaches the specified percentage of its speed.

- Collision: Event is triggered when a particle collides with the object that is specified as its obstacle.

- Inter Particle Collision: Event is triggered when particles collide with each other (dependent on the settings on the particle type’s Inter. page).

- Inter Particle Avoidance: Event is triggered when particles avoid each other (dependent on the settings on the particle type’s Inter. page).

• Action—determines what will happen when the trigger is executed. Possible actions include:

- Emit: causes new particles to be emitted when the event is triggered (such as upon impact with the obstacle in a collision) while preserving the original particles for as long as their lifetime allows.

- Disappear: makes particles disappear when the event is triggered.

- Emit & Disappear: causes new particles to be emitted when the event is triggered while the original particles disappear.

- Bounce: causes the particles to bounce off an obstacle that you have specified (requires a Collision trigger).

- Bounce & Disappear: causes new particles to be emitted when particles bounce off an obstacle (requires a Collision trigger). The original particles do not disappear.

- Stick: causes particles to stick to an obstacle that you specify and remain there for the duration of their lifetimes (requires a Collision trigger).

- Script: allows for a great deal of control over specialized effects. The rest of this chapter concentrates on Scripted Events.

| For more information on particle events in general, see the Simulation (user) guide.

What Can You Do With Particle Events?

Here are some suggestions for effects that you can create using particle events:

• Wave Behavior

• Raindrops Splashing in a Puddle

• Setting Fires

• Rising Flames

• Dust Disturbance

• Flying Mud Splattering

• Flocking and Swarming

Wave Behavior

Many difference types of wave actions (for example, tidal waves or avalanches) can be created using several different particle types. For example, you could specify a particle type for the main wave, the topcrest particles, foam and mist sequenced in the following way:

• The main wave uses an event triggered by a position in Y which emits the topcrest particle type (turbulence).

• The topcrest particle type uses two events triggered by particle age:

- At 45% age the foam particle type is emitted.

- At 80% age the mist particle type is emitted.

- ...etc.

In addition, there may be more particle types and events that you can add to simulate other phenomena, such as the waves crashing onto a rock or cliff.

Raindrops Splashing in a Puddle

You could use a raindrop particle type for the falling raindrop and then set up an event with a collision trigger and a disappear and emit action so that the new particle type represents the splashes.

Setting Fires

Picture a fire ball striking a field of grass and igniting the grass on fire, with soot being thrown into the air. To achieve this effect, you could use a collision event along with several age emission events to develop the look of fire and smoke look.

Rising Flames

To simulate a bonfire you could set up a flame particle type which uses rising particles, eventually turning into smoke particles with an age trigger.

Dust Disturbance

The scene is a haunted house being explored by ghost hunters. As their feet hit the floor, dust flies up from around the outline of each foot, accomplished with a collision event.

Flying Mud Splattering

Mud is slung against a wall and sticks to it, splatting along the surface of the wall. To simulate this effect, you could use a collision trigger with a scripted event action in this way:

• The mud particle type uses the wall as its obstacle.

• Upon collision, a scripted event changes the position of some of the particles to achieve a splatter pattern.

Flocking and Swarming

Bees swarming around a hive, a school of fish swimming, feathers flying. These effects would use similar algorithms in their scripted events, where particles would move towards some particles and away from others.

Scripted Particle Events

The standard actions (emit, bounce, disappear, stick) may not provide enough fine-tuning control in certain situations. It may be one of the property values you want to fine-tune or it may be the an irregular selection of particles in a collection that you want to affect. For example, you may be simulating a ghostly mist and you want a very specific pattern to appear. Or you may want to change the velocity of the 2nd, 3rd and 5th particle in each group of ten.

| For collision triggers, the event script can actually participate in the collision detection because the custom event script is called prior to doing collision detection.

| At this time, the only languages supported for scripted particle events are VBScript and JScript.

Contextual Information

Particle events are set on a particle type, which allows you to have very specific control over an effect. You can use embedded scripts, which allow you to choose the context for your event:

• Per Trigger Particle—the script is called once for each particle that triggers the event.

• Per Particle—the script is called once for every particle in the cloud, whether it triggered the event or not.

• Per Cloud—the script is called once for the cloud.

These contexts also give the script contextual access to the components of the particle cloud. For example, the Per Trigger Particle context supplies information about the particle that triggered the event, whereas the Per Particle context supplies information about the particle and its position in the whole particle collection.

Contexts are not available for events that use an external script file. However, you can still find the same information from the input parameters in your script function. And with embedded files you can write helper functions which you can call inside the main entry point (the procedure name you specified in the PEvent property page).

Can I Still Use My Old Pre-Collision Scripts?

Scripted Particle Events replace and expand upon pre-collision scripts that were available in previous versions of XSI. If you have a pre-collision script from a previous version, you can replace it with a script-based particle event that is triggered at every frame with a scripted action.

Scripted Particle Events vs. Custom Operators

Whatever modifications you create in a scripted event are evaluated and reinjected into the simulation every time the particle event fires so that the next simulation step takes them into consideration.

On the other hand custom operators modify the particles for the evaluated frame but the results are not used for the next evaluation of the simulation feedback loop.

You can still use your custom operator in place of the standard particle simulation operator as long as you compensate for this evaluation disjunct (for example, saving modified data as user data on the particles).