DPSF by Daniel Schroeder

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

.NET API 168,448 bytes

 DPSFHelper

public static class DPSFHelper
Collection of static functions for performing common operations
public static bool DPSFInheritsDrawableGameComponent { get; }

Get if the Particle Systems are inheriting from DrawableGameComponent or not.

If inheriting from DrawableGameComponent, the Particle Systems are automatically added to the given Game object's Components and the Update() and Draw() functions are automatically called by the Game object when it updates and draws the rest of its Components.

If the Update() and Draw() functions are called by the user anyways, they will exit without performing any operations, so it is suggested to include them anyways to make switching between inheriting and not inheriting from DrawableGameComponent seamless; just be aware that the updates and draws are actually being performed when the Game object is told to update and draw (i.e. when base.Update() and base.Draw() are called), not when the particle system functions are called.

public static bool IsRunningInDebugMode { get; }

Get if the application is currently running in Debug mode or not.

public static bool IsRunningInDebugModeWithDebuggerAttached { get; }

Get if the application is currently running in Debug mode with a Debugger attached or not.

public static RandomNumbers RandomNumber { get; }

Variable that can be used to get random numbers.

public static string Version { get; }

Return the version of the DPSF.dll being used. This includes the Major, Minor, Build, and Revision numbers.

public static BlendState CloneBlendState(BlendState blendStateToClone)

Returns a clone of the given BlendState. Read-only properties, such as the GraphicsDevice property, are not copied though.

public static DepthStencilState CloneDepthStencilState(DepthStencilState depthStencilStateToClone)

Returns a clone of the given DepthStencilState. Read-only properties, such as the GraphicsDevice property, are not copied though.

public static RasterizerState CloneRasterizerState(RasterizerState rasterizerStateToClone)

Returns a clone of the given RasterizerState. Read-only properties, such as the GraphicsDevice property, are not copied though.

public static SamplerState CloneSamplerState(SamplerState samplerStateToClone)

Returns a clone of the given SamplerState. Read-only properties, such as the GraphicsDevice property, are not copied though.

public static byte FadeInQuicklyAndFadeOutQuicklyBasedOnLifetime(float fNormalizedElapsedTime)

Returns how transparent a Particle should be, based on it's Normalized Elapsed Time, so that it fades in quickly and fades out quickly.

public static byte FadeInQuicklyAndFadeOutSlowlyBasedOnLifetime(float fNormalizedElapsedTime)

Returns how transparent a Particle should be, based on it's Normalized Elapsed Time, so that it fades in quickly and fades out slowly.

public static byte FadeInQuicklyBasedOnLifetime(float normalizedElapsedTime)

public static byte FadeOutQuicklyBasedOnLifetime(float nomalizedElapsedTime)

public static float InterpolationAmountForEqualLerpInAndLerpOut(float fNormalizedElapsedTime)

Returns the interpolation amount (between 0.0 and 1.0) that should be used in a Lerp function to have a property reach its full value when the NormalizedLifetime reaches 0.5, and go back to its original value by the time the NormalizedLifetime reaches 1.0.

An example of where to use this would be if you wanted a particle to start off small, and reach its full size when the particle's lifetime is half over, and then to shrink back to being small by the time the particle dies. You would use the value returned by this function as the interpolation amount for the Lerp function. e.g. MathHelper.Lerp(SmallSize, LargeSize, ValueReturnedByThisFunction).

public static Color LerpColor(Color sColor1, Color sColor2, float fInterpolationAmount)

Returns the linearly interpolated Color between Color 1 and Color 2

public static Color LerpColor(Color sColor1, Color sColor2, float fRInterpolationAmount, float fGInterpolationAmount, float fBInterpolationAmount, float fAInterpolationAmount)

Returns the linearly interpolated Color between Color 1 and Color 2

public static Vector3 NormalizedPointOnSphere(float fYawAngle, float fPitchAngle)

