Skip to content

Commit

Permalink
GemTrackDir reading, BandFaceDeform, FileMerger, PitchArrowDir, Motio…
Browse files Browse the repository at this point in the history
…nBlur
  • Loading branch information
ihatecompvir committed Jan 9, 2025
1 parent 34d8e1c commit 8c81937
Show file tree
Hide file tree
Showing 27 changed files with 2,292 additions and 535 deletions.
8 changes: 4 additions & 4 deletions MiloLib/Assets/Band/BandCrowdMeterDir.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public BandCrowdMeterDir Read(EndianReader reader, bool standalone, DirectoryMet
else
{
// fields only read when dir is not proxied
if (!entry.isEntryInRootDir)
if (!entry.isProxy)
{
if (revision < 3)
{
Expand Down Expand Up @@ -137,7 +137,7 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p
return;
}

if (!entry.isEntryInRootDir)
if (!entry.isProxy)
{
if (revision < 3)
{
Expand All @@ -157,9 +157,9 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p
}
}

if (revision >= 1)
writer.WriteFloat(peakValue);
}
if (revision >= 1)
writer.WriteFloat(peakValue);

base.Write(writer, false, parent, entry);

Expand Down
2 changes: 1 addition & 1 deletion MiloLib/Assets/Band/BandCrowdMeterIcon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public BandCrowdMeterIcon Read(EndianReader reader, bool standalone, DirectoryMe

if (revision > 0)
{
throw new UnsupportedAssetRevisionException("BandCrowdMeterDir", revision);
throw new UnsupportedAssetRevisionException("CrowdMeterDir", revision);
}

base.Read(reader, false, parent, entry);
Expand Down
79 changes: 79 additions & 0 deletions MiloLib/Assets/Band/BandFaceDeform.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
using MiloLib.Classes;
using MiloLib.Utils;

namespace MiloLib.Assets.Band
{
[Name("BandFaceDeform"), Description("Band Face Deformation object for face creator, basically a compact MeshAnim with position deltas")]
public class BandFaceDeform : Object
{
public class DeltaArray
{
[Name("Size"), Description("Size in bytes this takes up")]
private uint size;
public List<byte> data = new();

public DeltaArray Read(EndianReader reader)
{
size = reader.ReadUInt32();
for (int i = 0; i < size; i++)
{
data.Add(reader.ReadByte());
}

return this;
}

public void Write(EndianWriter writer)
{
writer.WriteUInt32((uint)data.Count);
foreach (var b in data)
{
writer.WriteByte(b);
}
}
}
public ushort altRevision;
public ushort revision;

private uint frameCount;
[Name("Frames"), Description("number of vertices with non-zero deltas in this keyframe")]
public List<DeltaArray> frames = new();

public BandFaceDeform Read(EndianReader reader, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry entry)
{
uint combinedRevision = reader.ReadUInt32();
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)((combinedRevision >> 16) & 0xFFFF));

base.Read(reader, false, parent, entry);

frameCount = reader.ReadUInt32();
for (int i = 0; i < frameCount; i++)
{
frames.Add(new DeltaArray().Read(reader));
}

if (standalone)
if ((reader.Endianness == Endian.BigEndian ? 0xADDEADDE : 0xDEADDEAD) != reader.ReadUInt32()) throw new Exception("Got to end of standalone asset but didn't find the expected end bytes, read likely did not succeed");

return this;
}

public override void Write(EndianWriter writer, bool standalone, DirectoryMeta parent, DirectoryMeta.Entry? entry)
{
writer.WriteUInt32(BitConverter.IsLittleEndian ? (uint)((altRevision << 16) | revision) : (uint)((revision << 16) | altRevision));

base.Write(writer, false, parent, entry);

writer.WriteUInt32((uint)frames.Count);
foreach (var frame in frames)
{
frame.Write(writer);
}

if (standalone)
writer.WriteBlock(new byte[4] { 0xAD, 0xDE, 0xAD, 0xDE });
}

}
}
13 changes: 10 additions & 3 deletions MiloLib/Assets/Band/BandScoreboard.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using MiloLib.Assets.Rnd;
using MiloLib.Classes;
using MiloLib.Utils;
using System.Reflection.PortableExecutable;

namespace MiloLib.Assets.Band
{
Expand All @@ -10,7 +11,8 @@ public class BandScoreboard : RndDir
public ushort altRevision;
public ushort revision;

public Symbol sym = new(0, "");
[Name("Star Display"), Description("Star display proxy object.")]
public Symbol starDisplay = new(0, "");

public BandScoreboard(ushort revision, ushort altRevision = 0) : base(revision, altRevision)
{
Expand All @@ -25,9 +27,9 @@ public BandScoreboard Read(EndianReader reader, bool standalone, DirectoryMeta p
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)(combinedRevision >> 16 & 0xFFFF));
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)(combinedRevision >> 16 & 0xFFFF));

if (!entry.isEntryInRootDir)
if (!entry.isProxy)
{
sym = Symbol.Read(reader);
starDisplay = Symbol.Read(reader);
}

base.Read(reader, false, parent, entry);
Expand All @@ -42,6 +44,11 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p
{
writer.WriteUInt32(BitConverter.IsLittleEndian ? (uint)(altRevision << 16 | revision) : (uint)(revision << 16 | altRevision));

if (!entry.isProxy)
{
Symbol.Write(writer, starDisplay);
}

base.Write(writer, false, parent, entry);

if (standalone)
Expand Down
4 changes: 3 additions & 1 deletion MiloLib/Assets/Band/BandStarDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class BandStarDisplay : RndDir
public ushort altRevision;
public ushort revision;

[Name("Star Type"), Description("The type of star to display")]
public Symbol starType = new(0, "");

public BandStarDisplay(ushort revision, ushort altRevision = 0) : base(revision, altRevision)
Expand All @@ -25,7 +26,8 @@ public BandStarDisplay Read(EndianReader reader, bool standalone, DirectoryMeta
if (BitConverter.IsLittleEndian) (revision, altRevision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)(combinedRevision >> 16 & 0xFFFF));
else (altRevision, revision) = ((ushort)(combinedRevision & 0xFFFF), (ushort)(combinedRevision >> 16 & 0xFFFF));

if (entry.isEntryInRootDir)
// star type only read when dir is proxied
if (entry.isProxy)
starType = Symbol.Read(reader);

base.Read(reader, false, parent, entry);
Expand Down
4 changes: 2 additions & 2 deletions MiloLib/Assets/Char/Character.cs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ public Character Read(EndianReader reader, bool standalone, DirectoryMeta parent
base.Read(reader, false, parent, entry);

// these fields only present if dir is not proxied
if (revision < 4 || !entry.isEntryInRootDir)
if (revision < 4 || !entry.isProxy)
{
lodCount = reader.ReadUInt32();
for (int i = 0; i < lodCount; i++)
Expand Down Expand Up @@ -380,7 +380,7 @@ public override void Write(EndianWriter writer, bool standalone, DirectoryMeta p
base.Write(writer, false, parent, entry);


if (revision < 4 || !entry.isEntryInRootDir)
if (revision < 4 || !entry.isProxy)
{
writer.WriteUInt32((uint)lods.Count);
foreach (var lod in lods)
Expand Down
Loading

0 comments on commit 8c81937

Please sign in to comment.