Skip to content

Commit

Permalink
Added Physics and other Chunks
Browse files Browse the repository at this point in the history
  • Loading branch information
gul4sch committed Aug 9, 2024
1 parent cb14560 commit f9c08ef
Show file tree
Hide file tree
Showing 49 changed files with 3,304 additions and 37 deletions.
26 changes: 26 additions & 0 deletions Warcraft.NET.Docs/ChunkAvailability.cs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,32 @@ internal static class ChunkAvailability
}
},
}
},{
"phys", new ()
{
{
"PHYS", new()
{
"PHYS",
"PHYT",
"BDY4",
"SHP2",
"BOXS",
"CAPS",
"SPHS",
"PLYT",
"JOIN",
"WLJ3",
"SPHJ",
"SHJ2",
"PRS2",
"REV2",
"DSTJ",
"SHOJ",
"PHYV",
}
},
}
},
{
"tex", new ()
Expand Down
44 changes: 31 additions & 13 deletions Warcraft.NET.Docs/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using Warcraft.NET.Docs.Steps;
using Warcraft.NET.Files.M2;
using Warcraft.NET.Files.phys;

namespace Warcraft.NET.Docs
{
Expand All @@ -10,24 +12,40 @@ internal class Program
/// <param name="args"></param>
static void Main(string[] args)
{
Console.WriteLine($"BaseDirectory: {AppDomain.CurrentDomain.BaseDirectory}");
string iripath = "C:\\Users\\marce\\Desktop\\WoWStuff\\wow.export\\creature\\iridikron\\";
byte[] data = File.ReadAllBytes(iripath+"iridikron.m2");
Model m = new Model(data);

if (args.Length == 0)
throw new System.Exception("Please provide an output folder");
byte[] phys_test = File.ReadAllBytes("D:\\Unity Projects\\M2Tool\\M2Godot\\buckle_panstart_a_01.phys");
Physics phys = new Physics(phys_test);

string outputFolder = Path.GetFullPath(args[0]);
if (!Directory.Exists(outputFolder))
throw new Exception("Output folder does not exist");
File.WriteAllBytes(iripath+"iridikron_output.m2", m.Serialize());
File.WriteAllBytes("D:\\Unity Projects\\M2Tool\\M2Godot\\buckle_panstart_a_01_output.phys", phys.Serialize());

Console.WriteLine($"Output folder: {outputFolder}");

Console.WriteLine("Generating documentation...");
var autoDocData = GenerateAutoDocDataStep.Process();

Console.WriteLine("Converting to markdown...");
ConvertToMarkdownStep.Process(autoDocData, outputFolder);
if (1==2) {

Console.WriteLine("Done!");
}

Console.WriteLine($"BaseDirectory: {AppDomain.CurrentDomain.BaseDirectory}");

if (args.Length == 0)
throw new System.Exception("Please provide an output folder");

string outputFolder = Path.GetFullPath(args[0]);
if (!Directory.Exists(outputFolder))
throw new Exception("Output folder does not exist");

Console.WriteLine($"Output folder: {outputFolder}");

Console.WriteLine("Generating documentation...");
var autoDocData = GenerateAutoDocDataStep.Process();

Console.WriteLine("Converting to markdown...");
ConvertToMarkdownStep.Process(autoDocData, outputFolder);

Console.WriteLine("Done!");
}
}
}
}
71 changes: 71 additions & 0 deletions Warcraft.NET/Files/M2/Chunks/Legion/EXPT.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Collections.Generic;
using System.IO;
using Warcraft.NET.Attribute;
using Warcraft.NET.Files.Interfaces;
using Warcraft.NET.Files.M2.Entries;

namespace Warcraft.NET.Files.M2.Chunks.Legion
{
[AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)]
public class EXPT : IIFFChunk, IBinarySerializable
{
/// <summary>
/// Holds the binary chunk signature.
/// </summary>
public const string Signature = "EXP2";

/// <summary>
/// Gets or sets the Skin FileDataId
/// </summary>
public List<EXPTEntry> EXP2Entries = new();

/// <summary>
/// Initializes a new instance of <see cref="EXPT"/>
/// </summary>
public EXPT() { }

/// <summary>
/// Initializes a new instance of <see cref="EXPT"/>
/// </summary>
/// <param name="inData">ExtendedData.</param>
public EXPT(byte[] inData) => LoadBinaryData(inData);

/// <inheritdoc />
public string GetSignature() { return Signature; }

/// <inheritdoc />
public uint GetSize() { return (uint)Serialize().Length; }

/// <inheritdoc />
public void LoadBinaryData(byte[] inData)
{
{
using (var ms = new MemoryStream(inData))
using (var br = new BinaryReader(ms))
{
var exp2count = br.BaseStream.Length / EXPTEntry.GetSize();
for (var i = 0; i < exp2count; ++i)
{
EXP2Entries.Add(new EXPTEntry(br.ReadBytes(EXPTEntry.GetSize())));
}
}
}
}

/// <inheritdoc />
public byte[] Serialize(long offset = 0)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
{
foreach (EXPTEntry obj in EXP2Entries)
{
bw.Write(obj.Serialize());
}

return ms.ToArray();
}
}

}
}
71 changes: 71 additions & 0 deletions Warcraft.NET/Files/M2/Chunks/Legion/LDV1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
using System.Collections.Generic;
using System.IO;
using Warcraft.NET.Attribute;
using Warcraft.NET.Files.Interfaces;
using Warcraft.NET.Files.M2.Entries;

