public bool push(Particle p)
		{
            //Esta llena la pila.
			if (i_cima == pila.Length)
				return false;

			pila[i_cima] = p;
			i_cima++;

			return true;
		}
        public bool pop(out Particle p)
		{
			if (i_cima == 0)
			{
				p = null;
				return false;
			}

			i_cima--;
            p = pila[i_cima];

			return true;
		}
        public bool enqueue(Particle p)
        {
            //La cola esta llena.
            if ((i_frente == 0 && i_final == cola.Length - 1) || (i_final == i_frente - 1))
                return false;

            cola[i_final] = p;
            i_final++;

            if (i_final == cola.Length) i_final = 0;

            count++;
            return true;
        }
        public bool dequeue(out Particle p)
        {
            //La cola esta vacia.
            if (i_frente == i_final)
            {
                p = null;
                return false;
            }

            p = cola[i_frente];
            i_frente++;

            if (i_frente == cola.Length) i_frente = 0;

            count--;
            return true;
        }
Exemple #5
0
 /// <summary>
 /// Actualizar el estado de una particula existente
 /// </summary>
 private void updateExistingParticle(float elapsedTime, Particle p)
 {
     //Actulizo posicion de la particula.
     Vector3 scaleVec = Vector3.Scale(this.speed, elapsedTime);
     scaleVec.X *= p.Speed.X;
     scaleVec.Y *= p.Speed.Y;
     scaleVec.Z *= p.Speed.Z;
     p.Position += scaleVec;
 }
Exemple #6
0
        /// <summary>
        /// Dibujar particula
        /// </summary>
        private void renderParticle(Particle p)
        {
            Device device = GuiController.Instance.D3dDevice;

            //Variamos el canal Alpha de la particula con efecto Fade-in y Fade-out (hasta 20% Alpha - Normal - desde 60% alpha)
            float currentProgress = 1 - (p.TimeToLive / p.TotalTimeToLive);
            int alphaComp = 255;
            if (currentProgress < 0.2)
            {
                alphaComp = (int)((currentProgress / 0.2f) * 255f);
            }
            else if (currentProgress > 0.6)
            {
                alphaComp = (int)((1 - ((currentProgress - 0.6f) / 0.4f)) * 255);
            }

            //Crear nuevo color con Alpha interpolado
            Color origColor = Particle.DEFAULT_COLOR;
            p.Color = Color.FromArgb(alphaComp, origColor.R, origColor.G, origColor.B).ToArgb();

            //Render con Moduliacion de color Alpha
            int color = device.RenderState.TextureFactor;

            device.RenderState.TextureFactor = p.Color;
            device.TextureState[0].AlphaOperation = TextureOperation.Modulate;
            device.TextureState[0].AlphaArgument1 = TextureArgument.TextureColor;
            device.TextureState[0].AlphaArgument2 = TextureArgument.TFactor;

            particleVertexArray[0] = p.PointSprite;
            device.DrawUserPrimitives(PrimitiveType.PointList, 1, particleVertexArray);

            //Restaurar valor original
            device.RenderState.TextureFactor = color;
        }