Default Particle Systems

Top  Previous  Next

There are several default particle system classes included with DPSF: DefaultSpriteParticleSystem, DefaultAnimatedSpriteParticleSystem, DefaultQuadParticleSystem, DefaultTexturedQuadParticleSystem, DefaultAnimatedTexturedQuadParticleSystem, and more (see below).  Each of these particle system classes has a corresponding particle class that it uses for its particles.  For example the DefaultQuadParticleSystem class uses the DefaultQuadParticle class, the DefaultSpriteParticleSystem class uses the DefaultSpriteParticle class, and so on.  In addition, each particle class has an associated vertex format structure which is used to hold the particle's drawable properties in the vertex buffer.  For example, the DefaultQuadParticle class uses the DefaultQuadParticleVertex structure to hold its drawable properties, the DefaultSpriteParticle class uses the DefaultSpriteParticleVertex structure, and so on.

 

The default particle and particle system classes are provided as an easy starting point for building new particle systems.  They provide functionality that is common to many particle systems, such as position, velocity, acceleration, rotation, rotational velocity, rotational acceleration, start and end colors and sizes, external force, friction, etc.  However, if you find that you only use a couple of the features, such as just the position, velocity, and color, and you are trying to optimize your code, you may want to Create A New Particle System From Scratch to avoid wasting memory on the unused particle properties, especially if your particle system will be using thousands of particles.

 

The source code for the default particle and particle system classes is also provided as a learning resource, and it may be modified to add or remove functionality from the default classes as you see fit.  The source code files  are in the folder named "DPSF Defaults", which can be found in the Templates folder (i.e. C:\DPSF\Templates\DPSF Defaults).

 

 

DefaultSpriteParticleSystem

 

The default sprite particle system is designed for particles displayed as sprites using a SpriteBatch.  It is designed to work with the DefaultSpriteParticle class, which uses the DefaultSpriteParticleVertex structure.  The DefaultSpriteParticleVertex structure is actually an empty structure, since sprites do not require an explicit vertex buffer to be drawn; they are drawn using a SpriteBatch object.

 

 

DefaultSpriteTextureCoordinatesParticleSystem

 

The default sprite texture coordinates particle system is also designed for particles displayed as sprites using a SpriteBatch.  It is designed to work with the DefaultSpriteTextureCoordinatesParticle class, which also uses the DefaultSpriteParticleVertex structure.  The DefaultAnimatedSpriteParticle class uses a Rectangle to hold the texture coordinates that should be used to display the sprite.  Use this class if you want to display multiple different particle images in a single particle system, but don't require the particles to be animated.

 

 

DefaultAnimatedSpriteParticleSystem

 

The default animated sprite particle system is also designed for particles displayed as sprites using a SpriteBatch.  It is designed to work with the DefaultAnimatedSpriteParticle class, which also uses the DefaultSpriteParticleVertex structure.  The DefaultAnimatedSpriteParticle class uses a Rectangle to hold the texture coordinates that should be used to display the sprite.  It also uses an Animations class to determine which texture coordinates should be used depending on where the particle is in the current animation.

 

 

DefaultQuadParticleSystem

 

The default quad particle system is designed for particles displayed as quads.  It is designed to work with the DefaultQuadParticle class, which uses the DefaultQuadParticleVertex structure to hold its drawable properties in the vertex buffer.

 

 

DefaultTexturedQuadParticleSystem

 

The default textured quad particle system is designed for particles displayed as textured quads.  It is designed to work with the DefaultTexturedQuadParticle class, which uses the DefaultTexturedQuadParticleVertex structure to hold its drawable properties in the vertex buffer.

 

 

DefaultTexturedQuadTextureCoordinatesParticleSystem

 

The default textured quad texture coordinates particle system is also designed for particles displayed as textured quads.  It is designed to work with the DefaultTexturedQuadTextureCoordinatesParticle class, which also uses the DefaultTexturedQuadParticleVertex structure to hold its drawable properties in the vertex buffer.  The DefaultAnimatedTexturedQuadParticle class uses two Vector2's to hold the texture coordinates that should be used to display the quad. Use this class if you want to display multiple different particle images in a single particle system, but don't require the particles to be animated.

 

 

DefaultAnimatedTexturedQuadParticleSystem

 

The default animated textured quad particle system is also designed for particles displayed as textured quads.  It is designed to work with the DefaultAnimatedTexturedQuadParticle class, which also uses the DefaultTexturedQuadParticleVertex structure to hold its drawable properties in the vertex buffer.  The DefaultAnimatedTexturedQuadParticle class uses two Vector2's to hold the texture coordinates that should be used to display the quad. It also uses an Animations class to determine which texture coordinates should be used depending on where the particle is in the current animation.  Unlike the DefaultAnimatedSpriteParticle class, these texture coordinates should be normalized between 0.0 and 1.0.