public static async Task <TerrainEditor> OpenEmptyAsync(TerrainSettings setting) { var file = new TerrainFile(); var chunks = new List <Chunk>(); var index = 0; var center = setting.Size / 2; for (var x = 0; x < setting.Size; x++) { for (var y = 0; y < setting.Size; y++) { var chunk = GenerateEmptyChunk(index++, setting); chunk.HeightMap.PositionX = (x - center) * setting.ChunkSpacing; chunk.HeightMap.PositionY = (y - center) * setting.ChunkSpacing; chunks.Add(chunk); } } file.Weight = setting.Size; file.Height = setting.Size; file.ChunkTotalCount = setting.Size * setting.Size; file.Chunks = chunks; return(new TerrainEditor(file) { ChunkSize = setting.ChunkSize }); }
private static Chunk GenerateEmptyChunk(int index, TerrainSettings settings) { var chunk = Chunk.Empty; chunk.HeightMap = HeightMap.FromSize(settings.ChunkSize, settings.DefaultHeight); chunk.Index = index; return(chunk); }