Exemple #1
0
 public Particle()
 {
     color = ColorFunctions.ARGB((byte)255, (byte)255, (byte)255, (byte)255);
     size  = 0.0f;
     life  = 0.0f;
     angle = 0.0f;
 }
Exemple #2
0
        public void render(float dt)
        {
            if (this.isAlive() == false)
            {
                return;
            }
            if (this.texture.GetID() == -9999)
            {
                return;
            }

            GL.DepthMask(false);

            byte red, green, blue;

            if (this.life < 1.0f)
            {
                red   = (byte)(ColorFunctions.GetR(this.color) * this.life);
                green = (byte)(ColorFunctions.GetG(this.color) * this.life);
                blue  = (byte)(ColorFunctions.GetB(this.color) * this.life);
            }
            else
            {
                red   = (byte)(ColorFunctions.GetR(this.color));
                green = (byte)(ColorFunctions.GetG(this.color));
                blue  = (byte)(ColorFunctions.GetB(this.color));
            }

            GL.Color3(red, green, blue);

            this.texture.Bind();

            GL.PushMatrix();
            GL.Translate(this.position.X, this.position.Y, this.position.Z);

            float halfSize = this.size * 0.5f;

            GL.Begin(BeginMode.Quads);
            GL.TexCoord2(0.0d, 1.0);
            GL.Vertex3(-halfSize, halfSize, 0.0f);
            GL.TexCoord2(0.0f, 0.0f);
            GL.Vertex3(-halfSize, -halfSize, 0.0f);
            GL.TexCoord2(1.0f, 0.0f);
            GL.Vertex3(-halfSize, -halfSize, 0.0f);
            GL.TexCoord2(1.0f, 1.0f);
            GL.Vertex3(halfSize, halfSize, 0.0f);
            GL.End();
            GL.PopMatrix();

            GL.DepthMask(true);
        }