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

            pila[i_cima] = p;
            i_cima++;

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

            i_cima--;
            p = pila[i_cima];

            return true;
        }
Esempio n. 3
0
        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;
        }
Esempio n. 4
0
        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;
        }
Esempio n. 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;

            //            //Actulizo posicion de la particula.
            //if (p.Position.Z <= 0)
            //{
            //    Vector3 scaleVec = Vector3.Scale(this.speed, elapsedTime);
            //    scaleVec.X *= p.Position.X;
            //    scaleVec.Y *= p.Position.Y;
            //    scaleVec.Z *= 10;
            //    p.Position += scaleVec;
            //}
            //else
            //{

            //    Vector3 scaleVec = Vector3.Scale(this.speed, elapsedTime);
            //    scaleVec.X *= p.Position.X;
            //    scaleVec.Y *= p.Position.Y;
            //    scaleVec.Z *= p.Position.Z - 0.01f;
            //    p.Position += scaleVec;
            //}
        }
Esempio n. 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.5)
            {
                alphaComp = (int)((currentProgress / 0.5f) * 255f);
            }
            else if (currentProgress > 0.95)
            {
                alphaComp = (int)((1 - ((currentProgress - 0.95f) / 0.05f)) * 255);
            }

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

            device.RenderState.PointSpriteEnable = true;

            //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;
        }