示例#1
0
 public ParticleManager(ShaderManager shaderManager)
 {
     this.shaderManager = shaderManager;
     shader = new ParticleShader();
     shaderManager.Add(shader); // Add shader to the manager so it updates the projectionMatrix & viewMatrix + clean-up.
     particleRenderer = new ParticleRenderer(shader);
 }
示例#2
0
        /// <summary>
        /// Renders the particles that are inside the paricles list of this emitter.
        /// </summary>
        /// <param name="particleRenderer">The render class for the particle</param>
        /// <param name="ms">Frame delta</param>
        public void Render(ParticleRenderer particleRenderer, double ms, Matrix4 viewMatrix)
        {
            Update(ms);

            cleanList.Clear();

            // Render each particle we have created in this emitter.
            foreach (Particle particle in particles)
            {
                if (!particle.Update(ms))
                { // Update the particle.
                    DestoryParticle(particle); // Remove the particle, it's not longer alive after this.
                }

                particleRenderer.Render(particle, viewMatrix); // Render the particle.
            }

            foreach(Particle particle in cleanList)
            {
                particles.Remove(particle);
            }
        }