Returns a point on a sphere with a radius of one. To use a different radius simply multiply the returned value by the desired radius value, before translating it to the sphere's position in world coordinates. To create a circle simply use a constant value for one of the Angles while changing the other Angle.

public static Vector2 PointOnCircle(float fAngle)

Returns a point on a circle with a radius of one, on the X-Y axis plane. To use a different radius simply multiply the returned value by the desired radius value.

public static Vector3 PointOnCircleVector3(float fAngle)

Returns a point on a circle with a radius of one, on the X-Y axis plane (Z value of zero). To use a different radius simply multiply the returned value by the desired radius value.

public static Vector3 PointOnSphere(float fYawAngle, float fPitchAngle, float fRadius)

Returns a point on a sphere with the given Radius. To create a circle simply use a constant value for one of the Angles while changing the other Angle.

public static Vector3 PointOnSphere(float fYawAngle, float fPitchAngle, float fRadius, Vector3 sSpherePosition)

Returns a point on a sphere with the given Radius, at the specified Sphere Position. To create a circle simply use a constant value for one of the Angles while changing the other Angle.

public static Color RandomColor()

Returns a random opaque Color (i.e. no transparency)

public static Color RandomColorWithRandomTransparency()

Returns a random Color with a random alpha value as well (i.e. random transparency)

public static Vector3 RandomNormalizedPointOnSphere()

Returns a random point on a sphere with a radius of one. To use a different radius simply multiply the returned value by the desired radius value, before translating it to the sphere's position in world coordinates.

public static Vector3 RandomNormalizedVector()

Returns a vector with a Random direction that has been Normalized.

public static float RandomNumberBetween(float fValue1, float fValue2)

Returns a random number between the specified values

public static Vector2 RandomPointOnCircle()

Returns a random point on a circle with a radius of one, on the X-Y axis plane. To use a different radius simply multiply the returned value by the desired radius value.

public static Vector3 RandomPointOnCircleVector3()

Returns a random point on a circle with a radius of one, on the X-Y axis plane (Z value of zero). To use a different radius simply multiply the returned value by the desired radius value.

public static Vector3 RandomPointOnSphere(float fRadius)

Returns a random point on a sphere with the given Radius

public static Vector3 RandomPointOnSphere(float fRadius, Vector3 sSpherePosition)

Returns a random point on a sphere with the given Radius, at the specified Sphere Position

public static Vector3 RandomVectorBetweenTwoVectors(Vector3 sVector1, Vector3 sVector2)

Returns a Vector whose individual XYZ components are each randomly chosen to be somewhere between the two given Vectors' individual XYZ components. Unlike choosing a random Lerp value between two vectors, which would give a point somewhere on the LINE between the two points, this chooses a random Lerp value between each of the two vectors individual xyz components, returning a point somewhere in the cube-shaped AREA (i.e. Volume) between the two points.

public static Vector3 SourceToTargetDirection(Vector3 source, Vector3 target)

Returns a normalized vector representing the direction that points from the source point to the target point.

public static Vector3 SourceToTargetVector(Vector3 source, Vector3 target)

Returns a vector representing the line from the source point to the target point.

public static float ValueInRange(float value, float min, float max)

Returns the given value, enforcing it to be within the given range.

public static bool VectorsAreEqualWithinTolerance(Vector3 sVector1, Vector3 sVector2, float fTolerance)

Returns true if the difference between the individual XYZ components of the given Vectors are all less than the specified Tolerance

public static bool VectorsAreTheSamePolarity(Vector3 sVector1, Vector3 sVector2)

Returns if the polarity (i.e. positive or negative) of each X,Y,Z component of the two vectors are the same or not.

Example: if Vector 1's X component is positive and Vector 2's X component is negative, this will return false.

Example: if Vector 1's X,Y,Z components are all positive, and Vector 2's X,Y,Z components are all positive, this will return true.