예제 #1
0
        /// <summary>
        ///     Crear un emisor de particulas
        /// </summary>
        /// <param name="texturePath">textura a utilizar</param>
        /// <param name="particlesCount">cantidad maxima de particlas a generar</param>
        public ParticleEmitter(string texturePath, int particlesCount)
        {
            //valores default
            enabled            = true;
            playing            = true;
            random             = new Random(0);
            creationFrecuency  = 1.0f;
            particleTimeToLive = 5.0f;
            minSizeParticle    = 0.25f;
            maxSizeParticle    = 0.5f;
            dispersion         = 100;
            speed = TGCVector3.One;
            particleVertexArray = new Particle.ParticleVertex[1];
            vertexDeclaration   = new VertexDeclaration(D3DDevice.Instance.Device, Particle.ParticleVertexElements);
            position            = TGCVector3.Empty;

            this.particlesCount = particlesCount;
            particles           = new Particle[particlesCount];

            particlesAlive = new ColaDeParticulas(particlesCount);
            particlesDead  = new Stack <Particle>(particlesCount);

            //Creo todas las particulas. Inicialmente estan todas muertas.
            for (var i = 0; i < particlesCount; i++)
            {
                particles[i] = new Particle();
                particlesDead.Push(particles[i]);
            }

            //Cargo la textura que tendra cada particula
            texture = TgcTexture.createTexture(D3DDevice.Instance.Device, texturePath);
        }
예제 #2
0
 /// <summary>
 ///     Liberar recursos
 /// </summary>
 public void dispose()
 {
     texture.dispose();
     particlesAlive = null;
     particlesDead  = null;
     particles      = null;
     vertexDeclaration.Dispose();
 }