Files

46 lines
1.3 KiB
C#
Raw Permalink Normal View History

2026-05-17 15:40:16 +03:00
using Common;
2026-05-17 02:31:11 +03:00
using NResLib;
2026-05-17 15:40:16 +03:00
namespace MshLib;
2026-05-17 02:31:11 +03:00
public static class Msh0x08
{
2026-06-12 02:06:32 +03:00
public static List<MshTransformKeyframe> ReadComponent(FileStream mshFs, NResArchive archive)
2026-05-17 02:31:11 +03:00
{
var entry = archive.Files.FirstOrDefault(x => x.FileType == "08 00 00 00");
if (entry is null)
{
throw new Exception("Archive doesn't contain animation descriptor component (0x08)");
}
mshFs.Seek(entry.OffsetInFile, SeekOrigin.Begin);
2026-06-12 02:06:32 +03:00
var descriptors = new List<MshTransformKeyframe>();
2026-05-17 02:31:11 +03:00
for (var i = 0; i < entry.ElementCount; i++)
{
2026-06-12 02:06:32 +03:00
descriptors.Add(new MshTransformKeyframe(
2026-05-17 02:31:11 +03:00
new Vector3(mshFs.ReadFloatLittleEndian(),
mshFs.ReadFloatLittleEndian(),
mshFs.ReadFloatLittleEndian()),
mshFs.ReadFloatLittleEndian(),
new UShortQuaternion(
2026-06-06 00:42:07 +03:00
mshFs.ReadInt16LittleEndian(),
mshFs.ReadInt16LittleEndian(),
mshFs.ReadInt16LittleEndian(),
mshFs.ReadInt16LittleEndian()
2026-05-17 02:31:11 +03:00
)
));
}
return descriptors;
}
}
2026-06-12 02:06:32 +03:00
public record MshTransformKeyframe(
Vector3 Position,
float Time,
UShortQuaternion Rotation
);