diff --git a/Warcraft.NET.Docs/Program.cs b/Warcraft.NET.Docs/Program.cs index 867c66f..2ab861e 100644 --- a/Warcraft.NET.Docs/Program.cs +++ b/Warcraft.NET.Docs/Program.cs @@ -12,20 +12,6 @@ internal class Program /// static void Main(string[] args) { - string iripath = "C:\\Users\\marce\\Desktop\\WoWStuff\\wow.export\\creature\\iridikron\\"; - byte[] data = File.ReadAllBytes(iripath+"iridikron.m2"); - Model m = new Model(data); - - byte[] phys_test = File.ReadAllBytes("D:\\Unity Projects\\M2Tool\\M2Godot\\buckle_panstart_a_01.phys"); - Physics phys = new Physics(phys_test); - - File.WriteAllBytes(iripath+"iridikron_output.m2", m.Serialize()); - File.WriteAllBytes("D:\\Unity Projects\\M2Tool\\M2Godot\\buckle_panstart_a_01_output.phys", phys.Serialize()); - - - - if (1==2) { - Console.WriteLine($"BaseDirectory: {AppDomain.CurrentDomain.BaseDirectory}"); @@ -45,7 +31,7 @@ static void Main(string[] args) ConvertToMarkdownStep.Process(autoDocData, outputFolder); Console.WriteLine("Done!"); - } - } + + } } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/LDV1.cs b/Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs similarity index 92% rename from Warcraft.NET/Files/M2/Chunks/Legion/LDV1.cs rename to Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs index 92eb4eb..f640b86 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/LDV1.cs +++ b/Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs @@ -4,9 +4,9 @@ using Warcraft.NET.Files.Interfaces; using Warcraft.NET.Files.M2.Entries; -namespace Warcraft.NET.Files.M2.Chunks.Legion +namespace Warcraft.NET.Files.M2.Chunks.BfA { - [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterLegion, AutoDocChunkVersionHelper.VersionBeforeBfA)] public class LDV1 : IIFFChunk, IBinarySerializable { /// diff --git a/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs b/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs new file mode 100644 index 0000000..fbc23dc --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.BfA +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterLegion, AutoDocChunkVersionHelper.VersionBeforeBfA)] + public class WFV1 : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "WFV1"; + + public byte[] data; + + /// + /// Initializes a new instance of + /// + public WFV1() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public WFV1(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + data = inData; + } + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + bw.Write(data); + + + return ms.ToArray(); + } + } + + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/BfA/WFV2.cs b/Warcraft.NET/Files/M2/Chunks/BfA/WFV2.cs new file mode 100644 index 0000000..af31db9 --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/BfA/WFV2.cs @@ -0,0 +1,62 @@ +using System.Collections.Generic; +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.BfA +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterLegion, AutoDocChunkVersionHelper.VersionBeforeBfA)] + public class WFV2 : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "WFV2"; + + public byte[] data; + + /// + /// Initializes a new instance of + /// + public WFV2() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public WFV2(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + data = inData; + } + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + bw.Write(data); + + + return ms.ToArray(); + } + } + + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/DF/AFRA.cs b/Warcraft.NET/Files/M2/Chunks/DF/AFRA.cs new file mode 100644 index 0000000..1fad62d --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/DF/AFRA.cs @@ -0,0 +1,58 @@ +using System.Collections.Generic; +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.DF +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterSL, AutoDocChunkVersionHelper.VersionBeforeDF)] + public class AFRA : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "AFRA"; + + /// + /// Initializes a new instance of + /// + public AFRA() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public AFRA(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + byte[] data; + + /// + public void LoadBinaryData(byte[] inData) + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + data = inData; + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + bw.Write(data); + + return ms.ToArray(); + } + } + } +} diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs new file mode 100644 index 0000000..276cae0 --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs @@ -0,0 +1,72 @@ +using System; +using System.Collections.Generic; +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.Legion +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + public class PABC : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "PABC"; + + /// + /// Gets or sets the Skin FileDataId + /// + public List PABCEntries = new(); + + /// + /// Initializes a new instance of + /// + public PABC() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public PABC(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + var PABCcount = br.BaseStream.Length / 2; + for (var i = 0; i < PABCcount; ++i) + { + PABCEntries.Add(br.ReadUInt16()); + } + } + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + foreach (UInt16 obj in PABCEntries) + { + bw.Write(obj); + } + + return ms.ToArray(); + } + } + + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PADC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PADC.cs new file mode 100644 index 0000000..e12ef1e --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PADC.cs @@ -0,0 +1,55 @@ +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; + +namespace Warcraft.NET.Files.M2.Chunks.Legion +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + public class PADC : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "PADC"; + + byte[] data; + /// + /// Initializes a new instance of + /// + public PADC() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public PADC(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + data = inData; + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + bw.Write(data); + + return ms.ToArray(); + } + } + } +} diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs new file mode 100644 index 0000000..372973a --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs @@ -0,0 +1,55 @@ +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; + +namespace Warcraft.NET.Files.M2.Chunks.Legion +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + public class PEDC : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "PEDC"; + + byte[] data; + /// + /// Initializes a new instance of + /// + public PEDC() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public PEDC(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + data = inData; + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + bw.Write(data); + + return ms.ToArray(); + } + } + } +} diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs new file mode 100644 index 0000000..9070431 --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs @@ -0,0 +1,55 @@ +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; + +namespace Warcraft.NET.Files.M2.Chunks.Legion +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + public class PSBC : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "PSBC"; + + byte[] data; + /// + /// Initializes a new instance of + /// + public PSBC() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public PSBC(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + data = inData; + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + bw.Write(data); + + return ms.ToArray(); + } + } + } +} diff --git a/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs b/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs index cccf08c..7bf4c9e 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs @@ -6,7 +6,7 @@ namespace Warcraft.NET.Files.M2.Chunks.Legion { - [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class DBOC : IIFFChunk, IBinarySerializable { /// diff --git a/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs b/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs new file mode 100644 index 0000000..d9fa1ed --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.SL +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] + public class DETL : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "DETL"; + + /// + /// Gets or sets the Skin FileDataId + /// + public List DETLEntries = new(); + + /// + /// Initializes a new instance of + /// + public DETL() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public DETL(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + var DETLcount = br.BaseStream.Length / DETLEntry.GetSize(); + for (var i = 0; i < DETLcount; ++i) + { + DETLEntries.Add(new DETLEntry(br.ReadBytes(DETLEntry.GetSize()))); + } + } + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + foreach (DETLEntry obj in DETLEntries) + { + bw.Write(obj.Serialize()); + } + + return ms.ToArray(); + } + } + + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/SL/EDGF.cs b/Warcraft.NET/Files/M2/Chunks/SL/EDGF.cs index 311763c..d5a93d8 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/EDGF.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/EDGF.cs @@ -6,7 +6,7 @@ namespace Warcraft.NET.Files.M2.Chunks.Legion { - [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class EDGF : IIFFChunk, IBinarySerializable { /// diff --git a/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs b/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs new file mode 100644 index 0000000..8ebf09b --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs @@ -0,0 +1,73 @@ +using System.Collections.Generic; +using System.IO; +using System.Numerics; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.Legion +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] + public class NERF : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "NERF"; + + /// + /// Gets or sets the Skin FileDataId + /// + public List NERFEntries = new(); + + /// + /// Initializes a new instance of + /// + public NERF() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public NERF(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + var NERFcount = br.BaseStream.Length / 8; + for (var i = 0; i < NERFcount; ++i) + { + NERFEntries.Add(new Vector2(br.ReadSingle(), br.ReadSingle())); + } + } + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + foreach (Vector2 obj in NERFEntries) + { + bw.Write(obj.X); + bw.Write(obj.Y); + } + + return ms.ToArray(); + } + } + + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/SL/WFV3.cs b/Warcraft.NET/Files/M2/Chunks/SL/WFV3.cs new file mode 100644 index 0000000..17ef33c --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/SL/WFV3.cs @@ -0,0 +1,71 @@ +using System.Collections.Generic; +using System.IO; +using Warcraft.NET.Attribute; +using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.M2.Entries; + +namespace Warcraft.NET.Files.M2.Chunks.SL +{ + [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] + public class WFV3 : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "WFV3"; + + /// + /// Gets or sets the Skin FileDataId + /// + public List WFV3Entries = new(); + + /// + /// Initializes a new instance of + /// + public WFV3() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public WFV3(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + { + using (var ms = new MemoryStream(inData)) + using (var br = new BinaryReader(ms)) + { + var WFV3count = br.BaseStream.Length / WFV3Entry.GetSize(); + for (var i = 0; i < WFV3count; ++i) + { + WFV3Entries.Add(new WFV3Entry(br.ReadBytes(WFV3Entry.GetSize()))); + } + } + } + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) + { + foreach (WFV3Entry obj in WFV3Entries) + { + bw.Write(obj.Serialize()); + } + + return ms.ToArray(); + } + } + + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/DETLEntry.cs b/Warcraft.NET/Files/M2/Entries/DETLEntry.cs new file mode 100644 index 0000000..cdbb8b3 --- /dev/null +++ b/Warcraft.NET/Files/M2/Entries/DETLEntry.cs @@ -0,0 +1,65 @@ +using System; +using System.IO; + +namespace Warcraft.NET.Files.M2.Entries +{ + public class DETLEntry + { + public UInt16 flags; + public UInt16 packedFloat0; + public UInt16 packedFloat1; // multiplier for M2Light.diffuse_color + public UInt16 unk0; + public UInt32 unk1; + + /// + /// Initializes a new instance of the class. + /// + public DETLEntry() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// ExtendedData. + public DETLEntry(byte[] data) + { + using (var ms = new MemoryStream(data)) + using (var br = new BinaryReader(ms)) + { + flags = br.ReadUInt16(); + packedFloat0 = br.ReadUInt16(); + packedFloat1 = br.ReadUInt16(); + unk0 = br.ReadUInt16(); + unk1 = br.ReadUInt32(); + } + } + + /// + /// Gets the size of a AFRA Entry + /// + /// The size. + public static int GetSize() + { + return 12; + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + { + using (var bw = new BinaryWriter(ms)) + { + bw.Write(flags); + bw.Write(packedFloat0); + bw.Write(packedFloat1); + bw.Write(unk0); + bw.Write(unk1); + } + + return ms.ToArray(); + } + } + } +} diff --git a/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs b/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs new file mode 100644 index 0000000..f8eb38a --- /dev/null +++ b/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs @@ -0,0 +1,128 @@ +using System; +using System.IO; +using Warcraft.NET.Files.Structures; + +namespace Warcraft.NET.Files.M2.Entries +{ + public class WFV3Entry + { + public float bumpScale; //Passed to vertex shader + public float value0_x; + public float value0_y; + public float value0_z; + public float value1_w; + public float value0_w; + public float value1_x; + public float value1_y; + public float value2_w; + public float value3_y; + public float value3_x; + public CImVector baseColor; // in rgba (not bgra) + public UInt16 flags; + public UInt16 unk0; + public float value3_w; + public float value3_z; + public float value4_y; + public float unk1; + public float unk2; + public float unk3; + public float unk4; + + /// + /// Initializes a new instance of the class. + /// + public WFV3Entry() + { + } + + /// + /// Initializes a new instance of the class. + /// + /// ExtendedData. + public WFV3Entry(byte[] data) + { + using (var ms = new MemoryStream(data)) + using (var br = new BinaryReader(ms)) + { + bumpScale = br.ReadSingle(); + + value0_x = br.ReadSingle(); + value0_y = br.ReadSingle(); + value0_z = br.ReadSingle(); + value1_w = br.ReadSingle(); + + value0_w = br.ReadSingle(); + value1_x = br.ReadSingle(); + value1_y = br.ReadSingle(); + value2_w = br.ReadSingle(); + + value3_y = br.ReadSingle(); + value3_x = br.ReadSingle(); + + baseColor = new CImVector(br.ReadBytes(4)); + + flags = br.ReadUInt16(); + unk0 = br.ReadUInt16(); + + value3_w = br.ReadSingle(); + value3_z = br.ReadSingle(); + value4_y = br.ReadSingle(); + + unk1 = br.ReadSingle(); + unk2 = br.ReadSingle(); + unk3 = br.ReadSingle(); + unk4 = br.ReadSingle(); + } + } + + /// + /// Gets the size of a WFV3 Entry + /// + /// The size. + public static int GetSize() + { + return 80; + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + { + using (var bw = new BinaryWriter(ms)) + { + bw.Write(bumpScale); + + bw.Write(value0_x); + bw.Write(value0_y); + bw.Write(value0_z); + bw.Write(value1_w); + + bw.Write(value0_w); + bw.Write(value1_x); + bw.Write(value1_y); + bw.Write(value2_w); + + bw.Write(value3_y); + bw.Write(value3_x); + + bw.Write(baseColor.toBytes()); + + bw.Write(flags); + bw.Write(unk0); + + bw.Write(value3_w); + bw.Write(value3_z); + bw.Write(value4_y); + + bw.Write(unk1); + bw.Write(unk2); + bw.Write(unk3); + bw.Write(unk4); + } + + return ms.ToArray(); + } + } + } +} diff --git a/Warcraft.NET/Files/M2/Model.cs b/Warcraft.NET/Files/M2/Model.cs index 61b8a5d..fb75684 100644 --- a/Warcraft.NET/Files/M2/Model.cs +++ b/Warcraft.NET/Files/M2/Model.cs @@ -1,6 +1,7 @@ using Warcraft.NET.Attribute; using Warcraft.NET.Files.M2.Chunks; using Warcraft.NET.Files.M2.Chunks.BfA; +using Warcraft.NET.Files.M2.Chunks.DF; using Warcraft.NET.Files.M2.Chunks.Legion; using Warcraft.NET.Files.M2.Chunks.SL; @@ -9,25 +10,25 @@ namespace Warcraft.NET.Files.M2 [AutoDocFile("m2")] public class Model : ChunkedFile { + /// /// Gets or sets the model information /// [ChunkOrder(1)] - public MD21 ModelInformation { get; set; } - - [ChunkOptional] - public TXAC TXAC { get; set; } - - //[ChunkOptional] - //public PEDC PEDC { get; set; } - - + public MD21 ModelInformation { get; set; } + + /// + /// Gets or sets the model phys file ids + /// [ChunkOptional] - public EXPT EXP2 { get; set; } + public PFID PhysFileIds { get; set; } + /// + /// Gets or sets the model skin file ids + /// [ChunkOptional] - public PGD1 PGD1 { get; set; } - + public SFID SkinFileIds { get; set; } + /// /// Gets or sets the model anim file ids /// @@ -41,19 +42,22 @@ public class Model : ChunkedFile public BFID BoneFileIds { get; set; } [ChunkOptional] - public LDV1 LDV1 { get; set; } - + public TXAC CParticleEmitter2 { get; set; } + [ChunkOptional] - public EDGF EDGF { get; set; } + public EXPT ExtendedParticle { get; set; } - /// - /// Gets or sets the model physics - /// - [ChunkOptional] - public PFDC ModelPhysics { get; set; } + //[ChunkOptional] + //public EXP2 ExtendedParticle2 { get; set; } [ChunkOptional] - public DBOC DBOC { get; set; } + public PABC M2InitBlacklistAnimData { get; set; }//Unfinished + [ChunkOptional] + public PADC M2InitParentAnimData { get; set; } //Unfinished + [ChunkOptional] + public PSBC M2InitParentSequencyBoundsData { get; set; }//Unfinished + [ChunkOptional] + public PEDC M2InitParentEventData { get; set; }//Unfinished /// /// Gets or sets the model skeleton file ids @@ -62,40 +66,68 @@ public class Model : ChunkedFile public SKID SkeletonFileIds { get; set; } /// - /// Gets or sets the model skin file ids + /// Gets or sets the texture file ids /// [ChunkOptional] - public SFID SkinFileIds { get; set; } + public TXID TextureFileIds { get; set; } + + [ChunkOptional] + public LDV1 LodDataVersion1 { get; set; } /// - /// Gets or sets the model phys file ids + /// Gets or sets the model recursive particle file ids /// [ChunkOptional] - public PFID PhysFileIds { get; set; } + public RPID RecursiveParticleFileIds { get; set; } /// - /// Gets or sets the texture file ids + /// Gets or sets the model geometry particle file ids /// [ChunkOptional] - public TXID TextureFileIds { get; set; } + public GPID GeometryParticleFileIds { get; set; } + [ChunkOptional] + public WFV1 WaterFallVersion1 { get; set; } - //[ChunkOptional] - //public PSBC PSBC { get; set; } + [ChunkOptional] + public WFV2 WaterFallVersion2 { get; set; } + [ChunkOptional] + public PGD1 ParticleGeosetData { get; set; } + [ChunkOptional] + public WFV3 WaterFallVersion3 { get; set; } /// - /// Gets or sets the model recursive particle file ids + /// Gets or sets the model physics /// [ChunkOptional] - public RPID RecursiveParticleFileIds { get; set; } + public PFDC ModelPhysics { get; set; } - /// - /// Gets or sets the model geometry particle file ids - /// [ChunkOptional] - public GPID GeometryParticleFileIds { get; set; } + public EDGF EdgeFade { get; set; } + + [ChunkOptional] + public NERF NERF { get; set; } + + [ChunkOptional] + public DETL DETL { get; set; } + + [ChunkOptional] + public DBOC DBOC { get; set; } + + [ChunkOptional] + public AFRA AFRA { get; set; } + + + + + + + + + + diff --git a/Warcraft.NET/Files/SKIN/Skin.cs b/Warcraft.NET/Files/SKIN/Skin.cs index 42f6f6f..d9ffd88 100644 --- a/Warcraft.NET/Files/SKIN/Skin.cs +++ b/Warcraft.NET/Files/SKIN/Skin.cs @@ -45,7 +45,7 @@ public Skin(byte[] inData) byte[] Serialize() { - + return null; } } diff --git a/Warcraft.NET/Files/Structures/CImVector.cs b/Warcraft.NET/Files/Structures/CImVector.cs new file mode 100644 index 0000000..ad01d56 --- /dev/null +++ b/Warcraft.NET/Files/Structures/CImVector.cs @@ -0,0 +1,50 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Numerics; +using System.Text; +using Warcraft.NET.Files.Interfaces; + +namespace Warcraft.NET.Files.Structures +{ + public struct CImVector : IFlattenableData + { + public byte r, g, b, a; + + public CImVector(byte _r, byte _g, byte _b, byte _a) + { + r = _r; + g = _g; + b = _b; + a = _a; + } + + public byte[] toBytes() + { + byte[] arr = new byte[4] { r, g, b, a }; + return arr; + } + + public CImVector(byte[] input) + { + if (input.Length == 4) + { + r = input[0]; + g = input[1]; + b = input[2]; + a = input[3]; + } + } + + /// + public override string ToString() + { + return $"{r}, {g}, {b}, {a}"; + } + + public IReadOnlyCollection Flatten() + { + return new[] { r,g,b,a }; + } + } +} diff --git a/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs b/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs index e147c77..6e9bab5 100644 --- a/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs @@ -6,7 +6,14 @@ namespace Warcraft.NET.Files.phys.Entries public class BDY4Entry { - public ushort type { get; set; } // maps to dmBodyDef type enum. 0 -> 1, 1 -> 0 = dm_dynamicBody, * -> 2. Only one should be of type 0 (root). possibly only 0 and 1. + public enum Body_Type : ushort + { + root = 0, + dynamic = 1, + unk = 2, + } + + public Body_Type type { get; set; } // maps to dmBodyDef type enum. 0 -> 1, 1 -> 0 = dm_dynamicBody, * -> 2. Only one should be of type 0 (root). possibly only 0 and 1. public ushort boneIndex { get; set; } public C3Vector position { get; set; } public ushort shapeIndex { get; set; } @@ -38,7 +45,7 @@ public BDY4Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - type = br.ReadUInt16(); + type = (Body_Type)br.ReadUInt16(); boneIndex = br.ReadUInt16(); position = new C3Vector(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); shapeIndex = br.ReadUInt16(); @@ -69,7 +76,7 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(type); + bw.Write((ushort)type); bw.Write(boneIndex); bw.Write(position.X); bw.Write(position.Y); diff --git a/Warcraft.NET/Files/phys/Entries/JOINEntry.cs b/Warcraft.NET/Files/phys/Entries/JOINEntry.cs index 6df6551..d0f57c3 100644 --- a/Warcraft.NET/Files/phys/Entries/JOINEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/JOINEntry.cs @@ -4,15 +4,25 @@ namespace Warcraft.NET.Files.phys.Entries { + + public class JOINEntry { - + public enum Joint_Type : ushort + { + sphericalJoint = 0, + shoulderJoint = 1, + weldJoint = 2, + revoluteJoint = 3, + prismaticJoint = 4, + distanceJoint = 5, + } public uint bodyAIdx; public uint bodyBIdx; public byte[] unk; - public ushort jointType; + public Joint_Type jointType; public ushort jointId; /// @@ -32,7 +42,7 @@ public JOINEntry(byte[] data) bodyAIdx = br.ReadUInt32(); bodyBIdx = br.ReadUInt32(); unk = br.ReadBytes(4); - jointType = br.ReadUInt16(); + jointType = (Joint_Type)br.ReadUInt16(); jointId = br.ReadUInt16(); } } @@ -56,7 +66,7 @@ public byte[] Serialize(long offset = 0) bw.Write(bodyAIdx); bw.Write(bodyBIdx); bw.Write(unk); - bw.Write(jointType); + bw.Write((ushort)jointType); bw.Write(jointId); } diff --git a/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs b/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs index a3f8057..5f1efe3 100644 --- a/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs @@ -4,12 +4,21 @@ namespace Warcraft.NET.Files.phys.Entries { + + + public class SHP2Entry { - + public enum Shape_Type : short + { + box = 0, + caps = 1, + sphere = 2, + polytope = 3, + } /*0x00*/ - public ushort shapeType; + public Shape_Type shapeType; /*0x02*/ public ushort shapeIndex; // into the corresponding chunk /*0x04*/ @@ -45,7 +54,7 @@ public SHP2Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - shapeType = br.ReadUInt16(); + shapeType = (Shape_Type)br.ReadUInt16(); shapeIndex = br.ReadUInt16(); unk = br.ReadBytes(4); friction = br.ReadSingle(); @@ -74,7 +83,7 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(shapeType); + bw.Write((ushort)shapeType); bw.Write(shapeIndex); bw.Write(unk); bw.Write(friction); @@ -89,5 +98,7 @@ public byte[] Serialize(long offset = 0) return ms.ToArray(); } } + + } } diff --git a/Warcraft.NET/Files/phys/Physics.cs b/Warcraft.NET/Files/phys/Physics.cs index ee27189..343102b 100644 --- a/Warcraft.NET/Files/phys/Physics.cs +++ b/Warcraft.NET/Files/phys/Physics.cs @@ -9,10 +9,10 @@ public class Physics : ChunkedFile [ChunkOrder(1)] public PHYS phys{get; set;} - [ChunkOrder(2)] + [ChunkOptional] public PHYT phyt{get; set;} - [ChunkOptional] + [ChunkOptional] public BOXS boxs{get;set;} [ChunkOptional] @@ -30,28 +30,18 @@ public class Physics : ChunkedFile [ChunkOptional] public BDY4 bdy4{get; set;} - - - - - [ChunkOptional] public SHOJ shoj { get; set; } [ChunkOptional] public SHJ2 shj2{get; set;} - - [ChunkOptional] public WLJ3 wlj3{get; set;} [ChunkOptional] public SPHJ sphj{get; set;} - - - [ChunkOptional] public PRS2 prs2{get; set;}