Пример #1
0
        /// <summary>
        /// Add a particle to the system
        /// </summary>
        /// <param name="system"></param>
        /// <param name="particle"></param>
        public override void AddParticle(ParticleSystem system, Particle particle)
        {
            base.AddParticle(system, particle);

            // pick a random X between X1 and X2 
            // then get the corresponding y
            double x = ParticleSystem.random.NextDouble(X1, X2);
            particle.Position = new Point(x + ParticleSystem.random.NextDouble(MinPositionOffset, MaxPositionOffset), 
                                          LinearEquation(x) + ParticleSystem.random.NextDouble(MinPositionOffset, MaxPositionOffset)); 
        }
Пример #2
0
        /// <summary>
        /// Create a meatball which adds three particles with springs to the system. 
        /// </summary>
        /// <param name="system"></param>
        /// <param name="particle"></param>
        public override void AddParticle(ParticleSystem system, Particle particle)
        {
            //base.AddParticle(system, particle); // ignore the base

            double x = ParticleSystem.random.NextDouble(X1, X2);
            Meatball meatball = new Meatball(system, this, x, LinearEquation(x),
                                             MinSpringConstant, MaxSpringConstant, MinDampeningConstant, MaxDampeningConstant,
                                             MinRestLength, MaxRestLength, true);
            // add each particle to the dictionary and its associated meatball.
            foreach (Particle p in meatball.Particles)
            {
                mMeatballs.Add(p, meatball);
            }
        }
Пример #3
0
        /// <summary>
        /// Generate the particles by calling AddPartcle for a number of meatbals equal to 
        /// the MaxParticles divided by three. 
        /// </summary>
        /// <param name="system"></param>
        public override void GenerateParticles(ParticleSystem system)
        {
            //base.GenerateParticles(system);
            
            int totalConnections = MaxParticles;
            if (Meatball.NumberOfConnections > 0)
                totalConnections = MaxParticles / Meatball.NumberOfConnections;

            // Init the particles for the emitter
            Particle p = null;
            for (int i = 0; i < totalConnections; i++)
            {
                AddParticle(system, p);
            }
        }
Пример #4
0
 /// <summary>
 /// Method which is used to perform additional processing when adding a particle to the system for the
 /// first time.
 /// </summary>
 /// <param name="system"></param>
 /// <param name="particle"></param>
 virtual public void AddParticle(ParticleSystem system, Particle particle) {}
Пример #5
0
 /// <summary>
 /// Generates the particles for an emitter, called once at creation by the Particle System.
 /// </summary>
 /// <param name="system"></param>
 virtual public void GenerateParticles(ParticleSystem system) 
 {
     // Init the particles for the emitter
     for (int i = 0; i < MaxParticles; i++)
     {
         Particle mParticle = new Particle();
         UpdateParticle(mParticle);
         this.AddParticle(system, mParticle);
         system.Particles.Add(mParticle); 
     }
 }