protected MeshGenerator(MeshGeneratorSettings settings, CaveWall wall) { Settings = settings; Wall = wall; }
//加工地图,清除小洞,小墙。获取生成的小墙体和房间。 private void ProcessMap() { //获取最大房间的索引 int currentIndex = 0, maxIndex = 0, maxSize = 0; //获取墙区域 List <List <CaveCoord> > wallRegions = GetRegions(TileType.Wall); foreach (List <CaveCoord> wallRegion in wallRegions) { if (wallRegion.Count < wallThresholdSize) { foreach (CaveCoord tile in wallRegion) { map[tile.tileX, tile.tileY] = TileType.Empty; //把小于阈值的都铲掉。 } } else { CaveWall walls = new CaveWall(wallRegion); caveWalls.Add(walls); foreach (CaveCoord tile in wallRegion) { if (tile.tileX == 0 || tile.tileY == 0 || tile.tileY == width || tile.tileY == height) { walls.isBorder = true; break; } } } } //获取空洞区域 List <List <CaveCoord> > roomRegions = GetRegions(TileType.Empty); foreach (List <CaveCoord> roomRegion in roomRegions) { if (roomRegion.Count < roomThresholdSize) { foreach (CaveCoord tile in roomRegion) { map[tile.tileX, tile.tileY] = TileType.Wall; //把小于阈值的都填充。 } } else { caveRooms.Add(new CaveRoom(roomRegion, map)); //添加到幸存房间列表里。 if (maxSize < roomRegion.Count) { maxSize = roomRegion.Count; maxIndex = currentIndex; //找出最大房间的索引。 } ++currentIndex; } } if (caveRooms.Count == 0) { Debug.LogError("No Survived Rooms Here!!"); } else { caveRooms[maxIndex].isMainRoom = true; //最大房间就是主房间。 caveRooms[maxIndex].isAccessibleFromMainRoom = true; } }
public MarchingCubesMeshGenerator(MeshGeneratorSettings settings, CaveWall wall) : base(settings, wall) { }
private async Task GenerateWallMeshAsync(CaveWall wall, WallGroup wallCells) { await Task.Run(() => wall.Generate(wallCells, this)); }
public SurfaceNetsMeshGenerator(MeshGeneratorSettings settings, CaveWall wall) : base(settings, wall) { }