Exemple #1
0
        void RenderTerrainParticles(IGraphicsApi gfx, Particle[] particles, int elems, double delta, float t)
        {
            int count = elems * 4;

            if (count > vertices.Length)
            {
                vertices = new VertexP3fT2fC4b[count];
            }

            Update1DCounts(particles, elems);
            for (int i = 0; i < elems; i++)
            {
                int index = particles[i].Get1DBatch(game);
                particles[i].Render(game, delta, t, vertices, ref terrain1DIndices[index]);
            }
            int drawCount = Math.Min(count, maxParticles * 4);

            if (drawCount == 0)
            {
                return;
            }

            gfx.SetDynamicVbData(vb, vertices, drawCount);
            int offset = 0;

            for (int i = 0; i < terrain1DCount.Length; i++)
            {
                int partCount = terrain1DCount[i];
                if (partCount == 0)
                {
                    continue;
                }

                gfx.BindTexture(game.TerrainAtlas1D.TexIds[i]);
                gfx.DrawIndexedVb(DrawMode.Triangles, partCount * 6 / 4, offset * 6 / 4);
                offset += partCount;
            }
        }