private static void ReadHeightMaps(BinaryReader reader, bool[,] profile, HeightMap[,] heightMaps) { for (var y = 0; y < TerrainConstants.ChunksPerTileSide; y++) { for (var x = 0; x < TerrainConstants.ChunksPerTileSide; x++) { heightMaps[x, y] = ReadHeightMap(reader, profile[x, y]); } } }
private static HeightMap ReadHeightMap(BinaryReader reader, bool readLiquid) { var map = new HeightMap { IsFlat = reader.ReadBoolean(), MedianHeight = reader.ReadUInt16() }; if (map.IsFlat) { map.OuterHeightDiff = null; map.InnerHeightDiff = null; } else { for (var y = 0; y < 9; y++) { for (var x = 0; x < 9; x++) { map.OuterHeightDiff[x, y] = reader.ReadUInt16(); } } for (var y = 0; y < 8; y++) { for (var x = 0; x < 8; x++) { map.InnerHeightDiff[x, y] = reader.ReadUInt16(); } } } if (readLiquid) { for (var y = 0; y < 9; y++) { for (var x = 0; x < 9; x++) { map.LiquidHeight[x, y] = reader.ReadUInt16(); } } } else { map.LiquidHeight = null; } return map; }
private static HeightMap ReadHeightMap(BinaryReader reader, bool readLiquid) { /* This method should now read this structure * TileExtractor WriteChunkInfo(BinaryWriter writer, ADTChunk chunk) writer.Write(chunk.NodeId); writer.Write(chunk.IsFlat); // The base height for this chunk writer.Write(chunk.Header.Z); // The wmos and m2s (UniqueIds) that overlap this chunk WriteChunkModelRefs(writer, chunk.DoodadRefs); WriteChunkObjRefs(writer, chunk.ObjectRefs); writer.Write(chunk.TerrainTris); //writer.Write(chunk.Header.Holes > 0); //if (chunk.Header.Holes > 0) //{ // WriteChunkHolesMap(writer, chunk.Header.GetHolesMap()); //} //// The height map //if (!chunk.IsFlat) //{ // WriteChunkHeightMap(writer, chunk); //} // The liquid information); if (chunk.WaterInfo == null) { writer.Write(false); return; } writer.Write(chunk.WaterInfo.Header.Used); if (!chunk.WaterInfo.Header.Used) return; writer.Write((ushort)chunk.WaterInfo.Header.Flags); writer.Write((ushort)chunk.WaterInfo.Header.Type); writer.Write(chunk.WaterInfo.IsFlat); writer.Write(chunk.WaterInfo.Header.HeightLevel1); writer.Write(chunk.WaterInfo.Header.HeightLevel2); if (chunk.WaterInfo.Header.Flags.HasFlag(MH2OFlags.Ocean)) return; WriteWaterRenderBits(writer, chunk.WaterInfo.GetRenderBitMapMatrix()); if (chunk.WaterInfo.IsFlat) return; WriteWaterHeights(writer, chunk.WaterInfo.GetMapHeightsMatrix());*/ var map = new HeightMap { IsFlat = reader.ReadBoolean(), MedianHeight = reader.ReadUInt16() }; if (map.IsFlat) { map.OuterHeightDiff = null; map.InnerHeightDiff = null; } else { for (var y = 0; y < 9; y++) { for (var x = 0; x < 9; x++) { map.OuterHeightDiff[x, y] = reader.ReadSingle(); } } for (var y = 0; y < 8; y++) { for (var x = 0; x < 8; x++) { map.InnerHeightDiff[x, y] = reader.ReadSingle(); } } } if (readLiquid) { for (var y = 0; y < 9; y++) { for (var x = 0; x < 9; x++) { map.LiquidHeight[x, y] = reader.ReadSingle(); } } } else { map.LiquidHeight = null; } return map; }