namespace Warcraft.NET.Files.M2.Chunks.Legion
{
[AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)]
public class LDV1 : IIFFChunk, IBinarySerializable
{
/// <summary>
/// Holds the binary chunk signature.
/// </summary>
public const string Signature = "LDV1";

/// <summary>
/// Gets or sets the Skin FileDataId
/// </summary>
public List<LDV1Entry> LDV1Entries = new();

/// <summary>
/// Initializes a new instance of <see cref="LDV1"/>
/// </summary>
public LDV1() { }

/// <summary>
/// Initializes a new instance of <see cref="LDV1"/>
/// </summary>
/// <param name="inData">ExtendedData.</param>
public LDV1(byte[] inData) => LoadBinaryData(inData);

/// <inheritdoc />
public string GetSignature() { return Signature; }

/// <inheritdoc />
public uint GetSize() { return (uint)Serialize().Length; }

/// <inheritdoc />
public void LoadBinaryData(byte[] inData)
{
{
using (var ms = new MemoryStream(inData))
using (var br = new BinaryReader(ms))
{
var LDV1count = br.BaseStream.Length / LDV1Entry.GetSize();
for (var i = 0; i < LDV1count; ++i)
{
LDV1Entries.Add(new LDV1Entry(br.ReadBytes(LDV1Entry.GetSize())));
}
}
}
}

/// <inheritdoc />
public byte[] Serialize(long offset = 0)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
{
foreach (LDV1Entry obj in LDV1Entries)
{
bw.Write(obj.Serialize());
}

return ms.ToArray();
}
}

}
}
72 changes: 72 additions & 0 deletions Warcraft.NET/Files/M2/Chunks/Legion/PGD1.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.IO;
using Warcraft.NET.Attribute;
using Warcraft.NET.Files.Interfaces;
using Warcraft.NET.Files.M2.Entries;

namespace Warcraft.NET.Files.M2.Chunks.Legion
{
[AutoDocChunk(AutoDocChunkVersionHelper.VersionAfterWoD, AutoDocChunkVersionHelper.VersionBeforeLegion)]
public class PGD1 : IIFFChunk, IBinarySerializable
{
/// <summary>
/// Holds the binary chunk signature.
/// </summary>
public const string Signature = "PGD1";

/// <summary>
/// Gets or sets the Skin FileDataId
/// </summary>
public List<UInt16> PGD1Entries = new();

/// <summary>
/// Initializes a new instance of <see cref="PGD1"/>
/// </summary>
public PGD1() { }

/// <summary>
/// Initializes a new instance of <see cref="PGD1"/>
/// </summary>
/// <param name="inData">ExtendedData.</param>
public PGD1(byte[] inData) => LoadBinaryData(inData);

/// <inheritdoc />
public string GetSignature() { return Signature; }

/// <inheritdoc />
public uint GetSize() { return (uint)Serialize().Length; }

/// <inheritdoc />
public void LoadBinaryData(byte[] inData)
{
{
using (var ms = new MemoryStream(inData))
using (var br = new BinaryReader(ms))
{
var PGD1count = br.BaseStream.Length / 2;
for (var i = 0; i < PGD1count; ++i)
{
PGD1Entries.Add(br.ReadUInt16());
}
}
}
}

/// <inheritdoc />
public byte[] Serialize(long offset = 0)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
{
foreach (UInt16 obj in PGD1Entries)
{
bw.Write(obj);
}

return ms.ToArray();
}
}

}
}
59 changes: 59 additions & 0 deletions Warcraft.NET/Files/M2/Chunks/Legion/TXAC.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
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 TXAC : IIFFChunk, IBinarySerializable
{
/// <summary>
/// Holds the binary chunk signature.
/// </summary>
public const string Signature = "TXAC";

/// <summary>
/// Gets or sets the Skin FileDataId
/// </summary>
public byte[] unk;

/// <summary>
/// Initializes a new instance of <see cref="TXAC"/>
/// </summary>
public TXAC() { }

/// <summary>
/// Initializes a new instance of <see cref="TXAC"/>
/// </summary>
/// <param name="inData">ExtendedData.</param>
public TXAC(byte[] inData) => LoadBinaryData(inData);

/// <inheritdoc />
public string GetSignature() { return Signature; }

/// <inheritdoc />
public uint GetSize() { return (uint)Serialize().Length; }

/// <inheritdoc />
public void LoadBinaryData(byte[] inData)
{
using (var ms = new MemoryStream(inData))
using (var br = new BinaryReader(ms))
{
unk = br.ReadBytes((int)br.BaseStream.Length);
}
}

/// <inheritdoc />
public byte[] Serialize(long offset = 0)
{
using (var ms = new MemoryStream())
using (var bw = new BinaryWriter(ms))
{
bw.Write(unk);

return ms.ToArray();
}
}
}
}
Loading

0 comments on commit f9c08ef

Please sign in to comment.