public void InitializeParticleShockwave(DefaultTextureQuadTextureCoordinatesParticle particle) { particle.Lifetime = ShockwaveDuration; particle.Color = ShockwaveColor; particle.Position = Emitter.PositionData.Position; particle.Normal = new Vector3(0, 1, 0); particle.Size = particle.StartSize = 1; particle.EndSize = ShockwaveSize; particle.SetTextureCoordinates(_shockwaveTextureCoordinates, Texture.Width, Texture.Height); }
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(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; // Orient the particle according to it's 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 = Color.HotPink; particle.Position = Emitter.PositionData.Position; particle.Velocity = DPSFHelper.RandomNormalizedVector() * RandomNumber.Next(50, 100); particle.Right = -particle.Velocity; // Orient the particle according to it's velocity. // Specify the particle's width-to-height ratio as 8:1 so it looks better particle.Width = 10; 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);*/ }
//=========================================================== // Other Particle System Functions //=========================================================== /// <summary> /// Start the explosion. /// </summary> public void Explode() { // Create the particle that we will model other particles added to the particle system after (i.e. a Shockwave particle) DefaultTextureQuadTextureCoordinatesParticle particle = new DefaultTextureQuadTextureCoordinatesParticle(); this.InitializeParticleShockwave(particle); // If a shockwave should be created, set the model-particle to the proper orientation and add a copy of the model-particle to the particle system. if (ShockwaveXAxisEnabled) { particle.Normal = new Vector3(1, 0, 0); this.AddParticle(particle); } if (ShockwaveYAxisEnabled) { particle.Normal = new Vector3(0, 1, 0); this.AddParticle(particle); } if (ShockwaveZAxisEnabled) { particle.Normal = new Vector3(0, 0, 1); this.AddParticle(particle); } if (ShockwaveXYAxisEnabled) { particle.Normal = new Vector3(1, 1, 0); this.AddParticle(particle); } if (ShockwaveXZAxisEnabled) { particle.Normal = new Vector3(1, 0, 1); this.AddParticle(particle); } if (ShockwaveYZAxisEnabled) { particle.Normal = new Vector3(0, 1, 1); this.AddParticle(particle); } if (ShockwaveXYNegativeAxisEnabled) { particle.Normal = new Vector3(-1, 1, 0); this.AddParticle(particle); } if (ShockwaveXZNegativeAxisEnabled) { particle.Normal = new Vector3(-1, 0, 1); this.AddParticle(particle); } if (ShockwaveYZNegativeAxisEnabled) { particle.Normal = new Vector3(0, 1, -1); this.AddParticle(particle); } }
//=========================================================== // Particle Update Functions //=========================================================== protected void UpdateParticleTransparencyToBeMoreTransparent(DefaultTextureQuadTextureCoordinatesParticle particle, float elapsedTimeInSeconds) { particle.Color.A = (byte)(particle.Color.A * this.ShockwaveTransparency); }
public void InitializeParticleShockwave(DefaultTextureQuadTextureCoordinatesParticle particle) { particle.Lifetime = ShockwaveDuration; particle.Color = ShockwaveColor; particle.Position = Emitter.PositionData.Position; particle.Normal = new Vector3(0, 1, 0); particle.Size = particle.StartSize = 1; particle.EndSize = ShockwaveSize; particle.SetTextureCoordinates(_shockwaveTextureCoordinates, Texture.Width, Texture.Height); // If a shockwave should be created, set the model-particle to the proper orientation and add a copy of the model-particle to the particle system. if (ShockwaveXAxisEnabled) { particle.Normal = new Vector3(1, 0, 0); this.AddParticle(particle); } if (ShockwaveYAxisEnabled) { particle.Normal = new Vector3(0, 1, 0); this.AddParticle(particle); } if (ShockwaveZAxisEnabled) { particle.Normal = new Vector3(0, 0, 1); this.AddParticle(particle); } if (ShockwaveXYAxisEnabled) { particle.Normal = new Vector3(1, 1, 0); this.AddParticle(particle); } if (ShockwaveXZAxisEnabled) { particle.Normal = new Vector3(1, 0, 1); this.AddParticle(particle); } if (ShockwaveYZAxisEnabled) { particle.Normal = new Vector3(0, 1, 1); this.AddParticle(particle); } if (ShockwaveXYNegativeAxisEnabled) { particle.Normal = new Vector3(-1, 1, 0); this.AddParticle(particle); } if (ShockwaveXZNegativeAxisEnabled) { particle.Normal = new Vector3(-1, 0, 1); this.AddParticle(particle); } if (ShockwaveYZNegativeAxisEnabled) { particle.Normal = new Vector3(0, 1, -1); this.AddParticle(particle); } }
public void InitializeParticleWithTextureCoordinates(DefaultTextureQuadTextureCoordinatesParticle cParticle) { // Initialize the particle using the InitialProperties specified above InitializeParticleUsingInitialProperties(cParticle); // Randomly pick which texture coordinates to use for this particle Rectangle sTextureCoordinates; switch (RandomNumber.Next(0, 4)) { default: case 0: sTextureCoordinates = msCloudTextureCoordinates; break; case 1: sTextureCoordinates = msSparkTextureCoordinates; break; case 2: sTextureCoordinates = msRockTextureCoordinates; break; case 3: sTextureCoordinates = msRingTextureCoordinates; break; } // Set the Particle's Texture Coordinates cParticle.SetTextureCoordinates(sTextureCoordinates, Texture.Width, Texture.Height); }
//=========================================================== // Particle Update Functions //=========================================================== protected void BounceOffFloor(DefaultTextureQuadTextureCoordinatesParticle cParticle, float fElapsedTimeInSeconds) { // If the Particle has hit the floor and is still travelling downwards if (cParticle.Position.Y <= 0 && cParticle.Velocity.Y < 0) { // Make the Particle Bounce upwards cParticle.Velocity.Y *= -mfBounciness; // Reduce the Particles X and Z speed cParticle.Velocity.X *= 0.8f; cParticle.Velocity.Z *= 0.8f; // Reduce the Particles Rotation speed cParticle.RotationalVelocity *= 0.8f; } }