Default Particle Systems

Top  Previous  Next

There are several default particle system classes included with DPSF: DefaultPixelParticleSystem, DefaultSpriteParticleSystem, DefaultAnimatedSpriteParticleSystem, DefaultPointSpriteParticleSystem, 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 DefaultPixelParticleSystem class uses the DefaultPixelParticle 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 DefaultPixelParticle class uses the DefaultPixelParticleVertex structure to hold its drawable properties, the DefaultPointSpriteParticle class uses the DefaultPointSpriteParticleVertex 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 file is named DPSFDefaults.cs and can be found in the Templates folder (i.e. C:\DPSF\Templates).

 

DefaultPixelParticleSystem

 

The default pixel particle system is designed for particles displayed as pixels.  It is designed to work with the DefaultPixelParticle class, which uses the DefaultPixelParticleVertex structure to hold its drawable properties in the vertex buffer.

 

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.

 

DefaultPointSpriteParticleSystem

 

The default point sprite particle system is designed for particles displayed as point sprites.  It is designed to work with the DefaultPointSpriteParticle class, which uses the DefaultPointSpriteParticleVertex structure to hold its drawable properties in the vertex buffer.

 

DefaultPointSpriteTextureCoordinatesNoRotationParticleSystem

 

The default point sprite texture coordinates no rotation particle system is designed for particles displayed as point sprites.  It is designed to work with the DefaultPointSpriteTextureCoordinatesParticle class, and uses the DefaultPointSpriteTextureCoordinatesNoRotationParticleVertex structure to hold its drawable properties in the vertex buffer.  The DefaultPointSpriteTextureCoordinatesParticle uses two Vector2's to hold the texture coordinates that should be used to display the particle.  This particle system class supports tinting the color of the particle image (including transparency), but does not support rotating the point sprites. 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 or rotated. When using point sprites you should try and keep the width and height between the top-left and bottom-right texture coordinates the same, since point sprites must be displayed as squares (i.e. not rectangles) and if the width and height are not the same, the image will get stretched to make it fit into a square.

 

DefaultPointSpriteTextureCoordinatesNoColorParticleSystem

 

The default point sprite texture coordinates no color particle system is designed for particles displayed as point sprites.  It is designed to work with the DefaultPointSpriteTextureCoordinatesParticle class, and uses the DefaultPointSpriteTextureCoordinatesNoColorParticleVertex structure to hold its drawable properties in the vertex buffer.  The DefaultPointSpriteTextureCoordinatesParticle uses two Vector2's to hold the texture coordinates that should be used to display the particle.  This particle system class supports rotating the point sprites, but does not support tinting the color of the particle image (including transparency). 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, or to change color or have transparency. When using point sprites you should try and keep the width and height between the top-left and bottom-right texture coordinates the same, since point sprites must be displayed as squares (i.e. not rectangles) and if the width and height are not the same, the image will get stretched to make it fit into a square.

 

DefaultPointSpriteTextureCoordinatesParticleSystem

 

The default point sprite texture coordinates particle system is designed for particles displayed as point sprites.  It is designed to work with the DefaultPointSpriteTextureCoordinatesParticle class, and uses the DefaultPointSpriteTextureCoordinatesParticleVertex structure to hold its drawable properties in the vertex buffer.  The DefaultPointSpriteTextureCoordinatesParticle uses two Vector2's to hold the texture coordinates that should be used to display the particle.  This particle system class supports both rotating the point sprites and tinting the color of the particle image (including transparency). Use this class if you want to display multiple different particle images in a single particle system and require the particles to be rotated and their color tinted, but don't require the particles to be animated. When using point sprites you should try and keep the width and height between the top-left and bottom-right texture coordinates the same, since point sprites must be displayed as squares (i.e. not rectangles) and if the width and height are not the same, the image will get stretched to make it fit into a square.

 

NOTE: This class runs much slower (20% - 40%) than the DefaultPointSpriteTextureCoordinatesNoRotationParticleSystem and DefaultPointSpriteTextureCoordinatesNoColorParticleSystem classes.  This is because extra operations must be performed in the shaders to allow texture coordinates, color, and rotation all to be passed into the pixel shader.  If you require texture coordinates, rotation, and color, you may be better off using the DefaultTexturedQuadTextureCoordinatesParticleSystem over this one.  This class requires less memory, but the DefaultTexturedQuadTextureCoordinatesParticleSystem may run slightly faster.

 

DefaultAnimatedPointSpriteNoRotationParticleSystem, DefaultAnimatedPointSpriteNoColorParticleSystem, and DefaultAnimatedPointSpriteParticleSystem

 

These classes extend their respective DefaultPointSpriteTextureCoordinates...ParticleSystem classes (above), they all are designed to work with the DefaultAnimatedPointSpriteParticle class, and they use the same particle vertex structure as their respective DefaultPointSpriteTextureCoordinates...ParticleSystem classes.  These classes also use 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.

 

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.