Exemplo n.º 1
0
        /// <summary>
        /// Add a particle to the particle system.
        /// </summary>
        private void AddParticle()
        {
            if (this.Particles.Count < this.psp.MaxParticles)
            {
                ParticleParameters pp = new ParticleParameters();

                pp.InitialPosition = this.psp.Position;
                pp.Velocity        = (this.psp.Speed + this.GetRandom() * this.psp.SpeedVariance) *
                                     Vector3.Normalize((this.psp.Direction + new Vector3(
                                                            this.GetRandom() * this.psp.DirectionVariance,
                                                            this.GetRandom() * this.psp.DirectionVariance,
                                                            this.GetRandom() * this.psp.DirectionVariance)));

                pp.Colour = new Color(
                    this.GetRandomByte(this.psp.Colour.R, this.psp.ColourVariance),
                    this.GetRandomByte(this.psp.Colour.G, this.psp.ColourVariance),
                    this.GetRandomByte(this.psp.Colour.B, this.psp.ColourVariance),
                    this.psp.Colour.A);

                pp.LifeTime = this.psp.LifeTime + this.GetRandom() * this.psp.LifeTimeVariance;
                pp.Mass     = this.psp.Mass + this.GetRandom() * this.psp.MassVariance;

                pp.Gravity       = this.psp.Gravity;
                pp.AirResistance = this.psp.AirResistance;

                // Create and add the particle to the system
                Particle newParticle = new Particle(pp);
                this.Particles.Add(newParticle);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Creates a particle for use by a particle system.
 /// </summary>
 /// <param name="pp">A list of supplied parameters.</param>
 public Particle(ParticleParameters pp)
 {
     this._position     = pp.InitialPosition;
     this.velocity      = pp.Velocity;
     this._colour       = pp.Colour;
     this._timeToDeath  = pp.LifeTime;
     this.mass          = pp.Mass;
     this.gravity       = pp.Gravity;
     this.airResistance = pp.AirResistance;
 }