public ParticleSystem(IGraphicsContext context,int maxParticleCount, ParticleSettings settings)
        {
            this.settings = settings;
            this.queue = new Particle[maxParticleCount * 4];

            this.vertexBuffer = new VertexBuffer<Particle>(context, OpenTK.Graphics.OpenGL.BufferUsageHint.StreamDraw);
            this.indecies = new IntIndexBuffer(context, OpenTK.Graphics.OpenGL.BufferUsageHint.StaticDraw);

            this.SetIndexBufferSize(maxParticleCount);

            this.vertexBuffer.Bind();
            this.vertexBuffer.SetData(this.queue);

            GL.GenVertexArrays(1, out vba);
        }
Пример #2
0
        public ParticleSystem(IGraphicsContext context, int maxParticleCount, ParticleSettings settings)
        {
            this.settings = settings;
            this.queue    = new Particle[maxParticleCount * 4];

            this.vertexBuffer = new VertexBuffer <Particle>(context, OpenTK.Graphics.OpenGL.BufferUsageHint.StreamDraw);
            this.indecies     = new IntIndexBuffer(context, OpenTK.Graphics.OpenGL.BufferUsageHint.StaticDraw);

            this.SetIndexBufferSize(maxParticleCount);

            this.vertexBuffer.Bind();
            this.vertexBuffer.SetData(this.queue);



            GL.GenVertexArrays(1, out vba);
        }
Пример #3
0
        void Panel_MouseDown(object sender, EntityGUI.MouseButtonEventArgs e)
        {
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    Color c = Random.NextColor() * 0.5f;
                    Color c2 = Random.NextColor();

                    ParticleSettings settings = new ParticleSettings(new Vector2(Random.Next(-30, 30), Random.Next(-30, 30)), c * 0.7f, c2,
                                                                     Color.Black * 0.5f,
                                                                     0, Random.Next(30, 40), 3f, 0, 2, Random.Next(1, 2));

                    this.systems[i * 2 + j] = new ParticleSystem(this.GraphicsContext, 256 * 2, settings);

                    double r = Random.NextDouble();
                    if (r > 0.66f)
                    {

                        SprayEmiter2D emiter = new SprayEmiter2D(100f, 200f, 0, (float)(Random.NextDouble() * Math.PI), new Vector2(this.Width / 5 * i + 150, this.Height / 2 * j + 150),
                        this.particleAtlas.ToArray(), systems[i * 2 + j]);
                        emiter.EmitInterval = TimeSpan.FromSeconds(1d / 64);
                        emiter.EmitCount = 2;

                        this.emiters[i * 2 + j] = emiter;
                    }
                    else if (r > 0.33d)
                    {
                        BeeEmiter2D emiter = new BeeEmiter2D(new Vector2(this.Width / 5 * i + 150, this.Height / 2 * j + 150),
                        new Frame[] { particleAtlas["Cloud002"], particleAtlas["Flame"], particleAtlas["Cloud004"] }, systems[i * 2 + j]);
                        emiter.EmitInterval = TimeSpan.FromSeconds(1d / 64);
                        emiter.EmitCount = 4;

                        this.emiters[i * 2 + j] = emiter;
                    }
                    else
                    {
                        CircleEmiter2D emiter = new CircleEmiter2D(50, 75, new Vector2(this.Width / 5 * i + 150, this.Height / 2 * j + 150),
                          this.particleAtlas.ToArray(), systems[i * 2 + j]);
                        emiter.EmitInterval = TimeSpan.FromSeconds(1d / 32);
                        emiter.EmitCount = 8;

                        this.emiters[i * 2 + j] = emiter;

                    }

                }
            }
        }