public WallBuilder(List <Vector3[]> outlines, IHeightMap floor, IHeightMap ceiling, CaveWallModule walls) { this.outlines = outlines; floorHeightMap = floor; ceilingHeightMap = ceiling; wallModule = walls; extraVertsPerCorner = wallModule.ExtraVerticesPerCorner; totalVertsPerCorner = extraVertsPerCorner + 2; }
public override GameObject Generate() { Map map = configuration.MapGenerator.Generate(); IHeightMap floor = configuration.FloorHeightMapModule.GetHeightMap(); IHeightMap ceiling = configuration.CeilingHeightMapModule.GetHeightMap(); CaveWallModule caveWalls = configuration.WallModule; Map[,] mapChunks = MapSplitter.Subdivide(map); CaveMeshes[,] caveChunks = GenerateCaveChunks(mapChunks, configuration.CaveType, configuration.Scale, floor, ceiling, caveWalls); ThreeTierCave cave = new ThreeTierCave(caveChunks); AssignMaterials(cave, configuration.FloorMaterial, configuration.WallMaterial, configuration.CeilingMaterial); return(cave.GameObject); }
CaveMeshes[,] GenerateCaveChunks(Map[,] mapChunks, ThreeTierCaveType type, int scale, IHeightMap floor, IHeightMap ceiling, CaveWallModule walls) { int xNumChunks = mapChunks.GetLength(0); int yNumChunks = mapChunks.GetLength(1); var caveChunks = new CaveMeshes[xNumChunks, yNumChunks]; var actions = new Action[mapChunks.Length]; mapChunks.ForEach((x, y) => { Coord index = new Coord(x, y); actions[y * xNumChunks + x] = new Action(() => { WallGrid grid = MapConverter.MapToWallGrid(mapChunks[x, y], scale, index); MeshData floorMesh = meshGenerator.BuildFloor(grid, floor); MeshData ceilingMesh = SelectCeilingBuilder(type)(grid, ceiling); MeshData wallMesh = meshGenerator.BuildWalls(grid, floor, ceiling, walls); caveChunks[index.x, index.y] = new CaveMeshes(floorMesh, wallMesh, ceilingMesh); }); }); Execute(actions); return(caveChunks); }
public MeshData BuildWalls(WallGrid grid, IHeightMap floorHeightMap, IHeightMap ceilingHeightMap, CaveWallModule caveWall) { var outlines = BuildOutlines(grid); var wallBuilder = new WallBuilder(outlines, floorHeightMap, ceilingHeightMap, caveWall); return(wallBuilder.Build()); }