-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Marlamin/master
Add initial support for LOD ADT
- Loading branch information
Showing
29 changed files
with
1,921 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Warcraft.NET.Files.ADT.Entries.Legion; | ||
using Warcraft.NET.Files.Interfaces; | ||
|
||
namespace Warcraft.NET.Files.ADT.Chunks.Legion | ||
{ | ||
/// <summary> | ||
/// MBBB Chunk - Level of detail | ||
/// </summary> | ||
public class MBBB : IIFFChunk, IBinarySerializable | ||
{ | ||
/// <summary> | ||
/// Holds the binary chunk signature. | ||
/// </summary> | ||
public const string Signature = "MBBB"; | ||
|
||
/// <summary> | ||
/// Gets or sets <see cref="MBBBEntry"/>s. | ||
/// </summary> | ||
public List<MBBBEntry> MBBBEntries { get; set; } = []; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBBB"/> class. | ||
/// </summary> | ||
public MBBB() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBBB"/> class. | ||
/// </summary> | ||
/// <param name="inData">ExtendedData.</param> | ||
public MBBB(byte[] inData) | ||
{ | ||
LoadBinaryData(inData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LoadBinaryData(byte[] inData) | ||
{ | ||
using (var ms = new MemoryStream(inData)) | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
var mbbbCount = br.BaseStream.Length / MBBBEntry.GetSize(); | ||
for (var i = 0; i < mbbbCount; ++i) | ||
{ | ||
MBBBEntries.Add(new MBBBEntry(br.ReadBytes(MBBBEntry.GetSize()))); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string GetSignature() | ||
{ | ||
return Signature; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public uint GetSize() | ||
{ | ||
return (uint)Serialize().Length; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
foreach (var mbbb in MBBBEntries) | ||
{ | ||
bw.Write(mbbb.Serialize()); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Warcraft.NET.Files.Interfaces; | ||
|
||
namespace Warcraft.NET.Files.ADT.Chunks.Legion | ||
{ | ||
/// <summary> | ||
/// MBMB Chunk - Level of detail | ||
/// </summary> | ||
public class MBMB : IIFFChunk, IBinarySerializable | ||
{ | ||
/// <summary> | ||
/// Holds the binary chunk signature. | ||
/// </summary> | ||
public const string Signature = "MBMB"; | ||
|
||
/// <summary> | ||
/// Unknown array with 20 byte elements. | ||
/// </summary> | ||
public List<byte[]> Entries = []; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBMB"/> class. | ||
/// </summary> | ||
public MBMB() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBMB"/> class. | ||
/// </summary> | ||
/// <param name="inData">ExtendedData.</param> | ||
public MBMB(byte[] inData) | ||
{ | ||
LoadBinaryData(inData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LoadBinaryData(byte[] inData) | ||
{ | ||
using (var ms = new MemoryStream(inData)) | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
var mbmbCount = br.BaseStream.Length / 20; | ||
for (var i = 0; i < mbmbCount; ++i) | ||
{ | ||
Entries.Add(br.ReadBytes(20)); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string GetSignature() | ||
{ | ||
return Signature; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public uint GetSize() | ||
{ | ||
return (uint)Serialize().Length; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
foreach (var entry in Entries) | ||
{ | ||
bw.Write(entry); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using Warcraft.NET.Files.ADT.Entries.Legion; | ||
using Warcraft.NET.Files.Interfaces; | ||
|
||
namespace Warcraft.NET.Files.ADT.Chunks.Legion | ||
{ | ||
/// <summary> | ||
/// MBMH Chunk - Level of detail | ||
/// </summary> | ||
public class MBMH : IIFFChunk, IBinarySerializable | ||
{ | ||
/// <summary> | ||
/// Holds the binary chunk signature. | ||
/// </summary> | ||
public const string Signature = "MBMH"; | ||
|
||
/// <summary> | ||
/// Gets or sets <see cref="MBMHEntry"/>s. | ||
/// </summary> | ||
public List<MBMHEntry> MBMHEntries { get; set; } = []; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBMH"/> class. | ||
/// </summary> | ||
public MBMH() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBMH"/> class. | ||
/// </summary> | ||
/// <param name="inData">ExtendedData.</param> | ||
public MBMH(byte[] inData) | ||
{ | ||
LoadBinaryData(inData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LoadBinaryData(byte[] inData) | ||
{ | ||
using (var ms = new MemoryStream(inData)) | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
var objCount = br.BaseStream.Length / MBMHEntry.GetSize(); | ||
|
||
for (var i = 0; i < objCount; ++i) | ||
{ | ||
MBMHEntries.Add(new MBMHEntry(br.ReadBytes(MBMHEntry.GetSize()))); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string GetSignature() | ||
{ | ||
return Signature; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public uint GetSize() | ||
{ | ||
return (uint)Serialize().Length; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
foreach (var mbmhEntry in MBMHEntries) | ||
{ | ||
bw.Write(mbmhEntry.Serialize()); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
using System.IO; | ||
using Warcraft.NET.Files.Interfaces; | ||
|
||
namespace Warcraft.NET.Files.ADT.Chunks.Legion | ||
{ | ||
/// <summary> | ||
/// MBMI Chunk - Level of detail | ||
/// </summary> | ||
public class MBMI : IIFFChunk, IBinarySerializable | ||
{ | ||
/// <summary> | ||
/// Holds the binary chunk signature. | ||
/// </summary> | ||
public const string Signature = "MBMI"; | ||
|
||
/// <summary> | ||
/// Blend Mesh indices. | ||
/// </summary> | ||
public ushort[] BlendMeshIndices { get; set; } | ||
|
||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBMI"/> class. | ||
/// </summary> | ||
public MBMI() | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="MBMI"/> class. | ||
/// </summary> | ||
/// <param name="inData">ExtendedData.</param> | ||
public MBMI(byte[] inData) | ||
{ | ||
LoadBinaryData(inData); | ||
} | ||
|
||
/// <inheritdoc/> | ||
public void LoadBinaryData(byte[] inData) | ||
{ | ||
using (var ms = new MemoryStream(inData)) | ||
using (var br = new BinaryReader(ms)) | ||
{ | ||
var count = (int)(ms.Length / 2); | ||
BlendMeshIndices = new ushort[count]; | ||
for (var i = 0; i < count; i++) | ||
{ | ||
BlendMeshIndices[i] = br.ReadUInt16(); | ||
} | ||
} | ||
} | ||
|
||
/// <inheritdoc/> | ||
public string GetSignature() | ||
{ | ||
return Signature; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public uint GetSize() | ||
{ | ||
return (uint)Serialize().Length; | ||
} | ||
|
||
/// <inheritdoc/> | ||
public byte[] Serialize(long offset = 0) | ||
{ | ||
using (var ms = new MemoryStream()) | ||
using (var bw = new BinaryWriter(ms)) | ||
{ | ||
foreach (var index in BlendMeshIndices) | ||
{ | ||
bw.Write(index); | ||
} | ||
return ms.ToArray(); | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.