//=========================================================== // Particle Update Functions //=========================================================== protected void UpdateParticleFireSmokeColor(DefaultSprite3DBillboardTextureCoordinatesParticle particle, float elapsedTimeInSeconds) { // Have particle be the specified color for the first part of its lifetime float firstPartOfLifetime = 0.2f; if (particle.NormalizedElapsedTime < firstPartOfLifetime) { particle.Color = particle.StartColor; } // Then start fading it to black to look like smoke else { float lerpAmount = (particle.NormalizedElapsedTime - firstPartOfLifetime) * (1.0f / (1.0f - firstPartOfLifetime)); particle.Color = DPSFHelper.LerpColor(particle.StartColor, particle.EndColor, lerpAmount); } }
public void InitializeParticleSnow(DefaultTexturedQuadParticle cParticle) { // Position the Snow within 500 units of the emitter Vector3 sPosition = Emitter.PositionData.Position; sPosition.Y = 200; sPosition.X += RandomNumber.Next(-500, 500); sPosition.Z += RandomNumber.Next(-500, 500); cParticle.Lifetime = 0.0f; cParticle.Position = sPosition; cParticle.Size = RandomNumber.Next(2, 5); cParticle.Color = DPSFHelper.LerpColor(new Color(255, 255, 255, 50), new Color(255, 255, 255, 255), RandomNumber.NextFloat()); cParticle.Orientation = Orientation3D.Rotate(Matrix.CreateRotationZ(RandomNumber.Between(0, MathHelper.TwoPi)), cParticle.Orientation); cParticle.Velocity = new Vector3(RandomNumber.Next(-10, 3), RandomNumber.Next(-15, -5), RandomNumber.Next(-10, 10)); cParticle.Acceleration = Vector3.Zero; cParticle.RotationalVelocity.Z = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2); }