/// <inheritdoc/> public byte[] Serialize(MH2OInstance instance) { using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { if (instance.LiquidObjectOrVertexFormat != 2) { for (byte y = instance.OffsetY; y < instance.Height + instance.OffsetY; y++) { for (byte x = instance.OffsetX; x < instance.Width + instance.OffsetX; x++) { bw.Write(HeightMap[y, x]); } } } for (byte y = instance.OffsetY; y < instance.Height + instance.OffsetY; y++) { for (byte x = instance.OffsetX; x < instance.Width + instance.OffsetX; x++) { bw.Write(DepthMap[y, x]); } } return(ms.ToArray()); } }
/// <summary> /// Initializes a new instance of the <see cref="MH2OInstanceVertexData"/> class. /// </summary> /// <param name="inData"></param> /// <param name="instance"></param> public MH2OInstanceVertexData(byte[] inData, MH2OInstance instance) { using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { if (instance.LiquidObjectOrVertexFormat != 2) { for (byte z = instance.OffsetY; z < instance.Height + instance.OffsetY; z++) { for (byte x = instance.OffsetX; x < instance.Width + instance.OffsetX; x++) { HeightMap[z, x] = br.ReadSingle(); } } } for (byte z = instance.OffsetY; z < instance.Height + instance.OffsetY; z++) { for (byte x = instance.OffsetX; x < instance.Width + instance.OffsetX; x++) { DepthMap[z, x] = br.ReadByte(); } } } }
/// <summary> /// Initializes a new instance of the <see cref="MH2OHeader"/> class. /// </summary> /// <param name="inData"></param> public MH2OHeader(byte[] inData) { using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { OffsetInstances = br.ReadUInt32(); LayerCount = br.ReadUInt32(); Instances = new MH2OInstance[LayerCount]; OffsetAttributes = br.ReadUInt32(); } }