Esempio n. 1
0
        /// <summary>
        /// Creates a new particle.
        /// </summary>
        /// <param name="position">The position to spawn the particle at.</param>
        /// <param name="velocity">The initial velocity of the particle.</param>
        /// <param name="color">A color to multiply the particle's texture by.</param>
        /// <param name="sizeStart">The initial size of the particle.</param>
        /// <param name="sizeEnd">The size of the particle just before dying.</param>
        /// <param name="lifetime">The total lifetime of the particle in seconds.</param>
        /// <param name="constrained">Set to true to constrain one of the axes used to create the quad to the particle's velocity.</param>
        /// <param name="fastFade">Set to true to fade the particle in and out more quickly.</param>
        public void Spawn(Vector3 position, Vector3 velocity, Color color, float sizeStart, float sizeEnd, float lifetime, bool constrained, bool fastFade)
        {
            // discard particle if buffer is full
            if (numNew >= MAX_NEW)
            {
                return;
            }

            // create particle struct
            ParticleVertex v = new ParticleVertex();

            v.Position      = position;
            v.Velocity      = velocity;
            v.TimerLifetime = new Vector2(0, lifetime);
            v.SizeStartEnd  = new Vector2(sizeStart, sizeEnd);
            v.Color         = color.ToVector4();

            // set the particle's flags
            if (constrained)
            {
                v.Flags |= FLAG_CONSTRAINED;
            }
            if (fastFade)
            {
                v.Flags |= FLAG_FAST_FADE;
            }

            // append to buffer
            this.newParticles[numNew++] = v;
        }
        /// <summary>
        /// Creates a new particle.
        /// </summary>
        /// <param name="position">The position to spawn the particle at.</param>
        /// <param name="velocity">The initial velocity of the particle.</param>
        /// <param name="color">A color to multiply the particle's texture by.</param>
        /// <param name="sizeStart">The initial size of the particle.</param>
        /// <param name="sizeEnd">The size of the particle just before dying.</param>
        /// <param name="lifetime">The total lifetime of the particle in seconds.</param>
        /// <param name="constrained">Set to true to constrain one of the axes used to create the quad to the particle's velocity.</param>
        /// <param name="fastFade">Set to true to fade the particle in and out more quickly.</param>
        public void Spawn(Vector3 position, Vector3 velocity, Color color, float sizeStart, float sizeEnd, float lifetime, bool constrained, bool fastFade)
        {
            // discard particle if buffer is full
            if (numNew >= MAX_NEW)
                return;

            // create particle struct
            ParticleVertex v = new ParticleVertex();
            v.Position = position;
            v.Velocity = velocity;
            v.TimerLifetime = new Vector2(0, lifetime);
            v.SizeStartEnd = new Vector2(sizeStart, sizeEnd);
            v.Color = color.ToVector4();

            // set the particle's flags
            if (constrained) v.Flags |= FLAG_CONSTRAINED;
            if (fastFade) v.Flags |= FLAG_FAST_FADE;

            // append to buffer
            this.newParticles[numNew++] = v;
        }