public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle) { particle.Lifetime = RandomNumber.Between(0.3f, 0.7f); particle.Color = particle.StartColor = ExplosionColor; particle.EndColor = Color.Black; particle.Position = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25)); particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(1, 50); particle.ExternalForce = new Vector3(0, 80, 0); // We want the smoke to rise particle.Size = particle.StartSize = 1; // Have the particles start small and grow particle.EndSize = ExplosionParticleSize; // Give the particle a random initial orientation and random rotation velocity (only need to Roll the particle since it will always face the camera) particle.Rotation = RandomNumber.Between(0, MathHelper.TwoPi); particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2); // Randomly pick which texture coordinates to use for this particle Rectangle textureCoordinates; switch (RandomNumber.Next(0, 4)) { default: case 0: textureCoordinates = _flameSmoke1TextureCoordinates; break; case 1: textureCoordinates = _flameSmoke2TextureCoordinates; break; case 2: textureCoordinates = _flameSmoke3TextureCoordinates; break; case 3: textureCoordinates = _flameSmoke4TextureCoordinates; break; } particle.SetTextureCoordinates(textureCoordinates); }
public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle) { particle.Lifetime = RandomNumber.Between(0.5f, 1.0f); particle.Color = ExplosionColor; particle.Position = Emitter.PositionData.Position + new Vector3(RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25), RandomNumber.Next(-25, 25)); particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(30, 50); particle.ExternalForce = new Vector3(0, 20, 0); particle.Size = ExplosionParticleSize; particle.SetTextureCoordinates(_roundSparkTextureCoordinates); }
/// <summary> /// Initialize the properties of a particle. /// </summary> /// <param name="particle">Reference to the particle to be initialized.</param> public void InitializeParticleProperties(DefaultTexturedQuadParticle particle) { // Set the Particle's Lifetime (how long it should exist for) and initial Position particle.Lifetime = 5; particle.Position = Emitter.PositionData.Position; // Give the Particle a random velocity direction to start with particle.Velocity = DPSFHelper.RandomNormalizedVector() * 0.5f; particle.Size = 0.2f; particle.Color = Color.Red; }
public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle) { particle.Lifetime = RandomNumber.Between(0.5f, 1.0f); particle.Color = ExplosionColor; particle.Position = Emitter.PositionData.Position; particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(175, 225); particle.Right = -particle.Velocity; particle.Width = ExplosionParticleSize; particle.Height = ExplosionParticleSize * _textureAspectRatio; // Set the spark particle's texture coordinates particle.SetTextureCoordinates(_sparkTextureCoordinates, Texture.Width, Texture.Height); }
public void InitializeParticleExplosion(DefaultTextureQuadTextureCoordinatesParticle particle) { particle.Lifetime = RandomNumber.Between(0.3f, 0.5f); particle.Color = ExplosionColor; particle.Position = Emitter.PositionData.Position; particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(100, 150); particle.Right = -particle.Velocity; // Specify the particle's width-to-height ratio as 8:1 so it looks better particle.Width = 8; particle.Height = 1; // Calculate and set what the particle's EndWidth and EndHeight should be (2 times the start size) particle.ScaleToWidth(ExplosionParticleSize * 2); particle.EndWidth = particle.Width; particle.EndHeight = particle.Height; // Calculate and set what the particle's StartWidth and StartHeight should be particle.ScaleToWidth(ExplosionParticleSize); particle.StartWidth = particle.Width; particle.StartHeight = particle.Height; // Randomly pick which texture coordinates to use for this particle Rectangle textureCoordinates; switch (RandomNumber.Next(0, 3)) { default: case 0: textureCoordinates = _smokeTrail1TextureCoordinates; break; case 1: textureCoordinates = _smokeTrail2TextureCoordinates; break; case 2: textureCoordinates = _smokeTrail3TextureCoordinates; break; } particle.SetTextureCoordinates(textureCoordinates, Texture.Width, Texture.Height); }
public void InitializeParticleExplosion(DefaultSprite3DBillboardTextureCoordinatesParticle particle) { particle.Lifetime = RandomNumber.Between(1.2f, 1.7f); particle.Color = particle.StartColor = ExplosionColor; particle.EndColor = Color.DarkGray; particle.Position = Emitter.PositionData.Position; particle.ExternalForce = new Vector3(0, -80, 0); particle.RotationalVelocity = RandomNumber.Between(-MathHelper.PiOver2, MathHelper.PiOver2); particle.Velocity = DPSFHelper.RandomNormalizedVector(); // Calculate the direction the particle will travel in // We want the debris to travel upwards more often than downward, so if it's travelling downward switch it to travel upward 50% of the time if (particle.Velocity.Y < 0 && RandomNumber.Next(0, 2) == 0) { particle.Velocity.Y *= -1; } // Fire some particles towards the camera (but not directly at it) for a more dramatic effect if (RandomNumber.Between(0, 5) == 0) { // Calculate a point somewhere around the camera int distance = 10; Vector3 somewhereAroundTheCamera = new Vector3(CameraPosition.X + RandomNumber.Next(-distance, distance), CameraPosition.Y + RandomNumber.Next(-distance, distance), CameraPosition.Z + RandomNumber.Next(-distance, distance)); // Direct the Particle towards the spot around the camera particle.Velocity = somewhereAroundTheCamera - particle.Position; particle.Velocity.Normalize(); } // Set the Particle's Speed particle.Velocity *= RandomNumber.Next(100, 150); // Randomly pick which texture coordinates to use for this particle Rectangle textureCoordinates; switch (RandomNumber.Next(0, 9)) { default: case 0: textureCoordinates = _debris1TextureCoordinates; break; case 1: textureCoordinates = _debris2TextureCoordinates; break; case 2: textureCoordinates = _debris3TextureCoordinates; break; case 3: textureCoordinates = _debris4TextureCoordinates; break; case 4: textureCoordinates = _debris5TextureCoordinates; break; case 5: textureCoordinates = _debris6TextureCoordinates; break; case 6: textureCoordinates = _debris7TextureCoordinates; break; case 7: textureCoordinates = _debris8TextureCoordinates; break; case 8: textureCoordinates = _debris9TextureCoordinates; break; } particle.SetTextureCoordinates(textureCoordinates); // Set the Width to Height ratio so the image isn't skewed when we scale it particle.Width = textureCoordinates.Width; particle.Height = textureCoordinates.Height; // Set the particle to the specified size, give or take 25% particle.ScaleToWidth(ExplosionParticleSize * RandomNumber.Between(0.75f, 1.25f)); }