Beispiel #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)
        {
            Device device = GuiController.Instance.D3dDevice;

            //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 = new Vector3(1, 1, 1) * fAleatorio(1, 10);
            particleVertexArray = new Particle.ParticleVertex[1];
            vertexDeclaration = new VertexDeclaration(device, Particle.ParticleVertexElements);
            position = new Vector3(0, 0, 0);

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

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

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

            //Cargo la textura que tendra cada particula
            this.texture = TgcTexture.createTexture(device, texturePath);

            Distancia = 1.0f;
        }
Beispiel #2
0
 /// <summary>
 /// Liberar recursos
 /// </summary>
 public void dispose()
 {
     this.texture.dispose();
     particlesAlive = null;
     particlesDead = null;
     particles = null;
     vertexDeclaration.Dispose();
 }