Time for action — adding a particle system

We are going to use the code from the last example:

  1. Create a particle system that uses a predefined particle script. Add the particle system to the same scene node that the Sinbad entity is attached to:
    Ogre::ParticleSystem* partSystem = _sceneManager->createParticleSystem("Smoke","Examples/Smoke");
    _SinbadNode->attachObject(partSystem);
    
  2. Compile and run the application. There should be a large amount of smoke coming from Sinbad.
    Time for action — adding a particle system

What just happened?

We used an already defined particle script to create a particle system, which we attached to the same node that our entity was attached to. This way, the particle system follows our entity around when it moves.

What is a particle system?

Before we create our own particle system instead of loading a predefined one, we need to discuss what exactly a particle system is. We have seen the effect a particle system creates in our case, a smoke cone; but how does it create this?

A particle system consists of two to three different constructs an emitter, a particle, and an affector (optional). The most important of these three is the particle itself, as the name particle system suggests. A particle displays a color or textures using a quad or the point render capability of the graphics cards. When the particle uses a quad, this quad is always rotated to face the camera. Each particle has a set of parameters, including a time to live, direction, and velocity. There are a lot of different parameters, but these three are the most important for the concept of particle systems. The time to live parameter controls the life and death of a particle. Normally, a particle doesn't live for more than a few seconds before it gets destroyed. This effect can be seen in the demo when we look up at the smoke cone. There will be a point where the smoke vanishes. For these particles, the time to live counter reached zero and they got destroyed.

The direction and velocity parameters describe the moving behavior of the particle. In our case, the direction was up.

An emitter creates a predefined number of particles per second and can be seen as the source of the particles. Affectors, on the other hand, don't create particles but change some of their parameters. We haven't seen any affectors in this scene, but we will later. An affector could change the direction, velocity, or color of the particles created by the emitter.

What is a particle system?

Now that we know the basics, let's create some particle systems on our own.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.189.170.206