DPSF by Daniel Schroeder

<PackageReference Include="DPSF" Version="2.5.0" />

.NET API 168,448 bytes

 DPSFDefaultQuadParticleSystem<Particle, Vertex>

public abstract class DPSFDefaultQuadParticleSystem<Particle, Vertex> : DPSFDefaultBaseParticleSystem<Particle, Vertex> where Particle : DPSFParticle where Vertex : struct, IDPSFParticleVertex
The Default Quad Particle System class
public class CInitialPropertiesForQuad<Particle, Vertex> : CInitialProperties<Particle, Vertex> where Particle : DPSFParticle where Vertex : struct, IDPSFParticleVertex

Particle System Properties used to initialize a Particle's Properties.

NOTE: These are only applied to the Particle when the InitializeParticleUsingInitialProperties() function is set as the Particle Initialization Function.

public Vector3 CameraPosition { get; set; }

Get / Set the Position of the Camera.

NOTE: This should be Set (updated) every frame if Billboarding will be used (i.e. Always have the Particles face the Camera).

public CInitialPropertiesForQuad<Particle, Vertex> InitialProperties { get; }

Get the Settings used to specify the Initial Properties of a new Particle.

NOTE: These are only applied to the Particle when the InitializeParticleUsingInitialProperties() function is set as the Particle Initialization Function.

public DPSFDefaultQuadParticleSystem(Game cGame)

Constructor

protected void UpdateParticleDistanceFromCameraSquared(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Updates the Particle's DistanceFromCameraSquared property to reflect how far this Particle is from the Camera.

protected void UpdateParticleHeightUsingLerp(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Linearly interpolate the Particle's Height between the Start and End Height according to the Particle's Normalized Lifetime

protected void UpdateParticleRotationalVelocityUsingRotationalAcceleration(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Update a Particle's Rotational Velocity according to its Rotational Acceleration

Update a Particle's Rotation and Rotational Velocity according to its Rotational Acceleration

protected void UpdateParticleRotationUsingRotationalVelocity(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Update a Particle's Rotation according to its Rotational Velocity

protected void UpdateParticleSystemToSortParticlesByDistanceFromCamera(float fElapsedTimeInSeconds)

Sorts the particles to draw particles furthest from the camera first, in order to achieve proper depth perspective.

NOTE: This operation is very expensive and should only be used when you are drawing particles with both opaque and semi-transparent portions, and not using additive blending.

Merge Sort is the sorting algorithm used, as it tends to be best for linked lists. TODO - WHILE MERGE SORT SHOULD BE USED, DUE TO TIME CONSTRAINTS A (PROBABLY) SLOWER METHOD (QUICK-SORT) IS BEING USED INSTEAD. THIS FUNCTION NEEDS TO BE UPDATED TO USE MERGE SORT STILL. THE LINKED LIST MERGE SORT ALGORITHM CAN BE FOUND AT http://www.chiark.greenend.org.uk/~sgtatham/algorithms/listsort.html

protected void UpdateParticleToBeConstrainedAroundXAxis(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Orientates the Particle to face the camera, but constrains the particle to always be perpendicular to the Y-Z plane.

protected void UpdateParticleToBeConstrainedAroundYAxis(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Orientates the Particle to face the camera, but constrains the particle to always be perpendicular to the X-Z plane (i.e standing straight up).

protected void UpdateParticleToBeConstrainedAroundZAxis(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Orientates the Particle to face the camera, but constrains the particle to always be perpendicular to the X-Y plane.

protected void UpdateParticleToFaceTheCamera(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Turns the Particle into a Billboard Particle (i.e. The Particle always faces the Camera).

NOTE: This Update function should be called after all other Update functions to ensure that the Particle is orientated correctly.

NOTE: Update the Particle System's Camera Position every frame to ensure that this works correctly.

NOTE: Only Roll Rotations (i.e. around the Z axis) will be visible when this is used.

protected void UpdateParticleWidthAndHeightUsingLerp(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Linearly interpolate the Particle's Width and Height between the Start and End values according to the Particle's Normalized Lifetime

protected void UpdateParticleWidthUsingLerp(DefaultQuadParticle cParticle, float fElapsedTimeInSeconds)

Linearly interpolate the Particle's Width between the Start and End Width according to the Particle's Normalized Lifetime

protected virtual void UpdateVertexProperties(ref DefaultQuadParticleVertex sVertexBuffer, int iIndex, DPSFParticle Particle)

Function to update the Vertex properties according to the Particle properties