diff --git a/InfectedRose.Terrain/HeightMap.cs b/InfectedRose.Terrain/HeightMap.cs index 529e3bc..d84e362 100644 --- a/InfectedRose.Terrain/HeightMap.cs +++ b/InfectedRose.Terrain/HeightMap.cs @@ -10,7 +10,9 @@ public class HeightMap : IConstruct public int Height { get; set; } public float UnknownFloat0 { get; set; } + public float UnknownFloat1 { get; set; } + public float UnknownFloat2 { get; set; } public int[] UnknownIntArray { get; set; } @@ -62,5 +64,10 @@ public void Deserialize(BitReader reader) Data[i] = reader.Read(); } } + + public float GetValue(int x, int y) + { + return Data[y * Width + x]; + } } } \ No newline at end of file diff --git a/InfectedRose.Terrain/TerrainEditor.cs b/InfectedRose.Terrain/TerrainEditor.cs deleted file mode 100644 index b502cdb..0000000 --- a/InfectedRose.Terrain/TerrainEditor.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace InfectedRose.Terrain -{ - public class TerrainEditor - { - - } -} \ No newline at end of file diff --git a/InfectedRose.Terrain/TerrainFile.cs b/InfectedRose.Terrain/TerrainFile.cs index 61b8f44..a66b8c7 100644 --- a/InfectedRose.Terrain/TerrainFile.cs +++ b/InfectedRose.Terrain/TerrainFile.cs @@ -48,5 +48,36 @@ public void Deserialize(BitReader reader) Chunks.Add(chunk); } } + + public float[,] GenerateHeightMap() + { + var heights = new float[ + ChunkCountX * Chunks[0].HeightMap.Width, + ChunkCountY * Chunks[0].HeightMap.Height + ]; + + for (var chunkY = 0; chunkY < ChunkCountY; ++chunkY) + { + for (var chunkX = 0; chunkX < ChunkCountX; ++chunkX) + { + var chunk = Chunks[chunkY * ChunkCountX + chunkX]; + + for (var y = 0; y < chunk.HeightMap.Height; ++y) + { + for (var x = 0; x < chunk.HeightMap.Width; ++x) + { + var value = chunk.HeightMap.GetValue(x, y); + + var pixelX = chunkX * Chunks[0].HeightMap.Width + x; + var pixelY = chunkY * Chunks[0].HeightMap.Height + y; + + heights[pixelX, pixelY] = value; + } + } + } + } + + return heights; + } } } \ No newline at end of file