/// <summary>
        /// InitializeParticle is overridden to add the appearance of wind.
        /// </summary>
        /// <param name="p">the particle to set up</param>
        /// <param name="where">where the particle should be placed</param>
        protected override void InitializeParticle(Particle3d p, Vector3 where)
        {
            base.InitializeParticle(p, where);

            // the base is mostly good, but we want to simulate a little bit of wind
            // heading to the right.
            p.Acceleration = p.Acceleration + new Vector3(ParticleSystem3d.RandomBetween(2, 8), 0, 0);
        }
Beispiel #2
0
        /// <summary>
        /// InitializeParticle randomizes some properties for a particle, then
        /// calls initialize on it. It can be overriden by subclasses if they 
        /// want to modify the way particles are created. For example, 
        /// SmokePlumeParticleSystem overrides this function make all particles
        /// accelerate to the right, simulating wind.
        /// </summary>
        /// <param name="p">the particle to initialize</param>
        /// <param name="where">the position on the screen that the particle should be
        /// </param>
        protected virtual void InitializeParticle(Particle3d p, Vector3 where)
        {
            // Determine the initial particle direction
            Vector3 direction = PickParticleDirection();

            // pick some random values for our particle
            float velocity = RandomBetween(minInitialSpeed, maxInitialSpeed);
            float acceleration = RandomBetween(minAcceleration, maxAcceleration);
            float lifetime = RandomBetween(minLifetime, maxLifetime);
            float scale = RandomBetween(minScale, maxScale);
            float rotationSpeed = RandomBetween(minRotationSpeed, maxRotationSpeed);
            float orientation = RandomBetween(0, (float)Math.PI * 2);

            // then initialize it with those random values. initialize will save those,
            // and make sure it is marked as active.
            p.Initialize(where, velocity * direction, acceleration * direction,
                          lifetime, scale, rotationSpeed, orientation);
        }