Exemplo n.º 1
0
        ///<summary>
        /// Iterates over the tiles of the chunk, assembling the vertices and triangles for the chunk-wide mesh.
        ///</summary>
        private MeshData UpdateMeshData()
        {
            rendered = true;
            MeshData mesh = new MeshData();

            for (int xi = 0; xi < CHUNK_WIDTH; xi++)
            {
                for (int yi = 0; yi < CHUNK_HEIGHT; yi++)
                {
                    for (int zi = 0; zi < CHUNK_DEPTH; zi++)
                    {
                        Tile tile = tiles[xi, yi, zi];
                        if (tile == null || mesh == null)
                        {
                            continue;
                        }

                        TilePos bswCorner = chunkPos.GetTilePos();
                        int     x         = bswCorner.x + xi;
                        int     y         = bswCorner.y + yi;
                        int     z         = bswCorner.z + zi;
                        mesh = tile.TileData(this, x, y, z, mesh);
                    }
                }
            }

            return(mesh);
        }