diff --git a/Warcraft.NET/Extensions/ExtendedIO.cs b/Warcraft.NET/Extensions/ExtendedIO.cs index 86bc251..4d96681 100644 --- a/Warcraft.NET/Extensions/ExtendedIO.cs +++ b/Warcraft.NET/Extensions/ExtendedIO.cs @@ -78,6 +78,22 @@ public static Vector3 ReadVector3(this BinaryReader binaryReader, AxisConfigurat } } + /// + /// Reads a 48-byte structure from the data stream and advances the position of the stream by + /// 48 bytes. + /// + /// The Mat3x4. + /// The reader. + /// Which axis configuration the read mat3x4 should be converted to. + public static Matrix3x4 ReadMatrix3x4(this BinaryReader binaryReader, AxisConfiguration convertTo = AxisConfiguration.YUp) + { + var a = binaryReader.ReadVector3(convertTo); + var b = binaryReader.ReadVector3(convertTo); + var c = binaryReader.ReadVector3(convertTo); + var pos = binaryReader.ReadVector3(convertTo); + return new Matrix3x4(a, b, c, pos); + } + /// /// Reads a 12-byte from the data stream and advances the position of the stream by /// 12 bytes. @@ -273,37 +289,37 @@ public static ShortVector3 ReadShortVector3(this BinaryReader binaryReader, Axis switch (convertTo) { case AxisConfiguration.Native: - { - return new ShortVector3(binaryReader.ReadInt16(), binaryReader.ReadInt16(), binaryReader.ReadInt16()); - } + { + return new ShortVector3(binaryReader.ReadInt16(), binaryReader.ReadInt16(), binaryReader.ReadInt16()); + } case AxisConfiguration.YUp: - { - var x1 = binaryReader.ReadInt16(); - var y1 = binaryReader.ReadInt16(); - var z1 = binaryReader.ReadInt16(); + { + var x1 = binaryReader.ReadInt16(); + var y1 = binaryReader.ReadInt16(); + var z1 = binaryReader.ReadInt16(); - var x = x1; - var y = z1; - var z = (short)-y1; + var x = x1; + var y = z1; + var z = (short)-y1; - return new ShortVector3(x, y, z); - } + return new ShortVector3(x, y, z); + } case AxisConfiguration.ZUp: - { - var x1 = binaryReader.ReadInt16(); - var y1 = binaryReader.ReadInt16(); - var z1 = binaryReader.ReadInt16(); + { + var x1 = binaryReader.ReadInt16(); + var y1 = binaryReader.ReadInt16(); + var z1 = binaryReader.ReadInt16(); - var x = x1; - var y = (short)-z1; - var z = y1; + var x = x1; + var y = (short)-z1; + var z = y1; - return new ShortVector3(x, y, z); - } + return new ShortVector3(x, y, z); + } default: - { - throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null); - } + { + throw new ArgumentOutOfRangeException(nameof(convertTo), convertTo, null); + } } } @@ -565,6 +581,25 @@ public static void WriteVector3(this BinaryWriter binaryWriter, Vector3 vector, } } + /// + /// Writes a 48-byte value to the data stream. This function + /// + /// The current object. + /// The Vector to write. + /// Which axis configuration the read vector should be stored as. + public static void WriteMatrix3x4(this BinaryWriter binaryWriter, Matrix3x4 matrix, AxisConfiguration storeAs = AxisConfiguration.ZUp) + { + var column1 = matrix.RotationX * matrix.Scale.X; + var column2 = matrix.RotationY * matrix.Scale.Y; + var column3 = matrix.RotationZ * matrix.Scale.Z; + var column4 = matrix.Position; + + binaryWriter.WriteVector3(column1, storeAs); + binaryWriter.WriteVector3(column2, storeAs); + binaryWriter.WriteVector3(column3, storeAs); + binaryWriter.WriteVector3(column4, storeAs); + } + /// /// Writes a 16-byte to the data stream. /// @@ -602,23 +637,23 @@ public static void WriteShortVector3(this BinaryWriter binaryWriter, ShortVector { case AxisConfiguration.Native: case AxisConfiguration.YUp: - { - binaryWriter.Write(vector.X); - binaryWriter.Write(vector.Y); - binaryWriter.Write(vector.Z); - break; - } + { + binaryWriter.Write(vector.X); + binaryWriter.Write(vector.Y); + binaryWriter.Write(vector.Z); + break; + } case AxisConfiguration.ZUp: - { - binaryWriter.Write(vector.X); - binaryWriter.Write((short)(vector.Z * -1)); - binaryWriter.Write(vector.Y); - break; - } + { + binaryWriter.Write(vector.X); + binaryWriter.Write((short)(vector.Z * -1)); + binaryWriter.Write(vector.Y); + break; + } default: - { - throw new ArgumentOutOfRangeException(nameof(storeAs), storeAs, null); - } + { + throw new ArgumentOutOfRangeException(nameof(storeAs), storeAs, null); + } } } diff --git a/Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs b/Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs index f640b86..44a7e33 100644 --- a/Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs +++ b/Warcraft.NET/Files/M2/Chunks/BfA/LDV1.cs @@ -15,7 +15,7 @@ public class LDV1 : IIFFChunk, IBinarySerializable public const string Signature = "LDV1"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the Lod Data Version 1 Entries /// public List LDV1Entries = new(); @@ -62,10 +62,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj.Serialize()); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/BfA/TXID.cs b/Warcraft.NET/Files/M2/Chunks/BfA/TXID.cs index 37daeb6..4f06227 100644 --- a/Warcraft.NET/Files/M2/Chunks/BfA/TXID.cs +++ b/Warcraft.NET/Files/M2/Chunks/BfA/TXID.cs @@ -61,4 +61,4 @@ public byte[] Serialize(long offset = 0) } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs b/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs index fbc23dc..ee2e459 100644 --- a/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs +++ b/Warcraft.NET/Files/M2/Chunks/BfA/WFV1.cs @@ -14,7 +14,10 @@ public class WFV1 : IIFFChunk, IBinarySerializable /// public const string Signature = "WFV1"; - public byte[] data; + /// + /// Gets or sets the full data (deserialization NYI) + /// + public byte[] Data; /// /// Initializes a new instance of @@ -36,27 +39,13 @@ public WFV1() { } /// public void LoadBinaryData(byte[] inData) { - { - using (var ms = new MemoryStream(inData)) - using (var br = new BinaryReader(ms)) - { - data = inData; - } - } + 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(); - } + return Data; } - } } \ 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 index af31db9..3eacdc2 100644 --- a/Warcraft.NET/Files/M2/Chunks/BfA/WFV2.cs +++ b/Warcraft.NET/Files/M2/Chunks/BfA/WFV2.cs @@ -14,7 +14,10 @@ public class WFV2 : IIFFChunk, IBinarySerializable /// public const string Signature = "WFV2"; - public byte[] data; + /// + /// Gets or sets the full data (deserialization NYI) + /// + public byte[] Data; /// /// Initializes a new instance of @@ -36,27 +39,13 @@ public WFV2() { } /// public void LoadBinaryData(byte[] inData) { - { - using (var ms = new MemoryStream(inData)) - using (var br = new BinaryReader(ms)) - { - data = inData; - } - } + 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(); - } + return Data; } - } } \ 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 index 1fad62d..3225f66 100644 --- a/Warcraft.NET/Files/M2/Chunks/DF/AFRA.cs +++ b/Warcraft.NET/Files/M2/Chunks/DF/AFRA.cs @@ -1,12 +1,7 @@ -using System.Collections.Generic; -using System.IO; -using Warcraft.NET.Attribute; -using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.M2.Entries; +using Warcraft.NET.Files.Interfaces; namespace Warcraft.NET.Files.M2.Chunks.DF { - [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterSL, AutoDocChunkVersionHelper.VersionBeforeDF)] public class AFRA : IIFFChunk, IBinarySerializable { /// @@ -14,6 +9,11 @@ public class AFRA : IIFFChunk, IBinarySerializable /// public const string Signature = "AFRA"; + /// + /// Gets or sets the full data (deserialization NYI) + /// + public byte[] Data; + /// /// Initializes a new instance of /// @@ -29,30 +29,21 @@ public AFRA() { } public string GetSignature() { return Signature; } /// - public uint GetSize() { return (uint)Serialize().Length; } - - byte[] data; + 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; - } + 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(); - } + return Data; } } } diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/AFID.cs b/Warcraft.NET/Files/M2/Chunks/Legion/AFID.cs index 91d0185..b3a175e 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/AFID.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/AFID.cs @@ -61,9 +61,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj.Serialize()); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/BFID.cs b/Warcraft.NET/Files/M2/Chunks/Legion/BFID.cs index 26b13ca..888cdc6 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/BFID.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/BFID.cs @@ -42,7 +42,6 @@ public void LoadBinaryData(byte[] inData) using (var br = new BinaryReader(ms)) { uint nBone = (uint)inData.Length / 4; - for (var i = 0; i < nBone; i++) BoneFileDataIds.Add(br.ReadUInt32()); } @@ -56,9 +55,8 @@ public byte[] Serialize(long offset = 0) { foreach(uint boneFileDataId in BoneFileDataIds) bw.Write(boneFileDataId); - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/EXP2.cs b/Warcraft.NET/Files/M2/Chunks/Legion/EXP2.cs new file mode 100644 index 0000000..155bdbc --- /dev/null +++ b/Warcraft.NET/Files/M2/Chunks/Legion/EXP2.cs @@ -0,0 +1,50 @@ +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 +{ + public class EXP2 : IIFFChunk, IBinarySerializable + { + /// + /// Holds the binary chunk signature. + /// + public const string Signature = "EXP2"; + + /// + /// Gets or sets the EXP2 Data + /// + public byte[] Data; + + /// + /// Initializes a new instance of + /// + public EXP2() { } + + /// + /// Initializes a new instance of + /// + /// ExtendedData. + public EXP2(byte[] inData) => LoadBinaryData(inData); + + /// + public string GetSignature() { return Signature; } + + /// + public uint GetSize() { return (uint)Serialize().Length; } + + /// + public void LoadBinaryData(byte[] inData) + { + Data = inData; + } + + /// + public byte[] Serialize(long offset = 0) + { + return Data; + } + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/EXPT.cs b/Warcraft.NET/Files/M2/Chunks/Legion/EXPT.cs index 6483a5a..bd4815b 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/EXPT.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/EXPT.cs @@ -15,7 +15,7 @@ public class EXPT : IIFFChunk, IBinarySerializable public const string Signature = "EXP2"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the EXPT Entries /// public List EXP2Entries = new(); @@ -62,10 +62,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj.Serialize()); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs index 276cae0..d010543 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PABC.cs @@ -1,9 +1,7 @@ -using System; -using System.Collections.Generic; +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 { @@ -16,9 +14,9 @@ public class PABC : IIFFChunk, IBinarySerializable public const string Signature = "PABC"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the ParentSequenceBounds Entries /// - public List PABCEntries = new(); + public List PABCEntries = new(); /// /// Initializes a new instance of @@ -59,14 +57,12 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - foreach (UInt16 obj in PABCEntries) + foreach (ushort 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 index e12ef1e..ec885fb 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/PADC.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PADC.cs @@ -1,10 +1,7 @@ -using System.IO; -using Warcraft.NET.Attribute; -using Warcraft.NET.Files.Interfaces; +using Warcraft.NET.Files.Interfaces; namespace Warcraft.NET.Files.M2.Chunks.Legion { - [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)] public class PADC : IIFFChunk, IBinarySerializable { /// @@ -12,7 +9,11 @@ public class PADC : IIFFChunk, IBinarySerializable /// public const string Signature = "PADC"; - byte[] data; + /// + /// Gets or sets the ParentAnimationData (deserialization NYI) + /// + public byte[] Data; + /// /// Initializes a new instance of /// @@ -33,23 +34,13 @@ public PADC() { } /// public void LoadBinaryData(byte[] inData) { - using (var ms = new MemoryStream(inData)) - using (var br = new BinaryReader(ms)) - { - data = inData; - } + 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(); - } + return Data; } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs index 372973a..3881430 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PEDC.cs @@ -1,5 +1,4 @@ -using System.IO; -using Warcraft.NET.Attribute; +using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; namespace Warcraft.NET.Files.M2.Chunks.Legion @@ -12,7 +11,11 @@ public class PEDC : IIFFChunk, IBinarySerializable /// public const string Signature = "PEDC"; - byte[] data; + /// + /// Gets or sets the ParentEventData (deserialization NYI) + /// + public byte[] Data; + /// /// Initializes a new instance of /// @@ -33,23 +36,13 @@ public PEDC() { } /// public void LoadBinaryData(byte[] inData) { - using (var ms = new MemoryStream(inData)) - using (var br = new BinaryReader(ms)) - { - data = inData; - } + 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(); - } + return Data; } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PFID.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PFID.cs index f92f272..729142a 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/PFID.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PFID.cs @@ -61,4 +61,4 @@ public byte[] Serialize(long offset = 0) } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PGD1.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PGD1.cs index 5502817..dba0ea2 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/PGD1.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PGD1.cs @@ -3,7 +3,6 @@ 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 { @@ -16,9 +15,9 @@ public class PGD1 : IIFFChunk, IBinarySerializable public const string Signature = "PGD1"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the ParticleGeosetData1 Entries /// - public List PGD1Entries = new(); + public List PGD1Entries = new(); /// /// Initializes a new instance of @@ -63,10 +62,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs index 9070431..570981b 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/PSBC.cs @@ -1,10 +1,8 @@ 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 { /// @@ -12,7 +10,11 @@ public class PSBC : IIFFChunk, IBinarySerializable /// public const string Signature = "PSBC"; - byte[] data; + /// + /// Gets or sets the ParentSequenceBounds (deserialization NYI) + /// + public byte[] Data; + /// /// Initializes a new instance of /// @@ -36,20 +38,14 @@ public void LoadBinaryData(byte[] inData) using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { - data = inData; + 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(); - } + return Data; } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/SFID.cs b/Warcraft.NET/Files/M2/Chunks/Legion/SFID.cs index bf6b4c3..90ff088 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/SFID.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/SFID.cs @@ -61,4 +61,4 @@ public byte[] Serialize(long offset = 0) } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/SKID.cs b/Warcraft.NET/Files/M2/Chunks/Legion/SKID.cs index abcda1d..1908f10 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/SKID.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/SKID.cs @@ -51,9 +51,8 @@ public byte[] Serialize(long offset = 0) using (var bw = new BinaryWriter(ms)) { bw.Write(SkeletonFileDataId); - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/Legion/TXAC.cs b/Warcraft.NET/Files/M2/Chunks/Legion/TXAC.cs index a4bcd8e..3ffe3d4 100644 --- a/Warcraft.NET/Files/M2/Chunks/Legion/TXAC.cs +++ b/Warcraft.NET/Files/M2/Chunks/Legion/TXAC.cs @@ -1,6 +1,7 @@ using System.IO; using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; +using System.Collections.Generic; namespace Warcraft.NET.Files.M2.Chunks.Legion { @@ -13,9 +14,12 @@ public class TXAC : IIFFChunk, IBinarySerializable public const string Signature = "TXAC"; /// - /// Gets or sets the Skin FileDataId + /// 2 byte array + /// From Wiki: + /// likely used in CM2SceneRender::SetupTextureTransforms and uploaded to the shader directly. 0 otherwise. + /// This chunk doesn't seem to be used directly. Inside CParticleEmitter2 class there are non-null checks that deal with selection of VertexBufferFormat for particles. Apart from that, the usage of these fields is unknown /// - public byte[] unk; + public List TXACEntries = new(); /// /// Initializes a new instance of @@ -40,7 +44,13 @@ public void LoadBinaryData(byte[] inData) using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { - unk = br.ReadBytes((int)br.BaseStream.Length); + for (int i = 0; i < inData.Length / 2; i++) + { + var entry = new byte[2]; + entry[0] = br.ReadByte(); + entry[1] = br.ReadByte(); + TXACEntries.Add(entry); + } } } @@ -50,10 +60,12 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - bw.Write(unk); - + foreach (var entry in TXACEntries) + { + bw.Write(entry); + } return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs b/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs index 7bf4c9e..912a6e0 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/DBOC.cs @@ -15,7 +15,7 @@ public class DBOC : IIFFChunk, IBinarySerializable public const string Signature = "DBOC"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the DBOC Entries /// public List DBOCEntries = new(); @@ -24,7 +24,7 @@ public class DBOC : IIFFChunk, IBinarySerializable /// public DBOC() { } - /// + /// /// Initializes a new instance of /// /// ExtendedData. @@ -62,10 +62,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj.Serialize()); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs b/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs index d9fa1ed..6a477a0 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/DETL.cs @@ -15,7 +15,7 @@ public class DETL : IIFFChunk, IBinarySerializable public const string Signature = "DETL"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the DETL Entries /// public List DETLEntries = new(); @@ -62,10 +62,8 @@ public byte[] Serialize(long offset = 0) { 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 d5a93d8..23634a1 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/EDGF.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/EDGF.cs @@ -15,7 +15,7 @@ public class EDGF : IIFFChunk, IBinarySerializable public const string Signature = "EDGF"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the EdgeFade Entries /// public List EDGFEntries = new(); @@ -62,10 +62,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj.Serialize()); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs b/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs index 8ebf09b..cdc76a2 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/NERF.cs @@ -3,7 +3,6 @@ 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 { @@ -16,7 +15,7 @@ public class NERF : IIFFChunk, IBinarySerializable public const string Signature = "NERF"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the NERF Entries /// public List NERFEntries = new(); @@ -64,10 +63,8 @@ public byte[] Serialize(long offset = 0) 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/PFDC.cs b/Warcraft.NET/Files/M2/Chunks/SL/PFDC.cs index f6ff583..5c8bb6b 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/PFDC.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/PFDC.cs @@ -1,9 +1,7 @@ -using System.Collections.Generic; -using System.IO; +using System; using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.M2.Entries; -using Warcraft.NET.Files.phys; +using Warcraft.NET.Files.Phys; namespace Warcraft.NET.Files.M2.Chunks.SL { @@ -16,9 +14,9 @@ public class PFDC : IIFFChunk, IBinarySerializable public const string Signature = "PFDC"; /// - /// Gets or sets the Physics of the chunk + /// Gets or sets the Physics for the M2 /// - public Physics physics { get; set; } = null; + public Physics Physics { get; set; } = null; /// /// Initializes a new instance of @@ -40,24 +38,27 @@ public PFDC() { } /// public void LoadBinaryData(byte[] inData) { - using (var ms = new MemoryStream(inData)) - using (var br = new BinaryReader(ms)) - { - physics = new Physics(inData); - //convert inData into >physics< - } + Physics = new Physics(inData); } - /// + /// public byte[] Serialize(long offset = 0) { - using (var ms = new MemoryStream()) - using (var bw = new BinaryWriter(ms)) + return PadTo8Bytes(Physics.Serialize()); + } + + static byte[] PadTo8Bytes(byte[] input) + { + int paddingNeeded = 8 - (input.Length % 8); + if (paddingNeeded == 8) + paddingNeeded = 0; + byte[] paddedArray = new byte[input.Length + paddingNeeded]; + Array.Copy(input, paddedArray, input.Length); + for (int i = input.Length; i < paddedArray.Length; i++) { - bw.Write(physics.Serialize()); - //convert >physics< into byte[] - return ms.ToArray(); + paddedArray[i] = 0x00; } + return paddedArray; } } } \ 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 index 17ef33c..c37dd2a 100644 --- a/Warcraft.NET/Files/M2/Chunks/SL/WFV3.cs +++ b/Warcraft.NET/Files/M2/Chunks/SL/WFV3.cs @@ -15,7 +15,7 @@ public class WFV3 : IIFFChunk, IBinarySerializable public const string Signature = "WFV3"; /// - /// Gets or sets the Skin FileDataId + /// Gets or sets the WaterFallVersion3 Entries /// public List WFV3Entries = new(); @@ -62,10 +62,8 @@ public byte[] Serialize(long offset = 0) { bw.Write(obj.Serialize()); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/AFIDEntry.cs b/Warcraft.NET/Files/M2/Entries/AFIDEntry.cs index 31a0080..6c85f43 100644 --- a/Warcraft.NET/Files/M2/Entries/AFIDEntry.cs +++ b/Warcraft.NET/Files/M2/Entries/AFIDEntry.cs @@ -9,7 +9,6 @@ public class AFIDEntry /// public ushort AnimationId { get; set; } - /// /// Gets or sets the sub animation id. /// @@ -20,7 +19,6 @@ public class AFIDEntry /// public uint FileDataId { get; set; } - /// /// Initializes a new instance of the class. /// @@ -49,7 +47,7 @@ public AFIDEntry(byte[] data) /// The size. public static int GetSize() { - return 8; + return 16; } /// @@ -68,4 +66,4 @@ public byte[] Serialize(long offset = 0) } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/DBOCEntry.cs b/Warcraft.NET/Files/M2/Entries/DBOCEntry.cs index c8c04a1..58a8bf5 100644 --- a/Warcraft.NET/Files/M2/Entries/DBOCEntry.cs +++ b/Warcraft.NET/Files/M2/Entries/DBOCEntry.cs @@ -1,21 +1,30 @@ -using System; -using System.IO; +using System.IO; namespace Warcraft.NET.Files.M2.Entries { public class DBOCEntry { - public float unk_float1; - public float unk_float2; - public UInt32 unk_int1; - public UInt32 unk_int2; + /// + /// unknown float + /// + public float Unk0; + /// + /// unknown float + /// + public float Unk1; + /// + /// unknown int + /// + public uint Unk2; + /// + /// unknown int + /// + public uint Unk3; /// /// Initializes a new instance of the class. /// - public DBOCEntry() - { - } + public DBOCEntry(){} /// /// Initializes a new instance of the class. @@ -26,10 +35,10 @@ public DBOCEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - unk_float1 = br.ReadSingle(); - unk_float2 = br.ReadSingle(); - unk_int1 = br.ReadUInt32(); - unk_int2 = br.ReadUInt32(); + Unk0 = br.ReadSingle(); + Unk1 = br.ReadSingle(); + Unk2 = br.ReadUInt32(); + Unk3 = br.ReadUInt32(); } } @@ -49,14 +58,13 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(unk_float1); - bw.Write(unk_float2); - bw.Write(unk_int1); - bw.Write(unk_int2); + bw.Write(Unk0); + bw.Write(Unk1); + bw.Write(Unk2); + bw.Write(Unk3); } - 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 index cdbb8b3..da70cdc 100644 --- a/Warcraft.NET/Files/M2/Entries/DETLEntry.cs +++ b/Warcraft.NET/Files/M2/Entries/DETLEntry.cs @@ -1,15 +1,33 @@ -using System; -using System.IO; +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; + /// + /// unknown Flags + /// + public ushort Flags; + + /// + /// multiplier for M2Light.diffuse_color + /// + public ushort PackedFloat0; + + /// + /// multiplier for M2Light.diffuse_color + /// + public ushort PackedFloat1; + + /// + /// unknown field + /// + public ushort Unk0; + + /// + /// unknown field + /// + public uint Unk1; /// /// Initializes a new instance of the class. @@ -27,11 +45,11 @@ 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(); + Flags = br.ReadUInt16(); + PackedFloat0 = br.ReadUInt16(); + PackedFloat1 = br.ReadUInt16(); + Unk0 = br.ReadUInt16(); + Unk1 = br.ReadUInt32(); } } @@ -51,15 +69,14 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(flags); - bw.Write(packedFloat0); - bw.Write(packedFloat1); - bw.Write(unk0); - bw.Write(unk1); + bw.Write(Flags); + bw.Write(PackedFloat0); + bw.Write(PackedFloat1); + bw.Write(Unk0); + bw.Write(Unk1); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/EDGFEntry.cs b/Warcraft.NET/Files/M2/Entries/EDGFEntry.cs index 5238753..346c50f 100644 --- a/Warcraft.NET/Files/M2/Entries/EDGFEntry.cs +++ b/Warcraft.NET/Files/M2/Entries/EDGFEntry.cs @@ -1,13 +1,23 @@ -using System; -using System.IO; +using System.IO; namespace Warcraft.NET.Files.M2.Entries { public class EDGFEntry { - public float[] _0x0; - public float _0x8; - public byte[] _0xC; + /// + /// unknown 2-floats array + /// + public float[] Unk0; + + /// + /// unknown float + /// + public float Unk1; + + /// + /// unknown 4 byte array + /// + public byte[] Unk2; /// /// Initializes a new instance of the class. @@ -25,11 +35,11 @@ public EDGFEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - _0x0 = new float[2]; - _0x0[0] = br.ReadSingle(); - _0x0[1] = br.ReadSingle(); - _0x8 = br.ReadSingle(); - _0xC = br.ReadBytes(4); + Unk0 = new float[2]; + Unk0[0] = br.ReadSingle(); + Unk0[1] = br.ReadSingle(); + Unk1 = br.ReadSingle(); + Unk2 = br.ReadBytes(4); } } @@ -49,14 +59,13 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(_0x0[0]); - bw.Write(_0x0[1]); - bw.Write(_0x8); - bw.Write(_0xC); + bw.Write(Unk0[0]); + bw.Write(Unk0[1]); + bw.Write(Unk1); + bw.Write(Unk2); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/EXPTEntry.cs b/Warcraft.NET/Files/M2/Entries/EXPTEntry.cs index 858929b..ece3be3 100644 --- a/Warcraft.NET/Files/M2/Entries/EXPTEntry.cs +++ b/Warcraft.NET/Files/M2/Entries/EXPTEntry.cs @@ -4,17 +4,23 @@ namespace Warcraft.NET.Files.M2.Entries { public class EXPTEntry { - public float zSource; - public float colorMult; - public float alphaMult; - + /// + /// replaces zSource from ParticleEmitter + /// + public float ZSource; + /// + /// colorMult is applied against particle's diffuse color + /// + public float ColorMult; + /// + ///alphaMult is applied against particle's opacity. + /// + public float AlphaMult; /// /// Initializes a new instance of the class. /// - public EXPTEntry() - { - } + public EXPTEntry() { } /// /// Initializes a new instance of the class. @@ -25,9 +31,9 @@ public EXPTEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - zSource = br.ReadSingle(); - colorMult = br.ReadSingle(); - alphaMult = br.ReadSingle(); + ZSource = br.ReadSingle(); + ColorMult = br.ReadSingle(); + AlphaMult = br.ReadSingle(); } } @@ -47,13 +53,12 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(zSource); - bw.Write(colorMult); - bw.Write(alphaMult); + bw.Write(ZSource); + bw.Write(ColorMult); + bw.Write(AlphaMult); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/LDV1Entry.cs b/Warcraft.NET/Files/M2/Entries/LDV1Entry.cs index e502496..007466f 100644 --- a/Warcraft.NET/Files/M2/Entries/LDV1Entry.cs +++ b/Warcraft.NET/Files/M2/Entries/LDV1Entry.cs @@ -1,16 +1,33 @@ -using System; -using System.IO; +using System.IO; namespace Warcraft.NET.Files.M2.Entries { public class LDV1Entry { - public UInt16 unk0; - public UInt16 lodCount; //maxLod = lodCount-1; - float unk2_f; - public byte[] particleBoneLod; //lod serves as indes into this array - public UInt32 unk4; + /// + /// unknown field + /// + public ushort Unk0; + + /// + /// the maximum lod count + /// + public ushort LodCount; + + /// + /// unknown field + /// + public float Unk1; + /// + /// lod serves as indes into this array + /// + public byte[] ParticleBoneLod; + + /// + /// unknown field + /// + public uint Unk2; /// /// Initializes a new instance of the class. @@ -28,11 +45,11 @@ public LDV1Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - unk0 = br.ReadUInt16(); - lodCount = br.ReadUInt16(); - unk2_f = br.ReadSingle(); - particleBoneLod = br.ReadBytes(4); - unk4 = br.ReadUInt32(); + Unk0 = br.ReadUInt16(); + LodCount = br.ReadUInt16(); + Unk1 = br.ReadSingle(); + ParticleBoneLod = br.ReadBytes(4); + Unk2 = br.ReadUInt32(); } } @@ -49,18 +66,15 @@ public static int GetSize() public byte[] Serialize(long offset = 0) { using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) { - using (var bw = new BinaryWriter(ms)) - { - bw.Write(unk0); - bw.Write(lodCount); - bw.Write(unk2_f); - bw.Write(particleBoneLod); - bw.Write(unk4); - } - + bw.Write(Unk0); + bw.Write(LodCount); + bw.Write(Unk1); + bw.Write(ParticleBoneLod); + bw.Write(Unk2); return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs b/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs index f8eb38a..12d0463 100644 --- a/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs +++ b/Warcraft.NET/Files/M2/Entries/WFV3Entry.cs @@ -1,32 +1,115 @@ -using System; -using System.IO; +using System.IO; +using Warcraft.NET.Extensions; 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; + /// + /// BumpScale -> Passed to vertex shader + /// + public float BumpScale; + + /// + /// value 0 x + /// + public float Value0X; + + /// + /// value 0 y + /// + public float Value0Y; + + /// + /// value 0 z + /// + public float Value0Z; + + /// + /// value 1 W + /// + public float Value1W; + + /// + /// value 0 W + /// + public float Value0W; + + /// + /// value 1 x + /// + public float Value1X; + + /// + /// value 1 y + /// + public float Value1Y; + + /// + /// value 2 w + /// + public float Value2W; + + /// + /// value 3 y + /// + public float Value3Y; + + /// + /// value 3 x + /// + public float Value3X; + + /// + /// BaseColor in rgba (not bgra) + /// + public RGBA BaseColor; + + /// + /// unknown Flags + /// + public ushort Flags; + + /// + /// unknown field + /// + public ushort Unk0; + + /// + /// value 3 W + /// + public float Value3W; + + /// + /// value 3 Z + /// + public float Value3Z; + + /// + /// value 4 y + /// + public float Value4Y; + + /// + /// unknown field + /// + public float Unk1; + + /// + /// unknown field + /// + public float Unk2; + + /// + /// unknown field + /// + public float Unk3; + + /// + /// unknown field + /// + public float Unk4; /// /// Initializes a new instance of the class. @@ -44,34 +127,27 @@ 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(); + BumpScale = br.ReadSingle(); + Value0X = br.ReadSingle(); + Value0Y = br.ReadSingle(); + Value0Z = br.ReadSingle(); + Value1W = br.ReadSingle(); + Value0W = br.ReadSingle(); + Value1X = br.ReadSingle(); + Value1Y = br.ReadSingle(); + Value2W = br.ReadSingle(); + Value3Y = br.ReadSingle(); + Value3X = br.ReadSingle(); + BaseColor = br.ReadRGBA(); + Flags = br.ReadUInt16(); + Unk0 = br.ReadUInt16(); + Value3W = br.ReadSingle(); + Value3Z = br.ReadSingle(); + Value4Y = br.ReadSingle(); + Unk1 = br.ReadSingle(); + Unk2 = br.ReadSingle(); + Unk3 = br.ReadSingle(); + Unk4 = br.ReadSingle(); } } @@ -90,39 +166,31 @@ 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); - } - + { + bw.Write(BumpScale); + bw.Write(Value0X); + bw.Write(Value0Y); + bw.Write(Value0Z); + bw.Write(Value1W); + bw.Write(Value0W); + bw.Write(Value1X); + bw.Write(Value1Y); + bw.Write(Value2W); + bw.Write(Value3Y); + bw.Write(Value3X); + bw.WriteRGBA(BaseColor); + bw.Write(Flags); + bw.Write(Unk0); + bw.Write(Value3W); + bw.Write(Value3Z); + bw.Write(Value4Y); + bw.Write(Unk1); + bw.Write(Unk2); + bw.Write(Unk3); + bw.Write(Unk4); + } return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/M2/Model.cs b/Warcraft.NET/Files/M2/Model.cs index fb75684..e92e642 100644 --- a/Warcraft.NET/Files/M2/Model.cs +++ b/Warcraft.NET/Files/M2/Model.cs @@ -10,7 +10,6 @@ namespace Warcraft.NET.Files.M2 [AutoDocFile("m2")] public class Model : ChunkedFile { - /// /// Gets or sets the model information /// @@ -18,127 +17,166 @@ public class Model : ChunkedFile public MD21 ModelInformation { get; set; } /// - /// Gets or sets the model phys file ids + /// Gets or sets the CParticleEmitter2 data /// - [ChunkOptional] - public PFID PhysFileIds { get; set; } + [ChunkOrder(2),ChunkOptional] + public TXAC CParticleEmitter2 { get; set; } /// - /// Gets or sets the model skin file ids + /// Gets or sets the ParentEventData /// - [ChunkOptional] - public SFID SkinFileIds { get; set; } + [ChunkOrder(3),ChunkOptional] + public PEDC M2InitParentEventData { get; set; } + + /// + /// Gets or sets the ExtendedParticle + /// + [ChunkOrder(4), ChunkOptional] + public EXPT ExtendedParticle { get; set; } + + /// + /// Gets or sets the ExtendedParticle2 + /// + [ChunkOrder(5),ChunkOptional] + public EXP2 ExtendedParticle2 { get; set; } + + /// + /// Gets or sets the ParticleGeosetData + /// + [ChunkOrder(6),ChunkOptional] + public PGD1 ParticleGeosetData { get; set; } /// /// Gets or sets the model anim file ids /// - [ChunkOptional] + [ChunkOrder(7), ChunkOptional] public AFID AnimFileIds { get; set; } /// /// Gets or sets the model bone file ids /// - [ChunkOptional] + [ChunkOrder(8), ChunkOptional] public BFID BoneFileIds { get; set; } - [ChunkOptional] - public TXAC CParticleEmitter2 { get; set; } - - [ChunkOptional] - public EXPT ExtendedParticle { get; set; } - - //[ChunkOptional] - //public EXP2 ExtendedParticle2 { get; set; } - - [ChunkOptional] - 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 + /// Gets or sets the BlacklistAnimData /// - [ChunkOptional] - public SKID SkeletonFileIds { get; set; } + [ChunkOrder(9), ChunkOptional] + public PABC M2InitBlacklistAnimData { get; set; } /// - /// Gets or sets the texture file ids + /// Gets or sets the LodDataVersion1 /// - [ChunkOptional] - public TXID TextureFileIds { get; set; } - - [ChunkOptional] + [ChunkOrder(10), ChunkOptional] public LDV1 LodDataVersion1 { get; set; } /// - /// Gets or sets the model recursive particle file ids + /// Gets or sets the EdgeFade /// - [ChunkOptional] - public RPID RecursiveParticleFileIds { get; set; } + [ChunkOrder(11), ChunkOptional] + public EDGF EdgeFade { get; set; } /// - /// Gets or sets the model geometry particle file ids + /// Gets or sets the Physics of the M2 /// - [ChunkOptional] - public GPID GeometryParticleFileIds { get; set; } + [ChunkOrder(12),ChunkOptional] + public PFDC ModelPhysics { get; set; } - [ChunkOptional] + /// + /// Gets or sets the model skeleton file ids + /// + [ChunkOrder(13), ChunkOptional] + public SKID SkeletonFileIds { get; set; } + + /// + /// Gets or sets the WaterFallVersion1 + /// + [ChunkOrder(14),ChunkOptional] public WFV1 WaterFallVersion1 { get; set; } - [ChunkOptional] + /// + /// Gets or sets the WaterFallVersion2 + /// + [ChunkOrder(15),ChunkOptional] public WFV2 WaterFallVersion2 { get; set; } - [ChunkOptional] - public PGD1 ParticleGeosetData { get; set; } - - [ChunkOptional] + /// + /// Gets or sets the WaterFallVersion3 + /// + [ChunkOrder(16),ChunkOptional] public WFV3 WaterFallVersion3 { get; set; } /// - /// Gets or sets the model physics + /// Gets or sets the DBOC /// - [ChunkOptional] - public PFDC ModelPhysics { get; set; } - - [ChunkOptional] - public EDGF EdgeFade { get; set; } - - [ChunkOptional] - public NERF NERF { get; set; } - - [ChunkOptional] - public DETL DETL { get; set; } - - [ChunkOptional] + [ChunkOrder(17), ChunkOptional] public DBOC DBOC { get; set; } - [ChunkOptional] - public AFRA AFRA { get; set; } - - - - - + /// + /// Gets or sets the model skin file ids + /// + [ChunkOrder(18), ChunkOptional] + public SFID SkinFileIds { get; set; } + /// + /// Gets or sets the model phys file ids + /// + [ChunkOrder(19), ChunkOptional] + public PFID PhysFileIds { get; set; } + /// + /// Gets or sets the model texture file ids + /// + [ChunkOrder(20), ChunkOptional] + public TXID TextureFileIds { get; set; } + /// + /// Gets or sets the ParentSequenceBoundsData + /// + [ChunkOrder(21),ChunkOptional] + public PSBC M2InitParentSequenceBoundsData { get; set; } + /// + /// Gets or sets the model recursive particle file ids + /// + [ChunkOrder(22), ChunkOptional] + public RPID RecursiveParticleFileIds { get; set; } + /// + /// Gets or sets the model geometry particle file ids + /// + [ChunkOrder(23), ChunkOptional] + public GPID GeometryParticleFileIds { get; set; } + /// + /// Gets or sets the ParentAnimData + /// + [ChunkOrder(24),ChunkOptional] + public PADC M2InitParentAnimData { get; set; } + /// + /// Gets or sets the NERF + /// + [ChunkOrder(25),ChunkOptional] + public NERF NERF { get; set; } + /// + /// Gets or sets the DETL (light related) + /// + [ChunkOrder(26),ChunkOptional] + public DETL DETL { get; set; } + /// + /// Gets or sets the AFRA + /// + [ChunkOrder(27),ChunkOptional] + public AFRA AFRA { get; set; } /// /// Initializes a new instance of the class. /// public Model() { - } /// @@ -147,7 +185,6 @@ public Model() /// The binary data. public Model(byte[] inData) : base(inData) { - } public override bool IsReverseSignature() diff --git a/Warcraft.NET/Files/SKIN/Skin.cs b/Warcraft.NET/Files/SKIN/Skin.cs index 5220d18..58d2c95 100644 --- a/Warcraft.NET/Files/SKIN/Skin.cs +++ b/Warcraft.NET/Files/SKIN/Skin.cs @@ -1,33 +1,60 @@ -using System; -using System.Collections.Generic; +using System.Collections.Generic; using System.IO; -using System.Linq; using Warcraft.NET.Attribute; using Warcraft.NET.Extensions; -using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Chunks; using Warcraft.NET.Files.Structures; -namespace Warcraft.NET.Files.SKIN +namespace Warcraft.NET.Files.Skin { [AutoDocFile("skin")] public class Skin { - public List Vertices{ get; set; } //index into M2s vertex list with offset - public List Triangles { get; set; } //3 indices per entry into vertices - public List BoneIndices { get; set; } + /// + /// The list of Vertices used for this skin + /// indexed into M2s vertex list with offset 'GlobalVertexOffset' + /// + public List Vertices { get; set; } + + /// + /// the triangles used for this skin (Right Handed) + /// indexed into the local list of vertices + /// + public List Triangles { get; set; } + + /// + /// the bones used for this skin. + /// indexed into the bone lookup table of the m2 + /// + public List BoneIndices { get; set; } + + /// + /// the submeshes used for this skin + /// public List Submeshes { get; set; } + + /// + /// the texture units used for this skin. + /// public List TextureUnits { get; set; } - public UInt32 globalVertexOffset; //start offset into M2.Vertices -> something else in wotlk + /// + /// start offset into M2.Vertices -> something else in wotlk + /// + public uint GlobalVertexOffset; + /// + /// the shadowbatches used in this skin + /// public List ShadowBatches; - - public byte[] unk0; //Padding? - public bool wotlk = false; + /// + /// unknown field. Maybe padding? + /// + public byte[] Unk0; + + public bool Wotlk = false; - public Skin(byte[] inData) + public Skin(byte[] inData) { using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) @@ -39,7 +66,7 @@ public Skin(byte[] inData) var ofsIndices = br.ReadUInt32(); if (ofsVertices == 48) { - wotlk = true; + Wotlk = true; } var nBones = br.ReadUInt32(); var ofsBones = br.ReadUInt32(); @@ -47,21 +74,20 @@ public Skin(byte[] inData) var ofsSubmeshes = br.ReadUInt32(); var nBatches = br.ReadUInt32(); var ofsBatches = br.ReadUInt32(); - globalVertexOffset = br.ReadUInt32(); + GlobalVertexOffset = br.ReadUInt32(); ShadowBatches = new List(); - unk0 = new byte[8]; - if (!wotlk) + Unk0 = new byte[8]; + if (!Wotlk) { var nShadow_batches = br.ReadUInt32(); var ofsShadow_batches = br.ReadUInt32(); - unk0 = br.ReadBytes(8); + Unk0 = br.ReadBytes(8); ShadowBatches = ReadStructList(nShadow_batches, ofsShadow_batches, br); } - Vertices = ReadStructList(nVertices, ofsVertices, br); - Triangles = ReadStructList(nIndices/3, ofsIndices, br); - BoneIndices = ReadStructList(nBones, ofsBones, br); + Triangles = ReadStructList(nIndices / 3, ofsIndices, br); + BoneIndices = ReadStructList(nBones, ofsBones, br); Submeshes = ReadStructList(nSubmeshes, ofsSubmeshes, br); TextureUnits = ReadStructList(nBatches, ofsBatches, br); @@ -83,54 +109,54 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - bw.Write(new byte[64]); //placeholder header + //Writing Empty Header -> Filling with data after writing the data + if (Wotlk) + { + bw.Write(new byte[48]); + } + else + { + bw.Write(new byte[64]); + } + foreach (ushort vertex in Vertices) { bw.Write(vertex); } - int _ofsTriangles = (int)bw.BaseStream.Position; foreach (M2Triangle triangle in Triangles) { bw.WriteStruct(triangle); } - int _ofsBones = (int)bw.BaseStream.Position; - foreach (BoneStruct bone in BoneIndices) + foreach (M2SkinBoneStruct bone in BoneIndices) { bw.WriteStruct(bone); - } - int _ofsSubmeshes = (int)bw.BaseStream.Position; foreach (M2SkinSection submesh in Submeshes) { bw.WriteStruct(submesh); } - int _ofsTexUnits = (int)bw.BaseStream.Position; foreach (M2Batch texUnit in TextureUnits) { bw.WriteStruct(texUnit); } - + int _ofsShadowBatches = (int)bw.BaseStream.Position; - if (!wotlk) { + if (!Wotlk) + { foreach (M2ShadowBatch shadowBatch in ShadowBatches) { bw.WriteStruct(shadowBatch); } } - - - - - - //Writing header + //Writing actual header data bw.BaseStream.Position = 0; bw.Write('S'); bw.Write('K'); @@ -139,32 +165,30 @@ public byte[] Serialize(long offset = 0) bw.Write(Vertices.Count); var _ofsVertices = 64; - if (wotlk) + if (Wotlk) _ofsVertices = 48; - bw.Write(_ofsVertices); - - bw.Write(Triangles.Count*3); + bw.Write(_ofsVertices); + + bw.Write(Triangles.Count * 3); bw.Write(_ofsTriangles); bw.Write(BoneIndices.Count); bw.Write(_ofsBones); bw.Write(Submeshes.Count); - bw.Write(_ofsSubmeshes); - + bw.Write(_ofsSubmeshes); + bw.Write(TextureUnits.Count); - bw.Write(_ofsTexUnits); - - bw.Write(globalVertexOffset); + bw.Write(_ofsTexUnits); + + bw.Write(GlobalVertexOffset); - if (!wotlk) - { + if (!Wotlk) + { bw.Write(ShadowBatches.Count); bw.Write(_ofsShadowBatches); - bw.Write(unk0); + bw.Write(Unk0); } - - return ms.ToArray(); } } @@ -174,21 +198,7 @@ public uint GetSize() { return (uint)Serialize().Length; } - - /* - public byte[] addPadding(byte[] bytes, int size) - { - // Calculate padding - int paddingSize = (4 - (size % 4)) % 4; - byte[] paddedBytes = new byte[size + paddingSize]; - Array.Copy(bytes, paddedBytes, size); - return paddedBytes; - } - */ - } - - } diff --git a/Warcraft.NET/Files/Structures/M2Batch.cs b/Warcraft.NET/Files/Structures/M2Batch.cs new file mode 100644 index 0000000..37040e8 --- /dev/null +++ b/Warcraft.NET/Files/Structures/M2Batch.cs @@ -0,0 +1,73 @@ +namespace Warcraft.NET.Files.Structures +{ + public struct M2Batch + { + /// + /// Texture Flags + /// Usually 16 for static textures, and 0 for animated textures. &0x1: materials invert something; &0x2: transform &0x4: projected texture; &0x10: something batch compatible; &0x20: projected texture?; &0x40: possibly don't multiply transparency by texture weight transparency to get final transparency value(?) + /// + public byte Flags; + + /// + /// Priority Plane + /// + public sbyte PriorityPlane; + + /// + /// ShaderID + /// negative = direct selection + /// positive = selection trough a function. See wiki for more information + /// + public ushort ShaderId; + + /// + /// A duplicate entry of a submesh from the list above. + /// + public ushort SkinSectionIndex; + + /// + /// New name: flags2. 0x2 - projected. 0x8 - EDGF chunk in m2 is mandatory and data from is applied to this mesh + /// + public ushort GeosetIndex; + + /// + /// A Color out of the Colors-Block or -1 if none. + /// + public ushort ColorIndex; + + /// + /// The renderflags used on this texture-unit. Index into M2 Materials + /// + public ushort MaterialIndex; + + /// + /// Capped at 7 (CM2Scene::BeginDraw) + /// + public ushort MaterialLayer; + + /// + /// 1 to 4. See below. Also seems to be the number of textures to load, starting at the texture lookup in the next field (0x10). + /// + public ushort TextureCount; + + /// + /// Index into Texture lookup table + /// + public ushort TextureComboIndex; + + /// + /// Index into the texture mapping lookup table. + /// + public ushort TextureCoordComboIndex; + + /// + /// Index into transparency lookup table. + /// + public ushort TextureWeightComboIndex; + + /// + /// Index into uvanimation lookup table. + /// + public ushort TextureTransformComboIndex; + } +} diff --git a/Warcraft.NET/Files/Structures/M2ShadowBatch.cs b/Warcraft.NET/Files/Structures/M2ShadowBatch.cs new file mode 100644 index 0000000..db25b23 --- /dev/null +++ b/Warcraft.NET/Files/Structures/M2ShadowBatch.cs @@ -0,0 +1,41 @@ +namespace Warcraft.NET.Files.Structures +{ + public struct M2ShadowBatch + { + /// + /// if auto-generated: M2Batch.Flags & 0xFF + /// + public byte Flags; + + /// + /// gets auto generated if certain flags in TextureUnit are set + /// See wiki for more information + /// + public byte Flags2; + + /// + /// unknown field + /// + public ushort Unk1; + + /// + /// same as TextureUnit + /// + public ushort SubmeshId; + + /// + /// same as TextureUnit + /// + public ushort TextureId; // already looked-up + + /// + /// same as TextureUnit + /// + public ushort ColorId; + + /// + /// same as TextureUnit + /// + public ushort TransparencyId; // already looked-up + } +} diff --git a/Warcraft.NET/Files/Structures/M2SkinBoneStruct.cs b/Warcraft.NET/Files/Structures/M2SkinBoneStruct.cs new file mode 100644 index 0000000..6f813ee --- /dev/null +++ b/Warcraft.NET/Files/Structures/M2SkinBoneStruct.cs @@ -0,0 +1,25 @@ +namespace Warcraft.NET.Files.Structures +{ + public struct M2SkinBoneStruct + { + /// + /// Bone 1 Index into BoneLookupTable from M2. see wiki for exact calculation + /// + public byte Bone1ID; + + /// + /// Bone 2 Index into BoneLookupTable from M2. see wiki for exact calculation + /// + public byte Bone2ID; + + /// + /// Bone 3 Index into BoneLookupTable from M2. see wiki for exact calculation + /// + public byte Bone3ID; + + /// + /// Bone 4 Index into BoneLookupTable from M2. see wiki for exact calculation + /// + public byte Bone4ID; + } +} diff --git a/Warcraft.NET/Files/Structures/M2SkinSection.cs b/Warcraft.NET/Files/Structures/M2SkinSection.cs new file mode 100644 index 0000000..cbd4b55 --- /dev/null +++ b/Warcraft.NET/Files/Structures/M2SkinSection.cs @@ -0,0 +1,79 @@ +using System; +using System.Collections.Generic; +using System.Numerics; +using System.Text; + +namespace Warcraft.NET.Files.Structures +{ + public struct M2SkinSection + { + /// + /// Mesh part ID, see wiki for exact calculation + /// + public ushort SkinSectionId; + + /// + /// (level << 16) is added (|ed) to startTriangle and alike to avoid having to increase those fields to uint32s. + /// + public ushort Level; + + /// + /// Starting Vertex. Index into local vertex list + /// + public ushort VertexStart; + + /// + /// Number of Vertices taken from local vertex list + /// + public ushort VertexCount; + + /// + /// Starting triangle index. + /// + public ushort IndexStart; + + /// + /// Number of triangle indices. + /// + public ushort IndexCount; + + /// + /// Number of elements in the bone lookup table. Max seems to be 256 in Wrath. Shall be ≠ 0. + /// + public ushort BoneCount; + + /// + /// Starting index in the bone lookup table. + /// + public ushort BoneComboIndex; + + /// + /// <= 4 + /// from <=BC documentation: Highest number of bones needed at one time in this Submesh --Tinyn (wowdev.org) + /// In 2.x this is the amount of of bones up the parent-chain affecting the submesh --NaK + /// Highest number of bones referenced by a vertex of this submesh. 3.3.5a and suspectedly all other client revisions. -- Skarn + /// + public ushort BoneInfluences; + + /// + /// Index of the center bone + /// + public ushort CenterBoneIndex; + + /// + /// Average position of all the vertices in the sub mesh. + /// + public Vector3 CenterPosition; + + //≥BC + /// + /// The center of the box when an axis aligned box is built around the vertices in the submesh. + /// + public Vector3 SortCenterPosition; + + /// + /// Distance of the vertex farthest from CenterBoundingBox. + /// + public float SortRadius; + } +} diff --git a/Warcraft.NET/Files/Structures/M2Triangle.cs b/Warcraft.NET/Files/Structures/M2Triangle.cs new file mode 100644 index 0000000..639055d --- /dev/null +++ b/Warcraft.NET/Files/Structures/M2Triangle.cs @@ -0,0 +1,25 @@ +namespace Warcraft.NET.Files.Structures +{ + /// + /// Triangle read from skin. + /// Default = Right Handed + /// To make it left handed, swap the second and third vertex + /// + public struct M2Triangle + { + /// + /// the first vertex of the Triangle + /// + public ushort Vertex1; + + /// + /// the second vertex of the Triangle + /// + public ushort Vertex2; + + /// + /// the third vertex of the Triangle + /// + public ushort Vertex3; + } +} diff --git a/Warcraft.NET/Files/Structures/Matrix3x4.cs b/Warcraft.NET/Files/Structures/Matrix3x4.cs new file mode 100644 index 0000000..7c6e0d6 --- /dev/null +++ b/Warcraft.NET/Files/Structures/Matrix3x4.cs @@ -0,0 +1,68 @@ +using System.Collections.Generic; +using Warcraft.NET.Files.Interfaces; +using System.Numerics; + +public class Matrix3x4 : IFlattenableData +{ + /// + /// The directional vector 'right' + /// + public Vector3 RotationX { get; set; } + + /// + /// The directional vector 'up' + /// + public Vector3 RotationY { get; set; } + + /// + /// The directional vector 'forward' + /// + public Vector3 RotationZ { get; set; } + + /// + /// The scale of the matrix + /// + public Vector3 Scale { get; set; } + + /// + /// The position of the matrix + /// + public Vector3 Position { get; set; } + + public Matrix3x4 (Vector3 column1, Vector3 column2, Vector3 column3, Vector3 column4) + { + float scaleX = column1.Length(); + float scaleY = column2.Length(); + float scaleZ = column3.Length(); + + RotationX = column1 / scaleX; + RotationY = column2 / scaleY; + RotationZ = column3 / scaleZ; + + Scale = new Vector3(scaleX, scaleY, scaleZ); + Position = column4; + } + + public Vector3 GetForward() + { + return Vector3.Normalize(RotationZ); + } + + public Vector3 GetUp() + { + return Vector3.Normalize(RotationY); + } + + public Vector3 GetRight() + { + return Vector3.Normalize(RotationX); + } + + public IReadOnlyCollection Flatten() + { + return new[] { + GetForward().X,GetForward().Y,GetForward().Z, + Scale.X, Scale.Y, Scale.Z, + Position.X, Position.Y, Position.Z }; + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Chunks/BDY4.cs b/Warcraft.NET/Files/phys/Chunks/BDY4.cs index ef7a3bd..7f90e83 100644 --- a/Warcraft.NET/Files/phys/Chunks/BDY4.cs +++ b/Warcraft.NET/Files/phys/Chunks/BDY4.cs @@ -2,9 +2,9 @@ using System.IO; using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class BDY4 : IIFFChunk, IBinarySerializable @@ -15,9 +15,9 @@ public class BDY4 : IIFFChunk, IBinarySerializable public const string Signature = "BDY4"; /// - /// Gets or Sets the version of the physics + /// Gets or Sets the used rigidbodies(V4) /// - public List bdy4Entries = new(); + public List BDY4Entries = new(); /// /// Initializes a new instance of @@ -46,7 +46,7 @@ public void LoadBinaryData(byte[] inData) for (var i = 0; i < bdy4count; ++i) { - bdy4Entries.Add(new BDY4Entry(br.ReadBytes(BDY4Entry.GetSize()))); + BDY4Entries.Add(new BDY4Entry(br.ReadBytes(BDY4Entry.GetSize()))); } } } @@ -57,13 +57,12 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - foreach (BDY4Entry obj in bdy4Entries) + foreach (BDY4Entry obj in BDY4Entries) { bw.Write(obj.Serialize()); } return ms.ToArray(); } } - } } diff --git a/Warcraft.NET/Files/phys/Chunks/BOXS.cs b/Warcraft.NET/Files/phys/Chunks/BOXS.cs index b4e2c87..98128a9 100644 --- a/Warcraft.NET/Files/phys/Chunks/BOXS.cs +++ b/Warcraft.NET/Files/phys/Chunks/BOXS.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class BOXS : IIFFChunk, IBinarySerializable @@ -16,9 +14,11 @@ public class BOXS : IIFFChunk, IBinarySerializable /// public const string Signature = "BOXS"; + /// + /// sets or gets the box shapes + /// public List BOXSEntries = new(); - /// /// Initializes a new instance of /// @@ -62,7 +62,6 @@ public byte[] Serialize(long offset = 0) bw.Write(obj.Serialize()); } return ms.ToArray(); - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/CAPS.cs b/Warcraft.NET/Files/phys/Chunks/CAPS.cs index d7286e4..26fab82 100644 --- a/Warcraft.NET/Files/phys/Chunks/CAPS.cs +++ b/Warcraft.NET/Files/phys/Chunks/CAPS.cs @@ -1,12 +1,10 @@ using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.Structures; using System.Collections.Generic; -using Warcraft.NET.Files.phys.Entries; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class CAPS : IIFFChunk, IBinarySerializable @@ -16,9 +14,11 @@ public class CAPS : IIFFChunk, IBinarySerializable /// public const string Signature = "CAPS"; + /// + /// sets or gets the capsule shapes + /// public List CAPSEntries = new(); - /// /// Initializes a new instance of /// @@ -63,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/DSTJ.cs b/Warcraft.NET/Files/phys/Chunks/DSTJ.cs index 63731a9..32db762 100644 --- a/Warcraft.NET/Files/phys/Chunks/DSTJ.cs +++ b/Warcraft.NET/Files/phys/Chunks/DSTJ.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class DSTJ : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class DSTJ : IIFFChunk, IBinarySerializable /// public const string Signature = "DSTJ"; + /// + /// sets or gets the distance joints + /// public List DSTJEntries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/JOIN.cs b/Warcraft.NET/Files/phys/Chunks/JOIN.cs index 94330a0..d378ac3 100644 --- a/Warcraft.NET/Files/phys/Chunks/JOIN.cs +++ b/Warcraft.NET/Files/phys/Chunks/JOIN.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class JOIN : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class JOIN : IIFFChunk, IBinarySerializable /// public const string Signature = "JOIN"; + /// + /// sets or gets the joints + /// public List JOINEntries = new(); /// @@ -42,7 +43,6 @@ public void LoadBinaryData(byte[] inData) using (var br = new BinaryReader(ms)) { var JOINcount = br.BaseStream.Length / JOINEntry.GetSize(); - for (var i = 0; i < JOINcount; ++i) { JOINEntries.Add(new JOINEntry(br.ReadBytes(JOINEntry.GetSize()))); @@ -62,8 +62,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/PHYS.cs b/Warcraft.NET/Files/phys/Chunks/PHYS.cs index 4f98688..7226e29 100644 --- a/Warcraft.NET/Files/phys/Chunks/PHYS.cs +++ b/Warcraft.NET/Files/phys/Chunks/PHYS.cs @@ -2,7 +2,7 @@ using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class PHYS : IIFFChunk, IBinarySerializable @@ -15,7 +15,7 @@ public class PHYS : IIFFChunk, IBinarySerializable /// /// Gets or Sets the version of the physics /// - public ushort version; + public ushort Version; /// /// Initializes a new instance of @@ -40,7 +40,7 @@ public void LoadBinaryData(byte[] inData) using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { - version = br.ReadUInt16(); + Version = br.ReadUInt16(); } } @@ -50,7 +50,7 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - bw.Write(version); + bw.Write(Version); return ms.ToArray(); } } diff --git a/Warcraft.NET/Files/phys/Chunks/PHYT.cs b/Warcraft.NET/Files/phys/Chunks/PHYT.cs index 9d0e48e..7e2d5c7 100644 --- a/Warcraft.NET/Files/phys/Chunks/PHYT.cs +++ b/Warcraft.NET/Files/phys/Chunks/PHYT.cs @@ -2,7 +2,7 @@ using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class PHYT : IIFFChunk, IBinarySerializable @@ -13,9 +13,9 @@ public class PHYT : IIFFChunk, IBinarySerializable public const string Signature = "PHYT"; /// - /// Gets or Sets the version of the physics + /// Gets or Sets PHYT (unknown) /// - public uint phyt; + public uint Phyt = 0; /// /// Initializes a new instance of @@ -40,7 +40,7 @@ public void LoadBinaryData(byte[] inData) using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { - phyt = br.ReadUInt32(); + Phyt = br.ReadUInt32(); } } @@ -50,7 +50,7 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - bw.Write(phyt); + bw.Write(Phyt); return ms.ToArray(); } } diff --git a/Warcraft.NET/Files/phys/Chunks/PHYV.cs b/Warcraft.NET/Files/phys/Chunks/PHYV.cs index 5d22e0b..690428a 100644 --- a/Warcraft.NET/Files/phys/Chunks/PHYV.cs +++ b/Warcraft.NET/Files/phys/Chunks/PHYV.cs @@ -1,10 +1,8 @@ -using System.Collections.Generic; -using System.IO; +using System.IO; using Warcraft.NET.Attribute; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class PHYV : IIFFChunk, IBinarySerializable @@ -15,9 +13,9 @@ public class PHYV : IIFFChunk, IBinarySerializable public const string Signature = "PHYV"; /// - /// Gets or Sets the version of the physics + /// Gets or Sets the PHYV (unknown) /// - public float[] values; + public float[] Values; /// /// Initializes a new instance of @@ -43,15 +41,15 @@ public void LoadBinaryData(byte[] inData) using (var br = new BinaryReader(ms)) { var PHYVcount = br.BaseStream.Length / 24; - values = new float[PHYVcount * 6]; + Values = new float[PHYVcount * 6]; for (var i = 0; i < PHYVcount; ++i) { - values[i] = br.ReadSingle(); - values[i+1] = br.ReadSingle(); - values[i+2] = br.ReadSingle(); - values[i+3] = br.ReadSingle(); - values[i+4] = br.ReadSingle(); - values[i+5] = br.ReadSingle(); + Values[i] = br.ReadSingle(); + Values[i+1] = br.ReadSingle(); + Values[i+2] = br.ReadSingle(); + Values[i+3] = br.ReadSingle(); + Values[i+4] = br.ReadSingle(); + Values[i+5] = br.ReadSingle(); } } } @@ -62,13 +60,12 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - foreach (float f in values) + foreach (float f in Values) { bw.Write(f); } return ms.ToArray(); } } - } } diff --git a/Warcraft.NET/Files/phys/Chunks/PLYT.cs b/Warcraft.NET/Files/phys/Chunks/PLYT.cs index d3d9418..12fd612 100644 --- a/Warcraft.NET/Files/phys/Chunks/PLYT.cs +++ b/Warcraft.NET/Files/phys/Chunks/PLYT.cs @@ -2,12 +2,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class PLYT : IIFFChunk, IBinarySerializable @@ -17,6 +15,9 @@ public class PLYT : IIFFChunk, IBinarySerializable /// public const string Signature = "PLYT"; + /// + /// sets or gets the polytope shapes + /// public List PLYTEntries = new(); /// @@ -42,55 +43,16 @@ public void LoadBinaryData(byte[] inData) using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { - - var PLYTcount = br.ReadUInt32(); - - for (var i = 0; i < PLYTcount; ++i) + var plyt_count = br.ReadUInt32(); + for (var i = 0; i < plyt_count; i++) { - PLYTEntry plyt_entry = new PLYTEntry - { - header = new PLYTEntry.PLYT_HEADER - { - vertexCount = br.ReadUInt32(), - unk_04 = br.ReadBytes(4), - RUNTIME_08_ptr_data_0 = br.ReadUInt64(), - count_10 = br.ReadUInt32(), - unk_14 = br.ReadBytes(4), - RUNTIME_18_ptr_data_1 = br.ReadUInt64(), - RUNTIME_20_ptr_data_2 = br.ReadUInt64(), - nodeCount = br.ReadUInt32(), - unk_2C = br.ReadBytes(4), - RUNTIME_30_ptr_data_3 = br.ReadUInt64(), - unk_38 = new float[6] { br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle() } - } - }; - + PLYTEntry plyt_entry = new PLYTEntry(br.ReadBytes(80)); PLYTEntries.Add(plyt_entry); } - for (var j = 0; j < PLYTcount; j++) + for (var j = 0; j < plyt_count; j++) { - PLYTEntry entry = PLYTEntries[j]; - uint vcount = entry.header.vertexCount; - uint count_10 = entry.header.count_10; - uint nodeCount = entry.header.nodeCount; - - entry.data.vertices = new C3Vector[vcount]; - for (int v = 0; v < vcount; v++) - { - entry.data.vertices[v] = new C3Vector(br.ReadBytes(12)); - } - entry.data.unk1 = br.ReadBytes((int)count_10 * 16); - entry.data.unk2 = br.ReadBytes((int)count_10); - entry.data.nodes = new PLYTEntry.NODE[nodeCount]; - for (int n = 0; n < nodeCount; n++) - { - PLYTEntry.NODE node = new PLYTEntry.NODE(); - node.unk = br.ReadByte(); - node.vertexIndex = br.ReadByte(); - node.unkIndex0 = br.ReadByte(); - node.unkIndex1 = br.ReadByte(); - entry.data.nodes[n] = node; - } + PLYTEntry plyt_entry = PLYTEntries[j]; + plyt_entry.DeserializeData(br.ReadBytes(plyt_entry.DataSize)); } } } @@ -101,10 +63,10 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - bw.Write((UInt32)PLYTEntries.Count); + bw.Write((uint)PLYTEntries.Count); foreach (PLYTEntry obj in PLYTEntries) { - Console.WriteLine("Writing Plyt Header Length: "+ obj.SerializeHeader().Length); + Console.WriteLine("Writing Plyt Header Length: " + obj.SerializeHeader().Length); bw.Write(obj.SerializeHeader()); } foreach (PLYTEntry obj in PLYTEntries) @@ -114,8 +76,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/PRS2.cs b/Warcraft.NET/Files/phys/Chunks/PRS2.cs index 1c4feb3..7d1e742 100644 --- a/Warcraft.NET/Files/phys/Chunks/PRS2.cs +++ b/Warcraft.NET/Files/phys/Chunks/PRS2.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class PRS2 : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class PRS2 : IIFFChunk, IBinarySerializable /// public const string Signature = "PRS2"; + /// + /// sets or gets the prismatic(V2) joints + /// public List PRS2Entries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/REV2.cs b/Warcraft.NET/Files/phys/Chunks/REV2.cs index 2024f40..297898a 100644 --- a/Warcraft.NET/Files/phys/Chunks/REV2.cs +++ b/Warcraft.NET/Files/phys/Chunks/REV2.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class REV2 : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class REV2 : IIFFChunk, IBinarySerializable /// public const string Signature = "REV2"; + /// + /// sets or gets the revolute(V2) joints + /// public List REV2Entries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/SHJ2.cs b/Warcraft.NET/Files/phys/Chunks/SHJ2.cs index 757a5ad..c8ae2e2 100644 --- a/Warcraft.NET/Files/phys/Chunks/SHJ2.cs +++ b/Warcraft.NET/Files/phys/Chunks/SHJ2.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class SHJ2 : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class SHJ2 : IIFFChunk, IBinarySerializable /// public const string Signature = "SHJ2"; + /// + /// sets or gets the shoulder(V2) joints + /// public List SHJ2Entries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/SHOJ.cs b/Warcraft.NET/Files/phys/Chunks/SHOJ.cs index 4adde28..b1149ac 100644 --- a/Warcraft.NET/Files/phys/Chunks/SHOJ.cs +++ b/Warcraft.NET/Files/phys/Chunks/SHOJ.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class SHOJ : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class SHOJ : IIFFChunk, IBinarySerializable /// public const string Signature = "SHOJ"; + /// + /// sets or gets the shoulder joints + /// public List SHOJEntries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/SHP2.cs b/Warcraft.NET/Files/phys/Chunks/SHP2.cs index 948105c..21f1265 100644 --- a/Warcraft.NET/Files/phys/Chunks/SHP2.cs +++ b/Warcraft.NET/Files/phys/Chunks/SHP2.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class SHP2 : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class SHP2 : IIFFChunk, IBinarySerializable /// public const string Signature = "SHP2"; + /// + /// sets or gets the shapes(V2) + /// public List SHP2Entries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/SPHJ.cs b/Warcraft.NET/Files/phys/Chunks/SPHJ.cs index 2f8fa97..4ec195f 100644 --- a/Warcraft.NET/Files/phys/Chunks/SPHJ.cs +++ b/Warcraft.NET/Files/phys/Chunks/SPHJ.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class SPHJ : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class SPHJ : IIFFChunk, IBinarySerializable /// public const string Signature = "SPHJ"; + /// + /// sets or gets the spherical joints + /// public List SPHJEntries = new(); /// @@ -42,7 +43,6 @@ public void LoadBinaryData(byte[] inData) using (var br = new BinaryReader(ms)) { var SPHJcount = br.BaseStream.Length / SPHJEntry.GetSize(); - for (var i = 0; i < SPHJcount; ++i) { SPHJEntries.Add(new SPHJEntry(br.ReadBytes(SPHJEntry.GetSize()))); @@ -62,8 +62,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Chunks/SPHS.cs b/Warcraft.NET/Files/phys/Chunks/SPHS.cs index 4798579..5b55a64 100644 --- a/Warcraft.NET/Files/phys/Chunks/SPHS.cs +++ b/Warcraft.NET/Files/phys/Chunks/SPHS.cs @@ -1,10 +1,10 @@ +using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class SPHS : IIFFChunk, IBinarySerializable @@ -15,14 +15,9 @@ public class SPHS : IIFFChunk, IBinarySerializable public const string Signature = "SPHS"; /// - /// Gets or Sets the local position of the Sphere shape + /// sets or gets a list of sphere shapes /// - public C3Vector localPosition; - - /// - /// Gets or Sets the radius of the Sphere shape - /// - public float radius; + public List Spheres = new(); /// /// Initializes a new instance of @@ -47,8 +42,12 @@ public void LoadBinaryData(byte[] inData) using (var ms = new MemoryStream(inData)) using (var br = new BinaryReader(ms)) { - localPosition = new C3Vector(br.ReadBytes(12)); - radius = br.ReadSingle(); + var SHP2count = br.BaseStream.Length / SHP2Entry.GetSize(); + + for (var i = 0; i < SHP2count; ++i) + { + Spheres.Add(new SPHSEntry(br.ReadBytes(SPHSEntry.GetSize()))); + } } } @@ -57,9 +56,11 @@ public byte[] Serialize(long offset = 0) { using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) - { - bw.Write(localPosition.asBytes()); - bw.Write(radius); + { + foreach (SPHSEntry obj in Spheres) + { + bw.Write(obj.Serialize()); + } return ms.ToArray(); } } diff --git a/Warcraft.NET/Files/phys/Chunks/WLJ3.cs b/Warcraft.NET/Files/phys/Chunks/WLJ3.cs index 086d177..b71e7a7 100644 --- a/Warcraft.NET/Files/phys/Chunks/WLJ3.cs +++ b/Warcraft.NET/Files/phys/Chunks/WLJ3.cs @@ -1,12 +1,10 @@ using System.Collections.Generic; using System.IO; using Warcraft.NET.Attribute; -using Warcraft.NET.Extensions; using Warcraft.NET.Files.Interfaces; -using Warcraft.NET.Files.phys.Entries; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Entries; -namespace Warcraft.NET.Files.phys.Chunks +namespace Warcraft.NET.Files.Phys.Chunks { [AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterBfA, AutoDocChunkVersionHelper.VersionBeforeSL)] public class WLJ3 : IIFFChunk, IBinarySerializable @@ -16,6 +14,9 @@ public class WLJ3 : IIFFChunk, IBinarySerializable /// public const string Signature = "WLJ3"; + /// + /// sets or gets a list of Weld(V3) Joints + /// public List WLJ3Entries = new(); /// @@ -62,8 +63,6 @@ public byte[] Serialize(long offset = 0) } return ms.ToArray(); } - - } } } diff --git a/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs b/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs index 6e9bab5..8fc497e 100644 --- a/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/BDY4Entry.cs @@ -1,40 +1,81 @@ using System.IO; +using System.Numerics; +using Warcraft.NET.Extensions; +using Warcraft.NET.Files.Phys.Enums; using Warcraft.NET.Files.Structures; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class BDY4Entry { + /// + /// Sets or gets the BodyType of the rigidbody + /// 0=static + /// 1=dynamic + /// 2=unknown + /// + public BodyType BodyType { get; set; } // maps to dmBodyDef BodyType enum. 0 -> 1, 1 -> 0 = dm_dynamicBody, * -> 2. Only one should be of BodyType 0 (root). possibly only 0 and 1. - public enum Body_Type : ushort - { - root = 0, - dynamic = 1, - unk = 2, - } + /// + /// Sets or gets the index of the bone, which is connected to this rigidbody + /// + public ushort BoneIndex { get; set; } + + /// + /// sets or gets the default Position of the rigidbody + /// + public Vector3 Position { get; set; } = new Vector3(0, 0, 0); + + /// + /// sets or gets the index of the shape, which is connected to this rigidbody + /// + public ushort ShapesIndex { get; set; } + + /// + /// sets or gets a currently unknown field. Possibly 'Padding' + /// + public byte[] Unk0 { get; set; } = { 0, 0 }; + + /// + /// sets or gets the amount of shapes this rigidbody has + /// + public int ShapesCount { get; set; } // shapes_count shapes are in this body. + + /// + /// sets or gets a currently unknown field. Possibly 'UpliftFactor' + /// + public float Unk1 { get; set; } = 0f; - 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; } - public byte[] PADDING { get; set; } - public int shapesCount { get; set; } // shapes_count shapes are in this body. - public float unk0 { get; set; } //#if version >= 3 // BDY3 - public float _x1c { get; set; } // default 1.0 - public float drag { get; set; } // default 0, maybe incorrect - public float unk1; // default 0, seems to be some sort of weight. - // If version >= 3 and unk1 == 0 the body will be non kinematic even if the flag is set, it needs to get its transform from the parent bone. - // See offhand_1h_artifactskulloferedar_d_06 where all the bodies have the kinematic flag - public float _x28 { get; set; } // default 0.89999998 + /// + /// sets or gets a currently unknown field. Possibly 'GravityScale' + /// + public float Unk2 { get; set; } = 1.0f; - public byte[] x2c { get; set; }// default 0x00000000 + /// + /// sets or gets the Drag value of the rigidbody. + /// + public float Drag { get; set; } = 0f; + /// + /// sets or gets a currently unknown field. Possibly 'Mass/Weight' + /// + public float Unk3 = 0f; + + /// + /// sets or gets a currently unknown field. + /// + public float Unk4 { get; set; } = 0.89999998f; + + /// + /// sets or gets a currently unknown field. + /// + public byte[] Unk5 { get; set; } = { 0, 0, 0, 0 }; /// /// Initializes a new instance of the class. /// - public BDY4Entry(){} + public BDY4Entry() { } /// /// Initializes a new instance of the class. @@ -45,18 +86,18 @@ public BDY4Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - type = (Body_Type)br.ReadUInt16(); - boneIndex = br.ReadUInt16(); - position = new C3Vector(br.ReadSingle(), br.ReadSingle(), br.ReadSingle()); - shapeIndex = br.ReadUInt16(); - PADDING = br.ReadBytes(2); - shapesCount = br.ReadInt32(); - unk0 = br.ReadSingle(); - _x1c = br.ReadSingle(); - drag = br.ReadSingle(); - unk1 = br.ReadSingle(); - _x28 = br.ReadSingle(); - x2c = br.ReadBytes(4); + BodyType = (BodyType)br.ReadUInt16(); + BoneIndex = br.ReadUInt16(); + Position = br.ReadVector3(AxisConfiguration.ZUp); + ShapesIndex = br.ReadUInt16(); + Unk0 = br.ReadBytes(2); + ShapesCount = br.ReadInt32(); + Unk1 = br.ReadSingle(); + Unk2 = br.ReadSingle(); + Drag = br.ReadSingle(); + Unk3 = br.ReadSingle(); + Unk4 = br.ReadSingle(); + Unk5 = br.ReadBytes(4); } } @@ -76,24 +117,23 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write((ushort)type); - bw.Write(boneIndex); - bw.Write(position.X); - bw.Write(position.Y); - bw.Write(position.Z); - bw.Write(shapeIndex); - bw.Write(PADDING); - bw.Write(shapesCount); - bw.Write(unk0); - bw.Write(_x1c); - bw.Write(drag); - bw.Write(unk1); - bw.Write(_x28); - bw.Write(x2c); + bw.Write((ushort)BodyType); + bw.Write(BoneIndex); + bw.Write(Position.X); + bw.Write(Position.Y); + bw.Write(Position.Z); + bw.Write(ShapesIndex); + bw.Write(Unk0); + bw.Write(ShapesCount); + bw.Write(Unk1); + bw.Write(Unk2); + bw.Write(Drag); + bw.Write(Unk3); + bw.Write(Unk4); + bw.Write(Unk5); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/BOXSEntry.cs b/Warcraft.NET/Files/phys/Entries/BOXSEntry.cs index cc0b3fc..8fffebd 100644 --- a/Warcraft.NET/Files/phys/Entries/BOXSEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/BOXSEntry.cs @@ -1,30 +1,31 @@ using System.IO; -using Warcraft.NET.Files.phys.Chunks; -using Warcraft.NET.Files.Structures; +using System.Numerics; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class BOXSEntry { /// - /// Gets or Sets the matrix of the box shape + /// Gets or Sets the transformation matrix of the box shape /// - public Mat3x4 a; + public Matrix3x4 Dimensions; /// /// Gets or Sets the local position of the box shape /// - public C3Vector c; + public Vector3 Position; public BOXSEntry(byte[] data) { using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - a = new Mat3x4(br.ReadBytes(48)); - c = new C3Vector(br.ReadBytes(12)); + Dimensions = br.ReadMatrix3x4(); + Position = br.ReadVector3(); } } + /// /// Gets the size of a box entry. /// @@ -41,13 +42,11 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(a.asBytes()); - bw.Write(c.asBytes()); + bw.WriteMatrix3x4(Dimensions); + bw.WriteVector3(Position); } - return ms.ToArray(); } } - } } \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/CAPSEntry.cs b/Warcraft.NET/Files/phys/Entries/CAPSEntry.cs index 05e86db..dcfde2d 100644 --- a/Warcraft.NET/Files/phys/Entries/CAPSEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/CAPSEntry.cs @@ -1,35 +1,35 @@ using System.IO; -using Warcraft.NET.Files.phys.Chunks; +using System.Numerics; +using Warcraft.NET.Extensions; using Warcraft.NET.Files.Structures; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class CAPSEntry { - /// - /// Gets or Sets the local start position of the capsule shape + /// Gets or Sets the local start position of this capsule shape /// - public C3Vector localPosition1; + public Vector3 LocalPosition1; /// - /// Gets or Sets the local end position of the capsule shape + /// Gets or Sets the local end position of this capsule shape /// - public C3Vector localPosition2; + public Vector3 LocalPosition2; /// - /// Gets or Sets the radius of the capsule shape + /// Gets or Sets the Radius of this capsule shape /// - public float radius; + public float Radius; public CAPSEntry(byte[] data) { using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - localPosition1 = new C3Vector(br.ReadBytes(12)); - localPosition2 = new C3Vector(br.ReadBytes(12)); - radius = br.ReadSingle(); + LocalPosition1 = br.ReadVector3(AxisConfiguration.ZUp); + LocalPosition2 = br.ReadVector3(AxisConfiguration.ZUp); + Radius = br.ReadSingle(); } } /// @@ -47,9 +47,9 @@ public byte[] Serialize(long offset = 0) using (var ms = new MemoryStream()) using (var bw = new BinaryWriter(ms)) { - bw.Write(localPosition1.asBytes()); - bw.Write(localPosition2.asBytes()); - bw.Write(radius); + bw.WriteVector3(LocalPosition1); + bw.WriteVector3(LocalPosition2); + bw.Write(Radius); return ms.ToArray(); } } diff --git a/Warcraft.NET/Files/phys/Entries/DSTJEntry.cs b/Warcraft.NET/Files/phys/Entries/DSTJEntry.cs index add4cee..6752e96 100644 --- a/Warcraft.NET/Files/phys/Entries/DSTJEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/DSTJEntry.cs @@ -1,18 +1,25 @@ -using System; using System.IO; -using Warcraft.NET.Files.Structures; +using System.Numerics; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class DSTJEntry { + /// + /// sets or gets the local Anchor for Bone A from the Joint + /// + public Vector3 LocalAnchorA; + /// + /// sets or gets the local Anchor for Bone B from the Joint + /// + public Vector3 LocalAnchorB; - public C3Vector localAnchorA; - public C3Vector localAnchorB; - - public float some_distance_factor; - + /// + /// sets or gets the currently unknown value for the distance joint calculation + /// + public float UnknownDistanceFactor; /// /// Initializes a new instance of the class. @@ -28,9 +35,9 @@ public DSTJEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - localAnchorA = new C3Vector(br.ReadBytes(12)); - localAnchorB = new C3Vector(br.ReadBytes(12)); - some_distance_factor = br.ReadSingle(); + LocalAnchorA = br.ReadVector3(); + LocalAnchorB = br.ReadVector3(); + UnknownDistanceFactor = br.ReadSingle(); } } @@ -50,13 +57,12 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(localAnchorA.asBytes()); - bw.Write(localAnchorB.asBytes()); - bw.Write(some_distance_factor); + bw.WriteVector3(LocalAnchorA); + bw.WriteVector3(LocalAnchorB); + bw.Write(UnknownDistanceFactor); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/JOINEntry.cs b/Warcraft.NET/Files/phys/Entries/JOINEntry.cs index d0f57c3..03aaa3c 100644 --- a/Warcraft.NET/Files/phys/Entries/JOINEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/JOINEntry.cs @@ -1,29 +1,40 @@ -using System; using System.IO; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Enums; -namespace Warcraft.NET.Files.phys.Entries +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, - } + /// + /// sets or gets the index of the first connected Rigidbody + /// + public uint BodyAIdx; - public uint bodyAIdx; - public uint bodyBIdx; - public byte[] unk; + /// + /// sets or gets the index of the second connected Rigidbody + /// + public uint BodyBIdx; - public Joint_Type jointType; - public ushort jointId; + /// + /// sets or gets a Unknown field. + /// + public byte[] Unk; + + /// + /// sets or gets the JointType + /// 0 = SphericalJoint + /// 1 = ShoulderJoint + /// 2 = WeldJoint + /// 3 = RevoluteJoint + /// 4 = PrismaticJoint + /// 5 = DistanceJoint + /// + public JointType JointType; + + /// + /// sets or gets the index of the joint into the joint list based on the JointType field + /// + public ushort JointID; /// /// Initializes a new instance of the class. @@ -39,11 +50,11 @@ public JOINEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - bodyAIdx = br.ReadUInt32(); - bodyBIdx = br.ReadUInt32(); - unk = br.ReadBytes(4); - jointType = (Joint_Type)br.ReadUInt16(); - jointId = br.ReadUInt16(); + BodyAIdx = br.ReadUInt32(); + BodyBIdx = br.ReadUInt32(); + Unk = br.ReadBytes(4); + JointType = (JointType)br.ReadUInt16(); + JointID = br.ReadUInt16(); } } @@ -63,14 +74,12 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(bodyAIdx); - bw.Write(bodyBIdx); - bw.Write(unk); - bw.Write((ushort)jointType); - bw.Write(jointId); - + bw.Write(BodyAIdx); + bw.Write(BodyBIdx); + bw.Write(Unk); + bw.Write((ushort)JointType); + bw.Write(JointID); } - return ms.ToArray(); } } diff --git a/Warcraft.NET/Files/phys/Entries/PLYTEntry.cs b/Warcraft.NET/Files/phys/Entries/PLYTEntry.cs index 0f784c3..5e5ce51 100644 --- a/Warcraft.NET/Files/phys/Entries/PLYTEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/PLYTEntry.cs @@ -1,132 +1,188 @@ -using System; using System.IO; -using System.Linq; -using System.Runtime.InteropServices; -using Warcraft.NET.Files.Structures; +using System.Numerics; +using Warcraft.NET.Extensions; +using Warcraft.NET.Files.Phys.Structures; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class PLYTEntry { - public PLYT_HEADER header; - public PLYT_DATA data; + /// + /// gets or set the Polytope Header + /// + public PlytHeader Header; - [Serializable] - public struct PLYT_HEADER - { - public UInt32 vertexCount; // Mostly 8 - public byte[] unk_04; - public UInt64 RUNTIME_08_ptr_data_0; // = &data[i].unk_0 - public UInt32 count_10; // Mostly 6 - public byte[] unk_14; - public UInt64 RUNTIME_18_ptr_data_1; // = &data[i].unk_1 - public UInt64 RUNTIME_20_ptr_data_2; // = &data[i].unk_2 - public UInt32 nodeCount; // Mostly 24 - public byte[] unk_2C; - public UInt64 RUNTIME_30_ptr_data_3; // = &data[i].unk_3 - public float[] unk_38; // not sure if floats: has e-08 values - } + /// + /// gets or set the Polytope Data + /// + public PlytData Data; + + /// + /// gets or set the Polytope Data + /// + public int DataSize { get; } + + /// + /// Initializes a new instance of the class. + /// + public PLYTEntry() { } - [Serializable] - public struct PLYT_DATA + /// + /// Initializes a new instance of the class. + /// + /// Header Data + public PLYTEntry(byte[] header) { - public C3Vector[] vertices; //amount = vertexCount in header - public byte[] unk1; //multiple of 16 -> amount = count_10 in header - public byte[] unk2; //amount = count_10 in header - public NODE[] nodes;//amount = node_count in header + using (var ms = new MemoryStream(header)) + using (var br = new BinaryReader(ms)) + { + Header = new PlytHeader + { + VertexCount = br.ReadUInt32(), + Unk0 = br.ReadBytes(4), + RUNTIME08ptrData0 = br.ReadUInt64(), + Count10 = br.ReadUInt32(), + Unk1 = br.ReadBytes(4), + RUNTIME18ptrData1 = br.ReadUInt64(), + RUNTIME20ptrData2 = br.ReadUInt64(), + NodeCount = br.ReadUInt32(), + Unk2 = br.ReadBytes(4), + RUNTIME30ptrData3 = br.ReadUInt64(), + Unk3 = [br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle()] + }; + int size = 0; + size += (int)Header.VertexCount * 12; + size += (int)Header.Count10 * 16; + size += (int)Header.Count10; + size += (int)Header.NodeCount * 4; + DataSize = size; + } } - [Serializable] - public struct NODE + /// + /// Deserialization of the Data Chunks + /// + /// + public void DeserializeData(byte[] data) { - public byte unk; // 1 or -1 - public byte vertexIndex; // index in vertex list - public byte unkIndex0; // index into the nodes - public byte unkIndex1; // index into the nodes + using (var ms = new MemoryStream(data)) + using (var br = new BinaryReader(ms)) + { + uint vcount = Header.VertexCount; + uint count_10 = Header.Count10; + uint nodeCount = Header.NodeCount; + + Data.Vertices = new Vector3[vcount]; + for (int v = 0; v < vcount; v++) + { + Data.Vertices[v] = br.ReadVector3(); + } + Data.Unk1 = br.ReadBytes((int)count_10 * 16); + Data.Unk2 = br.ReadBytes((int)count_10); + Data.Nodes = new PlytNode[nodeCount]; + for (int n = 0; n < nodeCount; n++) + { + PlytNode node = new(); + node.Unk = br.ReadByte(); + node.VertexIndex = br.ReadByte(); + node.UnkIndex0 = br.ReadByte(); + node.UnkIndex1 = br.ReadByte(); + Data.Nodes[n] = node; + } + } } /// - /// Initializes a new instance of the class. + /// gets the data size of the polytope. /// - public PLYTEntry() { } + /// The size. + public int GetDataSize() + { + return SerializeData().Length; + } /// - /// Initializes a new instance of the class. + /// gets the header size of the polytope. /// - /// ExtendedData. - public PLYTEntry(byte[] data) + /// The size. + public int GetHeaderSize() { - + return SerializeHeader().Length; } /// - /// Gets the size of a PLYT entry. + /// gets the full size of the polytope. /// /// The size. - public static int GetSize() + public int GetSize() { - return 0; + return SerializeHeader().Length + SerializeData().Length; } - /// + /// + /// Serialize the Header + /// + /// + /// public byte[] SerializeHeader(long offset = 0) { using (var ms = new MemoryStream()) { using (var bw = new BinaryWriter(ms)) { - - bw.Write(header.vertexCount); - bw.Write(header.unk_04); - - bw.Write(header.RUNTIME_08_ptr_data_0); + bw.Write(Header.VertexCount); + bw.Write(Header.Unk0); + + bw.Write(Header.RUNTIME08ptrData0); + + bw.Write(Header.Count10); + bw.Write(Header.Unk1); + + bw.Write(Header.RUNTIME18ptrData1); - bw.Write(header.count_10); - bw.Write(header.unk_14); + bw.Write(Header.RUNTIME20ptrData2); - bw.Write(header.RUNTIME_18_ptr_data_1); + bw.Write(Header.NodeCount); - bw.Write(header.RUNTIME_20_ptr_data_2); + bw.Write(Header.Unk2); - bw.Write(header.nodeCount); - - bw.Write(header.unk_2C); - - bw.Write(header.RUNTIME_30_ptr_data_3); - foreach (float f in header.unk_38) + bw.Write(Header.RUNTIME30ptrData3); + foreach (float f in Header.Unk3) { bw.Write(f); } - - } return ms.ToArray(); } } + + /// + /// Serialize the Data + /// + /// + /// public byte[] SerializeData(long offset = 0) { using (var ms = new MemoryStream()) { using (var bw = new BinaryWriter(ms)) { - foreach (var vertex in data.vertices) + foreach (var vertex in Data.Vertices) { - bw.Write(vertex.asBytes()); + bw.WriteVector3(vertex); } - bw.Write(data.unk1); - bw.Write(data.unk2); - foreach (var node in data.nodes) + bw.Write(Data.Unk1); + bw.Write(Data.Unk2); + foreach (var node in Data.Nodes) { - bw.Write(node.unk); - bw.Write(node.vertexIndex); - bw.Write(node.unkIndex0); - bw.Write(node.unkIndex1); + bw.Write(node.Unk); + bw.Write(node.VertexIndex); + bw.Write(node.UnkIndex0); + bw.Write(node.UnkIndex1); } } return ms.ToArray(); } } - - } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/PRS2Entry.cs b/Warcraft.NET/Files/phys/Entries/PRS2Entry.cs index de4420c..fc925a8 100644 --- a/Warcraft.NET/Files/phys/Entries/PRS2Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/PRS2Entry.cs @@ -1,25 +1,62 @@ -using System; using System.IO; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class PRS2Entry { + /// + /// The Transformation Matrix for Bone A of this Joint + /// + public Matrix3x4 FrameA; + + /// + /// The Transformation Matrix for Bone B of this Joint + /// + public Matrix3x4 FrameB; + + /// + /// The lower limit + /// + public float LowerLimit; + + /// + /// The upper limit + /// + public float UpperLimit; + + /// + /// Unknown value + /// + public float Unk0; + /// + /// Max motor force if enabled + /// + public float MaxMotorForce; - public Mat3x4 frameA; - public Mat3x4 frameB; - public float lowerLimit; - public float upperLimit; - public float _68; - public float maxMotorForce; - public float _70; - public UInt32 motorMode; + /// + /// unknown value + /// + public float Unk1; - public float motorFrequencyHz; - public float motorDampingRatio; + /// + /// The MotorMode + /// 0 = disabled? + /// 1 = motorPositionMode (MotorFrequencyHz>0) + /// 2 = motorVelocityMode + /// + public uint MotorMode; + /// + /// how often per second the motor damps + /// + public float MotorFrequencyHz; + + /// + /// the ratio how much the motor damps + /// + public float MotorDampingRatio; /// /// Initializes a new instance of the class. @@ -35,16 +72,16 @@ public PRS2Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - frameA = new Mat3x4(br.ReadBytes(48)); - frameB = new Mat3x4(br.ReadBytes(48)); - lowerLimit = br.ReadSingle(); - upperLimit = br.ReadSingle(); - _68 = br.ReadSingle(); - maxMotorForce = br.ReadSingle(); - _70 = br.ReadSingle(); - motorMode = br.ReadUInt32(); - motorFrequencyHz = br.ReadSingle(); - motorDampingRatio = br.ReadSingle(); + FrameA = br.ReadMatrix3x4(); + FrameB = br.ReadMatrix3x4(); + LowerLimit = br.ReadSingle(); + UpperLimit = br.ReadSingle(); + Unk0 = br.ReadSingle(); + MaxMotorForce = br.ReadSingle(); + Unk1 = br.ReadSingle(); + MotorMode = br.ReadUInt32(); + MotorFrequencyHz = br.ReadSingle(); + MotorDampingRatio = br.ReadSingle(); } } @@ -64,20 +101,19 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(frameA.asBytes()); - bw.Write(frameB.asBytes()); - bw.Write(lowerLimit); - bw.Write(upperLimit); - bw.Write(_68); - bw.Write(maxMotorForce); - bw.Write(_70); - bw.Write(motorMode); - bw.Write(motorFrequencyHz); - bw.Write(motorDampingRatio); + bw.WriteMatrix3x4(FrameA); + bw.WriteMatrix3x4(FrameB); + bw.Write(LowerLimit); + bw.Write(UpperLimit); + bw.Write(Unk0); + bw.Write(MaxMotorForce); + bw.Write(Unk1); + bw.Write(MotorMode); + bw.Write(MotorFrequencyHz); + bw.Write(MotorDampingRatio); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/REV2Entry.cs b/Warcraft.NET/Files/phys/Entries/REV2Entry.cs index b1ef402..bc747ac 100644 --- a/Warcraft.NET/Files/phys/Entries/REV2Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/REV2Entry.cs @@ -1,22 +1,48 @@ -using System; using System.IO; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class REV2Entry { - public Mat3x4 frameA; - public Mat3x4 frameB; - public float lowerAngle; - public float upperAngle; + /// + /// The Transformation Matrix for Bone A of this Joint + /// + public Matrix3x4 FrameA; - public float maxMotorTorque; - public UInt32 motorMode; // 1: motorPositionMode → frequency > 0, 2: motorVelocityMode + /// + /// The Transformation Matrix for Bone B of this Joint + /// + public Matrix3x4 FrameB; - public float motorFrequencyHz; - public float motorDampingRatio; + /// + /// The lower swing angle + /// + public float LowerAngle; + /// + /// The upper swing angle + /// + public float UpperAngle; + /// + /// The max motor torque + /// + public float MaxMotorTorque; + /// + /// The MotorMode + /// 0 = disabled? + /// 1 = motorPositionMode (MotorFrequencyHz>0) + /// 2 = motorVelocityMode + /// + public uint MotorMode; // 1: motorPositionMode → frequency > 0, 2: motorVelocityMode + /// + /// how often per second the motor damps + /// + public float MotorFrequencyHz; + /// + /// the ratio how much the motor damps + /// + public float MotorDampingRatio; /// /// Initializes a new instance of the class. @@ -32,14 +58,14 @@ public REV2Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - frameA = new Mat3x4(br.ReadBytes(48)); - frameB = new Mat3x4(br.ReadBytes(48)); - lowerAngle = br.ReadSingle(); - upperAngle = br.ReadSingle(); - maxMotorTorque = br.ReadSingle(); - motorMode = br.ReadUInt32(); - motorFrequencyHz = br.ReadSingle(); - motorDampingRatio = br.ReadSingle(); + FrameA = br.ReadMatrix3x4(); + FrameB = br.ReadMatrix3x4(); + LowerAngle = br.ReadSingle(); + UpperAngle = br.ReadSingle(); + MaxMotorTorque = br.ReadSingle(); + MotorMode = br.ReadUInt32(); + MotorFrequencyHz = br.ReadSingle(); + MotorDampingRatio = br.ReadSingle(); } } @@ -59,18 +85,17 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(frameA.asBytes()); - bw.Write(frameB.asBytes()); - bw.Write(lowerAngle); - bw.Write(upperAngle); - bw.Write(maxMotorTorque); - bw.Write(motorMode); - bw.Write(motorFrequencyHz); - bw.Write(motorDampingRatio); + bw.WriteMatrix3x4(FrameA); + bw.WriteMatrix3x4(FrameB); + bw.Write(LowerAngle); + bw.Write(UpperAngle); + bw.Write(MaxMotorTorque); + bw.Write(MotorMode); + bw.Write(MotorFrequencyHz); + bw.Write(MotorDampingRatio); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/SHJ2Entry.cs b/Warcraft.NET/Files/phys/Entries/SHJ2Entry.cs index cdd41f5..0586d11 100644 --- a/Warcraft.NET/Files/phys/Entries/SHJ2Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/SHJ2Entry.cs @@ -1,24 +1,57 @@ -using System; -using System.IO; -using Warcraft.NET.Files.Structures; +using System.IO; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class SHJ2Entry { + /// + /// The Transformation Matrix for Bone A of this Joint + /// + public Matrix3x4 FrameA; + /// + /// The Transformation Matrix for Bone B of this Joint + /// + public Matrix3x4 FrameB; - public Mat3x4 frameA; - public Mat3x4 frameB; - public float lowerTwistAngle; - public float upperTwistAngle; - public float coneAngle; - public float maxMotorTorque; - public UInt32 motorMode; // NO BACKWARDS COMPATIBILITY as of Legion (7.0.1.20979) and Legion (7.3.0.24931)! client always assumes new size! + /// + /// The lower twist angle of the angular constraint + /// + public float LowerTwistAngle; - public float motorFrequencyHz; - public float motorDampingRatio; + /// + /// The upper twist angle of the angular constraint + /// + public float UpperTwistAngle; + /// + /// The cone angle of the angular constraint + /// + public float ConeAngle; + + /// + /// The max motor torque + /// + public float MaxMotorTorque; + + /// + /// The MotorMode + /// 0 = disabled? + /// 1 = motorPositionMode (MotorFrequencyHz>0) + /// 2 = motorVelocityMode + /// + public uint MotorMode; // 1: motorPositionMode → frequency > 0, 2: motorVelocityMode + + /// + /// how often per second the motor damps + /// + public float MotorFrequencyHz; + + /// + /// the ratio how much the motor damps + /// + public float MotorDampingRatio; /// /// Initializes a new instance of the class. @@ -34,15 +67,15 @@ public SHJ2Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - frameA = new Mat3x4(br.ReadBytes(48)); - frameB = new Mat3x4(br.ReadBytes(48)); - lowerTwistAngle = br.ReadSingle(); - upperTwistAngle = br.ReadSingle(); - coneAngle = br.ReadSingle(); - maxMotorTorque = br.ReadSingle(); - motorMode = br.ReadUInt32(); - motorFrequencyHz = br.ReadSingle(); - motorDampingRatio = br.ReadSingle(); + FrameA = br.ReadMatrix3x4(); + FrameB = br.ReadMatrix3x4(); + LowerTwistAngle = br.ReadSingle(); + UpperTwistAngle = br.ReadSingle(); + ConeAngle = br.ReadSingle(); + MaxMotorTorque = br.ReadSingle(); + MotorMode = br.ReadUInt32(); + MotorFrequencyHz = br.ReadSingle(); + MotorDampingRatio = br.ReadSingle(); } } @@ -62,19 +95,18 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(frameA.asBytes()); - bw.Write(frameB.asBytes()); - bw.Write(lowerTwistAngle); - bw.Write(upperTwistAngle); - bw.Write(coneAngle); - bw.Write(maxMotorTorque); - bw.Write(motorMode); - bw.Write(motorFrequencyHz); - bw.Write(motorDampingRatio); + bw.WriteMatrix3x4(FrameA); + bw.WriteMatrix3x4(FrameB); + bw.Write(LowerTwistAngle); + bw.Write(UpperTwistAngle); + bw.Write(ConeAngle); + bw.Write(MaxMotorTorque); + bw.Write(MotorMode); + bw.Write(MotorFrequencyHz); + bw.Write(MotorDampingRatio); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/SHOJEntry.cs b/Warcraft.NET/Files/phys/Entries/SHOJEntry.cs index 5218b7a..1c5bead 100644 --- a/Warcraft.NET/Files/phys/Entries/SHOJEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/SHOJEntry.cs @@ -1,21 +1,47 @@ -using System; -using System.IO; -using Warcraft.NET.Files.Structures; +using System.IO; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class SHOJEntry { + /// + /// The Transformation Matrix for Bone A of this Joint + /// + public Matrix3x4 FrameA; + + /// + /// The Transformation Matrix for Bone B of this Joint + /// + public Matrix3x4 FrameB; + + /// + /// The lower twist angle for the angular constraint + /// + public float LowerTwistAngle; + + /// + /// The upper twist angle for the angular constraint + /// + public float UpperTwistAngle; + /// + /// The cone angle for the angular constraint + /// + public float ConeAngle; - public Mat3x4 frameA; - public Mat3x4 frameB; - public float lowerTwistAngle; - public float upperTwistAngle; - public float coneAngle; - public float maxMotorTorque; - public UInt32 motorMode; // NO BACKWARDS COMPATIBILITY as of Legion (7.0.1.20979) and Legion (7.3.0.24931)! client always assumes new size! + /// + /// The Maximum torque the motor can apply + /// + public float MaxMotorTorque; + /// + /// The MotorMode + /// 0 = disabled? + /// 1 = motorPositionMode (MotorFrequencyHz>0) + /// 2 = motorVelocityMode + /// + public uint MotorMode; // NO BACKWARDS COMPATIBILITY as of Legion (7.0.1.20979) and Legion (7.3.0.24931)! client always assumes new size! /// /// Initializes a new instance of the class. @@ -31,13 +57,13 @@ public SHOJEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - frameA = new Mat3x4(br.ReadBytes(48)); - frameB = new Mat3x4(br.ReadBytes(48)); - lowerTwistAngle = br.ReadSingle(); - upperTwistAngle = br.ReadSingle(); - coneAngle = br.ReadSingle(); - maxMotorTorque = br.ReadSingle(); - motorMode = br.ReadUInt32(); + FrameA = br.ReadMatrix3x4(); + FrameB = br.ReadMatrix3x4(); + LowerTwistAngle = br.ReadSingle(); + UpperTwistAngle = br.ReadSingle(); + ConeAngle = br.ReadSingle(); + MaxMotorTorque = br.ReadSingle(); + MotorMode = br.ReadUInt32(); } } @@ -57,17 +83,16 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(frameA.asBytes()); - bw.Write(frameB.asBytes()); - bw.Write(lowerTwistAngle); - bw.Write(upperTwistAngle); - bw.Write(coneAngle); - bw.Write(maxMotorTorque); - bw.Write(motorMode); + bw.WriteMatrix3x4(FrameA); + bw.WriteMatrix3x4(FrameB); + bw.Write(LowerTwistAngle); + bw.Write(UpperTwistAngle); + bw.Write(ConeAngle); + bw.Write(MaxMotorTorque); + bw.Write(MotorMode); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs b/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs index 5f1efe3..e179c04 100644 --- a/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/SHP2Entry.cs @@ -1,44 +1,63 @@ -using System; using System.IO; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Files.Phys.Enums; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { + public class SHP2Entry + { + /// + /// The Shape Type + /// 0 = Box + /// 1 = Capsule + /// 2 = Sphere + /// 3 = Polytope + /// + public ShapeType ShapeType; + /// + /// The index into the corresponding chunk based on ShapeType + /// + public ushort ShapeIndex; + + /// + /// unknown field + /// + public byte[] Unk0; + /// + /// the friction of the shape + /// + public float Friction; - public class SHP2Entry - { - public enum Shape_Type : short - { - box = 0, - caps = 1, - sphere = 2, - polytope = 3, - } + /// + /// the restitution of the shape + /// + public float Restitution; + + /// + /// the density of the shape + /// + public float Density; - /*0x00*/ - public Shape_Type shapeType; - /*0x02*/ - public ushort shapeIndex; // into the corresponding chunk - /*0x04*/ - public byte[] unk; - /*0x08*/ - public float friction; - /*0x0c*/ - public float restitution; - /*0x10*/ - public float density; - /*0x14*/ - public UInt32 _x14; // default 0 - /*0x18*/ - public float _x18; // default 1.0 - /*0x1c*/ - public UInt16 _x1c; // default 0 - /*0x1e*/ - public UInt16 _x1e; // no default, padding? + /// + /// unknown field + /// + public uint Unk1 = 0; + + /// + /// unknown field + /// + public float Unk2 = 1f; + /// + /// unknown field + /// + public ushort Unk3 = 0; + /// + /// unknown field + /// + public ushort Unk4; //no default, padding? /// /// Initializes a new instance of the class. @@ -54,16 +73,16 @@ public SHP2Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - shapeType = (Shape_Type)br.ReadUInt16(); - shapeIndex = br.ReadUInt16(); - unk = br.ReadBytes(4); - friction = br.ReadSingle(); - restitution = br.ReadSingle(); - density = br.ReadSingle(); - _x14 = br.ReadUInt32(); - _x18 = br.ReadSingle(); - _x1c = br.ReadUInt16(); - _x1e = br.ReadUInt16(); + ShapeType = (ShapeType)br.ReadUInt16(); + ShapeIndex = br.ReadUInt16(); + Unk0 = br.ReadBytes(4); + Friction = br.ReadSingle(); + Restitution = br.ReadSingle(); + Density = br.ReadSingle(); + Unk1 = br.ReadUInt32(); + Unk2 = br.ReadSingle(); + Unk3 = br.ReadUInt16(); + Unk4 = br.ReadUInt16(); } } @@ -83,22 +102,19 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write((ushort)shapeType); - bw.Write(shapeIndex); - bw.Write(unk); - bw.Write(friction); - bw.Write(restitution); - bw.Write(density); - bw.Write(_x14); - bw.Write(_x18); - bw.Write(_x1c); - bw.Write(_x1e); + bw.Write((ushort)ShapeType); + bw.Write(ShapeIndex); + bw.Write(Unk0); + bw.Write(Friction); + bw.Write(Restitution); + bw.Write(Density); + bw.Write(Unk1); + bw.Write(Unk2); + bw.Write(Unk3); + bw.Write(Unk4); } - return ms.ToArray(); } } - - } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/SPHJEntry.cs b/Warcraft.NET/Files/phys/Entries/SPHJEntry.cs index a2a428d..1f0d175 100644 --- a/Warcraft.NET/Files/phys/Entries/SPHJEntry.cs +++ b/Warcraft.NET/Files/phys/Entries/SPHJEntry.cs @@ -1,15 +1,26 @@ -using System; using System.IO; +using System.Numerics; +using Warcraft.NET.Extensions; using Warcraft.NET.Files.Structures; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class SPHJEntry { - public C3Vector anchorA; - public C3Vector anchorB; - public float frictionTorque; + /// + /// the local anchor of the Bone A of the joint + /// + public Vector3 AnchorA; + + /// + /// the local anchor of the Bone B of the joint + /// + public Vector3 AnchorB; + /// + /// the friction torque + /// + public float FrictionTorque; /// /// Initializes a new instance of the class. @@ -25,9 +36,9 @@ public SPHJEntry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - anchorA = new C3Vector(br.ReadBytes(12)); - anchorB = new C3Vector(br.ReadBytes(12)); - frictionTorque = br.ReadSingle(); + AnchorA = br.ReadVector3(AxisConfiguration.ZUp); + AnchorB = br.ReadVector3(AxisConfiguration.ZUp); + FrictionTorque = br.ReadSingle(); } } @@ -47,13 +58,12 @@ public byte[] Serialize(long offset = 0) { using (var bw = new BinaryWriter(ms)) { - bw.Write(anchorA.asBytes()); - bw.Write(anchorB.asBytes()); - bw.Write(frictionTorque); + bw.WriteVector3(AnchorA); + bw.WriteVector3(AnchorB); + bw.Write(FrictionTorque); } - return ms.ToArray(); } } } -} +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/SPHSEntry.cs b/Warcraft.NET/Files/phys/Entries/SPHSEntry.cs new file mode 100644 index 0000000..51ceec7 --- /dev/null +++ b/Warcraft.NET/Files/phys/Entries/SPHSEntry.cs @@ -0,0 +1,52 @@ +using System.IO; +using System.Numerics; +using Warcraft.NET.Extensions; + +namespace Warcraft.NET.Files.Phys.Entries +{ + public class SPHSEntry + { + /// + /// Gets or Sets the local position of the Sphere shape + /// + public Vector3 LocalPosition; + + /// + /// Gets or Sets the radius of the Sphere shape + /// + public float Radius; + + public SPHSEntry(byte[] data) + { + using (var ms = new MemoryStream(data)) + using (var br = new BinaryReader(ms)) + { + LocalPosition = br.ReadVector3(); + Radius = br.ReadSingle(); + } + } + + /// + /// Gets the size of a Sphere entry. + /// + /// The size. + public static int GetSize() + { + return 16; + } + + /// + public byte[] Serialize(long offset = 0) + { + using (var ms = new MemoryStream()) + { + using (var bw = new BinaryWriter(ms)) + { + bw.WriteVector3(LocalPosition); + bw.Write(Radius); + } + return ms.ToArray(); + } + } + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Entries/WLJ3Entry.cs b/Warcraft.NET/Files/phys/Entries/WLJ3Entry.cs index 56be673..396083e 100644 --- a/Warcraft.NET/Files/phys/Entries/WLJ3Entry.cs +++ b/Warcraft.NET/Files/phys/Entries/WLJ3Entry.cs @@ -1,21 +1,44 @@ -using System; using System.IO; -using Warcraft.NET.Files.Structures; +using Warcraft.NET.Extensions; -namespace Warcraft.NET.Files.phys.Entries +namespace Warcraft.NET.Files.Phys.Entries { public class WLJ3Entry { - public Mat3x4 frameA; - public Mat3x4 frameB; - public float angularFrequencyHz; - public float angularDampingRatio; + /// + /// The Transformation Matrix for Bone A of this Joint + /// + public Matrix3x4 FrameA; + + /// + /// The Transformation Matrix for Bone B of this Joint + /// + public Matrix3x4 FrameB; + + /// + /// how often the angular dampening is applied per second + /// + public float AngularFrequencyHz; + + /// + /// the ratio how strong the angular dampening is applied + /// + public float AngularDampingRatio; - public float linearFrequencyHz; // default 0 - public float linearDampingRatio; // default 0 + /// + /// how often the linear dampening is applied per second + /// + public float LinearFrequencyHz; // default 0 - public float unk70; + /// + /// the ratio how linear the angular dampening is applied + /// + public float LinearDampingRatio; // default 0 + /// + /// unknown field + /// + public float Unk0; /// /// Initializes a new instance of the class. @@ -31,13 +54,13 @@ public WLJ3Entry(byte[] data) using (var ms = new MemoryStream(data)) using (var br = new BinaryReader(ms)) { - frameA = new Mat3x4(br.ReadBytes(48)); - frameB = new Mat3x4(br.ReadBytes(48)); - angularFrequencyHz = br.ReadSingle(); - angularDampingRatio = br.ReadSingle(); - linearFrequencyHz = br.ReadSingle(); - linearDampingRatio = br.ReadSingle(); - unk70 = br.ReadSingle(); + FrameA = br.ReadMatrix3x4(); + FrameB = br.ReadMatrix3x4(); + AngularFrequencyHz = br.ReadSingle(); + AngularDampingRatio = br.ReadSingle(); + LinearFrequencyHz = br.ReadSingle(); + LinearDampingRatio = br.ReadSingle(); + Unk0 = br.ReadSingle(); } } @@ -54,18 +77,15 @@ public static int GetSize() public byte[] Serialize(long offset = 0) { using (var ms = new MemoryStream()) + using (var bw = new BinaryWriter(ms)) { - using (var bw = new BinaryWriter(ms)) - { - bw.Write(frameA.asBytes()); - bw.Write(frameB.asBytes()); - bw.Write(angularFrequencyHz); - bw.Write(angularDampingRatio); - bw.Write(linearFrequencyHz); - bw.Write(linearDampingRatio); - bw.Write(unk70); - } - + bw.WriteMatrix3x4(FrameA); + bw.WriteMatrix3x4(FrameB); + bw.Write(AngularFrequencyHz); + bw.Write(AngularDampingRatio); + bw.Write(LinearFrequencyHz); + bw.Write(LinearDampingRatio); + bw.Write(Unk0); return ms.ToArray(); } } diff --git a/Warcraft.NET/Files/phys/Enums/BodyType.cs b/Warcraft.NET/Files/phys/Enums/BodyType.cs new file mode 100644 index 0000000..5908459 --- /dev/null +++ b/Warcraft.NET/Files/phys/Enums/BodyType.cs @@ -0,0 +1,9 @@ +namespace Warcraft.NET.Files.Phys.Enums +{ + public enum BodyType : ushort + { + root = 0, + dynamic = 1, + unk = 2, + } +} diff --git a/Warcraft.NET/Files/phys/Enums/JointType.cs b/Warcraft.NET/Files/phys/Enums/JointType.cs new file mode 100644 index 0000000..e7f605d --- /dev/null +++ b/Warcraft.NET/Files/phys/Enums/JointType.cs @@ -0,0 +1,12 @@ +namespace Warcraft.NET.Files.Phys.Enums +{ + public enum JointType : ushort + { + sphericalJoint = 0, + shoulderJoint = 1, + weldJoint = 2, + revoluteJoint = 3, + prismaticJoint = 4, + distanceJoint = 5, + } +} diff --git a/Warcraft.NET/Files/phys/Enums/ShapeType.cs b/Warcraft.NET/Files/phys/Enums/ShapeType.cs new file mode 100644 index 0000000..290f93f --- /dev/null +++ b/Warcraft.NET/Files/phys/Enums/ShapeType.cs @@ -0,0 +1,10 @@ +namespace Warcraft.NET.Files.Phys.Enums +{ + public enum ShapeType : short + { + box = 0, + caps = 1, + sphere = 2, + polytope = 3, + } +} diff --git a/Warcraft.NET/Files/phys/Physics.cs b/Warcraft.NET/Files/phys/Physics.cs index 343102b..45ec5ef 100644 --- a/Warcraft.NET/Files/phys/Physics.cs +++ b/Warcraft.NET/Files/phys/Physics.cs @@ -1,61 +1,113 @@ using Warcraft.NET.Attribute; -using Warcraft.NET.Files.phys.Chunks; +using Warcraft.NET.Files.Phys.Chunks; -namespace Warcraft.NET.Files.phys +namespace Warcraft.NET.Files.Phys { [AutoDocFile("phys")] public class Physics : ChunkedFile { + /// + /// contains the version of the physics + /// [ChunkOrder(1)] - public PHYS phys{get; set;} + public PHYS Version{get; set;} - [ChunkOptional] - public PHYT phyt{get; set;} + /// + /// contains an unknown uint + /// + [ChunkOrder(2),ChunkOptional] + public PHYT Phyt{get; set; } - [ChunkOptional] - public BOXS boxs{get;set;} + /// + /// contains the used box shapes + /// + [ChunkOrder(3),ChunkOptional] + public BOXS BoxShapes{get;set;} - [ChunkOptional] - public SPHS sphs{get;set;} + /// + /// contains the used sphere shapes + /// + [ChunkOrder(4),ChunkOptional] + public SPHS SphereShapes{get;set;} - [ChunkOptional] - public CAPS caps{get;set;} + /// + /// contains the used capsule shapes + /// + + [ChunkOrder(5),ChunkOptional] + public CAPS CapsuleShapes{get;set;} - [ChunkOptional] - public PLYT plyt{get; set;} + /// + /// contains the used polytope shapes + /// + [ChunkOrder(6),ChunkOptional] + public PLYT PolytopeShapes{get; set;} - [ChunkOptional] - public SHP2 shp2{get; set;} + /// + /// contains the used shapes + /// + [ChunkOrder(7),ChunkOptional] + public SHP2 Shapes2{get; set;} //SHAP nyi - [ChunkOptional] - public BDY4 bdy4{get; set;} + /// + /// contains the used rigidbodies + /// + [ChunkOrder(8),ChunkOptional] + public BDY4 Rigidbodies4{get; set;} //BODY,BDY2,BDY3 NYI - [ChunkOptional] - public SHOJ shoj { get; set; } + /// + /// contains the used shoulder joints + /// + [ChunkOrder(9),ChunkOptional] + public SHOJ ShoulderJoints { get; set; } - [ChunkOptional] - public SHJ2 shj2{get; set;} + /// + /// contains the used shoulder joints + /// + [ChunkOrder(10),ChunkOptional] + public SHJ2 ShoulderJoints2{get; set;} - [ChunkOptional] - public WLJ3 wlj3{get; set;} + /// + /// contains the used weld joints + /// + [ChunkOrder(11),ChunkOptional] + public WLJ3 WeldJoints3{get; set;} //WELJ,WLJ2 nyi - [ChunkOptional] - public SPHJ sphj{get; set;} + /// + /// contains the used spherical joints + /// + [ChunkOrder(12),ChunkOptional] + public SPHJ SphericalJoints{get; set;} + + /// + /// contains the used prismatic joints + /// + [ChunkOrder(13),ChunkOptional] + public PRS2 PrismaticJoints2{get; set;} //PRSJ nyi - [ChunkOptional] - public PRS2 prs2{get; set;} + /// + /// contains the used revolute joints + /// + [ChunkOrder(14),ChunkOptional] + public REV2 RevoluteJoints2{get; set;} //REVJ nyi - [ChunkOptional] - public REV2 rev2{get; set;} + /// + /// contains the used distance joints + /// + [ChunkOrder(15),ChunkOptional] + public DSTJ DistanceJoints{get; set;} - [ChunkOptional] - public DSTJ dstj{get; set;} - - [ChunkOptional] - public JOIN join{get; set;} + /// + /// contains the used joints + /// + [ChunkOrder(16),ChunkOptional] + public JOIN Joints{get; set;} - [ChunkOptional] - public PHYV phyv { get; set; } + /// + /// contains the used phyv data (unknown) + /// + [ChunkOrder(17),ChunkOptional] + public PHYV Phyv { get; set; } /// /// Initializes a new instance of the class. diff --git a/Warcraft.NET/Files/phys/Structures/PlytData.cs b/Warcraft.NET/Files/phys/Structures/PlytData.cs new file mode 100644 index 0000000..65ddf95 --- /dev/null +++ b/Warcraft.NET/Files/phys/Structures/PlytData.cs @@ -0,0 +1,29 @@ +using System; +using System.Numerics; + +namespace Warcraft.NET.Files.Phys.Structures +{ + [Serializable] + public struct PlytData + { + /// + /// gets or sets the vertices. Amount is defined by header.VertexCount + /// + public Vector3[] Vertices; //amount = VertexCount in Header + + /// + /// gets or sets the Unk1 array. Unknown purpose. Amount is defined by header.Count10 + /// + public byte[] Unk1; //multiple of 16 -> amount = count_10 in Header + + /// + /// gets or sets the Unk2 array. Unknown purpose.Amount is defined by header.Count10 + /// + public byte[] Unk2; //amount = count_10 in Header + + /// + /// gets or sets the Unk2 array. Unknown purpose.Amount is defined by header.NodeCount + /// + public PlytNode[] Nodes; + } +} diff --git a/Warcraft.NET/Files/phys/Structures/PlytHeader.cs b/Warcraft.NET/Files/phys/Structures/PlytHeader.cs new file mode 100644 index 0000000..c6b871a --- /dev/null +++ b/Warcraft.NET/Files/phys/Structures/PlytHeader.cs @@ -0,0 +1,62 @@ +using System; + +namespace Warcraft.NET.Files.Phys.Structures +{ + public struct PlytHeader + { + /// + /// gets or sets the amount of vertices for this polytope + /// + public uint VertexCount; + + /// + /// gets or sets unknown data + /// + public byte[] Unk0; + + /// + /// gets or sets certain runtime data. Unknown purpose + /// + public UInt64 RUNTIME08ptrData0; + + /// + /// gets or sets the count10, which defines how many Unk1[] and Unk2[] there are inside the Data. + /// + public uint Count10; + + /// + /// gets or sets the Unk1 array. Unknown purpose + /// + public byte[] Unk1; + + /// + /// gets or sets certain runtime data. Unknown purpose + /// + public UInt64 RUNTIME18ptrData1; + + /// + /// gets or sets certain runtime data. Unknown purpose + /// + public UInt64 RUNTIME20ptrData2; + + /// + /// gets or sets the amount of nodes. Defines how Vertices are connected + /// + public uint NodeCount; + + /// + /// gets or sets the Unk2 array. Unknown purpose + /// + public byte[] Unk2; + + /// + /// gets or sets certain runtime data. Unknown purpose + /// + public UInt64 RUNTIME30ptrData3; + + /// + /// gets or sets the Unk3 array. Unknown purpose + /// + public float[] Unk3; + } +} \ No newline at end of file diff --git a/Warcraft.NET/Files/phys/Structures/PlytNode.cs b/Warcraft.NET/Files/phys/Structures/PlytNode.cs new file mode 100644 index 0000000..c727e69 --- /dev/null +++ b/Warcraft.NET/Files/phys/Structures/PlytNode.cs @@ -0,0 +1,29 @@ +using System; + +namespace Warcraft.NET.Files.Phys.Structures +{ + + [Serializable] + public struct PlytNode + { + /// + /// Unknown byte. Always 1 or -1 + /// + public byte Unk; // 1 or -1 + + /// + /// Index into the data.Vertices + /// + public byte VertexIndex; // index in vertex list + + /// + /// Index into data.Nodes + /// + public byte UnkIndex0; // index into the nodes + + /// + /// Index into data.Nodes + /// + public byte UnkIndex1; // index into the nodes + } +} \ No newline at end of file