VertexPos3Col4[] BuildTerrainBorders(TerrainMap map, ref int totalTriangles) { TileDrawInfo drawInfo = new TileDrawInfo(); int lengthX = map.Width; int lengthY = map.Length; VertexPos3Col4[] vertices = new VertexPos3Col4[lengthX * lengthY * 4]; int index = 0; for (int x = 0; x < lengthX; x++) { for (int y = 0; y < lengthY; y++) { Tile tile = map[x, y]; drawInfo.CurrentTile = tile; drawInfo.MapX = x; drawInfo.MapY = y; RenderTileBorders(drawInfo, vertices, index); index += 4; } } // end for totalTriangles += drawInfo.TotalTriangles; return(vertices); }
void RenderTileBorders(TileDrawInfo drawInfo, VertexPos3Col4[] vertices, int index) { Tile tile = drawInfo.CurrentTile; float x = tile.X; float y = tile.Y; float height = tile.Height; FastColour colour = new FastColour(150, 150, 150); vertices[index] = new VertexPos3Col4(x, height, y + 0.5f, colour); vertices[index + 1] = new VertexPos3Col4(x + 0.5f, height, y, colour); vertices[index + 2] = new VertexPos3Col4(x + tileWidth, height, y + 0.5f, colour); vertices[index + 3] = new VertexPos3Col4(x + 0.5f, height, y + tileWidth, colour); drawInfo.TotalTriangles += 2; }