Creating New Particle Systems

Top  Previous  Next

The first thing to do is to create a new particle system file from a template and import it into your project.  Be sure to import one of the template files whose name starts with Default, as those are the templates that inherit the default particle systems' functionality.

 

Initializing the particle system

 

First locate the AutoInitialize() function.  The first thing this function does is call the particle system initialization function with some default values.  You may change these parameter values if you like.

 

Once the particle system is initialized you may change the Name property of the particle system if you wish.

 

From here the LoadParticleSystem() function is called to define how the particle system and its particles should behave.

 

 

Defining the particle system behavior

 

Step 0 - You should have already renamed / refactored the particle system classes name when you imported the template into your project.  If you have not done this yet, do it now.

 

Step 1 - Locate the LoadParticleSystem() function; This is where you will define how the particle system should behave.  If you like you may rename / refactor this function, or create several functions to load the particle system with different behaviors.

 

Step 2 - Specify the ParticleInitializationFunction.  The Particle Initialization Function is the function that will be used to initialize new particles when they are added to the particle system.  The default particle systems provide a particle initialization function called InitializeParticleUsingInitialProperties which initializes new particles based on the settings in the InitialProperties particle system object.  The default templates show how to specify the settings of the InitialProperties object.

 

If you like you may define your own function to initialize the particles, allowing full control over the particle's initial property values.  Any particle initialization functions you create must follow the InitializeParticleDelegate prototype, which is:

 

       public void FunctionName(Particle cParticle); where Particle is the particle class that the particle system is using for its particles.

 

An example of how to do this is shown in the templates by the InitializeParticleProperties() function. The naming convention DPSF uses for naming particle initialization functions to make them easy to recognize is that the function name starts with InitializeParticle. If you do not specify a Particle Initialization Function, when new particles are created their properties will have their default values.

 

Step 3 - First remove all ParticleEvents and ParticleSystemEvents so that if the function is called again later to reload the particle system, the events will not be added twice.  Next, add the the Particle and Particle System Events that you want the particle system to use.  The templates show examples of how to do this to achieve specific effects.  The default classes come with a number of built-in functions to achieve specific effects.  All built-in particle event functions begin with UpdateParticle, and all built-in particle system event functions begin with UpdateParticleSystem.

 

You may create your own particle event and particle system event functions as well.  Examples of how to do this are shown in the templates with the UpdateParticleFunctionExample() and UpdateParticleSystemFunctionExample() functions respectively.  Any new event functions you create must follow these same function prototypes.

 

Step 4 - Setup the emitter if it you want to use it, such as specifying its position, orientation, and how many particles it should emit per second.

 

 

To see some particle system examples, check out the DPSF Demo source code to see how the particle systems used in the demo were created.