Creating a New Particle Class
|Top Previous Next|
Every particle class created must inherit from the DPSFParticle class, so they will already have some particle properties defined. You will likely want to add more particle properties as well, which is what is shown how to do here:
Step 0 - You should have already created a new particle system file from a template and imported it into your project, making sure to have imported one of the template files whose name does not start with Default.
Step 1 - Locate the particle class that inherits from DPSFParticle. You should have already renamed / refactored this classes name in step 0 above, but if you did not then do it now.
Step 2 - Define any properties that you want your particles to have, making sure they are public so that they can be accessed by the particle system. The templates include some particle properties by default (such as Position and Velocity), but you may erase any that you do not want your particles to have.
Step 3 - Modify the Reset() function to initialize all of the particle properties to their default values. Be sure that base.Reset() is called as well.
Step 4 - Modify the CopyFrom() function to copy all of the particle properties from the particle given in the function parameters to that particle. Note that if any of the particle properties are reference-types (i.e. classes), you should be doing a deep copy on those properties to ensure that each particle has its own data. This is not necessary to do for built-in types (i.e. int, float, etc) and structs, since they are value-types, not reference-types.
The particle class should now be completely set up. Continue on to creating a new particle vertex structure.