An emitter
In this section, we add to the project the emitter, which will create particles at a specified rate.
Note
An example of this is 03-Particles/02-ParticlesEmitter
.
The example is based on the 03-Particles/01-SingleParticle
project, implemented in the previous section. We implement the emitter right inside the testApp
class. In the class declaration, replace the following line with declaration of a single particle Particle p;
with an array of particles:
vector<Particle> p; //Particles
Note
We will delete inactive particles from any parts of the p
array. So for computational efficiency, it is preferable to use the deque
class instead of vector
. But for simplicity, in this example, we use vector
. It works fast enough for our purposes in the example.
See usage of deque
in the Radial slit-scan example section in Chapter 5, Working with Videos.
Next, add the declaration of the parameter bornRate
and the supplementary variable bornCount
:
float bornRate; //Particles born rate per...