|
As a modeliing system we decided to implement a behavioral particle system. The scenes we created consisted of many particles who interacted with each other to form consequent scenes in an animation. We tried to create an animation that resembled fire, but with a few changes we can make animations that resemble water coming out of a fountain or exhausts.
There are two main components in our system. The first one is the Particle structure that has the following definitions:
| position |
defines the position of the particle in world coordinates |
| velocity |
a vector that holds the x, y and z components of the particle's velocity. |
| age |
the age of the particle (starts at 0 and gets incremented at every iteration) |
| temp |
for our system this was the temperature of the particle. |
The second main component is the Generator structure. In our system a Generator creates new particles. This can be thought of a circular tray that shoots out particles at different velocities and in different directions. The Generator has the following definitions
| position |
defines the position of the Generator in world coordinates |
| radius |
a vector that holds the x, y and z components of the particle's velocity. |
| theta |
the age of the particle (starts at 0 and gets incremented at every iteration) |
| highSpeed |
the highest initial velocity for a new particle |
| lowSpeed |
the lowes initial velocity for a new particle |
| highNewPeriter |
the maximum number of new particles that are created every iteration |
| lowNewPeriter |
the minimum number of new particles that are added to the system. |
These two structures are kept inside the PSystem structure which defines the system and contains the current number of particles, generators, the maximum number of particles the system can contain and the death temperature.
Initially we thought the particles in our system would die at a certain age (defined in the Particle structure) but we decided to use a death temperature, because we wanted the particles to stay alive as long as they are hot.
:: THE SYSTEM .
We implemented our system so that the motion of the particles will governed both by their own attributes and by the other particles. When we generated the particles, their initial characteristics such as their initial position, velocity and temperature were selected randomly. Once the particle's initial state was defined by its generator, at every iteration its characteristics were updated. Here's the life of a particle:
- The x and y coordinates of the center of the system were calculated.
- Depending on the particle's position relative to the center of the system the x and y components of its velocity were perturbed by a small random amount. Since the generators spurt out particles towards different directions, the center of the system is not (0,0) but it might be. A moving center creates a meandering path for the particles.
- The z component of the velocity of the particle was a random constant that was smaller than 1 but greater than 0. The idea was to decrease the velocity by some amount but keep the particle going upwards. We thought that this would be a more realistic representation of fire, since the hot particles tend to move up. If we used gravity instead of a factor, then the new system would resemble the motion of water being shot up by some velocity (we could modify our system a little and create a similar system)
- Then a 'closeness' value was calculated for the particle. The closeness value depended on the distance of the particle relative to each of the other particles. Then the closeness value was used to decrease the temperature of the particle. If the particle was close to a lot of other particles then it stayed hot. and if it was farther away the temperature dropped faster. We never increased the temperature of the particles to avoid parts of fire heating up and glowing randomly. Also since we defined a death temperature, increasing the temperature could potentially lead to immortal fire particles (oooh, scary...). We can however use the 'age' component of the particle system and let particle temperatures go up.
- Finally, if the temperature of the particles dropped to a certain level, the particle died.
And here's how the particles are generated. Behavior of a generator:
- The generator creates particles in a circle. Each time, the position inside the circle where the generator spurts out the particles changes randomly. The generator creates the particles on the surface (ie. their Z positions are all equal) but not all at the same point.
- The number of particles a generator can create depends on two boundary values and the number of particles in the system. Usually the generator will create at least MIN particles and at most MAX particles, but if the system is full then the generator will limit itself. Having the generator create a huge number of particles creates a nice effect. Since it takes a while before the particles die and the system is full, the generator can't create new particles and waits, and when particles start dying, it all of a suddent spurts out another huge chunk of particles.
- The velocities of the new particles face a random (but logical) location, and each new particle also has a little perturbation so that it doesn't look like the generator's shooting out arrows.
Here are some animations (click on animations to see larger versions)
|
|
|
|
animation 1 |
animation 2
|
animation 3 |
animation 4
|
in animation 1, the circle in which the generator is moving is pretty big, so the particles usually die faster (being away from family over christmas break hurts)
in animation 2 the generator circle is smaller. This time the death temperature is smaller, so the generator stops creating new particles. since the color depends on temperature the particles become very dark (but don't die) that's why we see no particles being created despite seeing none alive. We also made the particles go away from each other and the center so as to create a wind effect.
animation 3 is similar to animation 2, the wind effect is not there anymore.
in animation 4 we changed the colors of particles a little and tried to keep the particles bright for a longer period (if you compare particle this animation to the third one, you can see that the particles are visible at higher levels)
Finally here's our more fire-like animation with a lot of parameters optimized.
you can see how the particles are interacting with each other.

|