diff --git a/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/010/Bmd.bt b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/010/Bmd.bt new file mode 100644 index 000000000..ee1ee03ba --- /dev/null +++ b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/010/Bmd.bt @@ -0,0 +1,60 @@ +//------------------------------------------------ +//--- 010 Editor v14.0 Binary Template +// +// File: +// Authors: +// Version: +// Purpose: +// Category: +// File Mask: +// ID Bytes: +// History: +//------------------------------------------------ + + +typedef struct { + uint scaleFactor; + + uint boneCount; + uint bonesOffset; + + uint displayListCount; + uint displayListsOffset; + + uint textureCount; + uint texturesOffset; + + uint texturePaletteCount; + uint texturePalettesOffset; + + uint materialCount; + uint materialsOffset; + + uint transformAndBoneMapOffset; + uint textureAndPaletteDataBlock; +} FileHeader; + +FileHeader fileHeader; + + +typedef struct { + uint unknown; + uint dataOffset; + + local ulong tmp = FTell(); + FSeek(dataOffset); + + uint transformCount; + uint transformsOffset; + + uint opcodesByteLength; + uint opcodesOffset; + + FSeek(transformsOffset); + byte transforms[transformCount]; + + FSeek(tmp); +} DisplayList; + +FSeek(fileHeader.displayListsOffset); +DisplayList displayLists[fileHeader.displayListCount] ; \ No newline at end of file diff --git a/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/api/Sm64dsModelImporter.cs b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/api/Sm64dsModelImporter.cs index 96901cd06..c56a9b297 100644 --- a/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/api/Sm64dsModelImporter.cs +++ b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/api/Sm64dsModelImporter.cs @@ -29,8 +29,8 @@ public IModel Import(Sm64dsModelFileBundle fileBundle) { }; using var bmdRawBr = bmdFile.OpenReadAsBinary(); - var bmdBr = new SchemaBinaryReader( - new Lz77Decompressor().Decompress(bmdRawBr)); + var bmdBr + = new SchemaBinaryReader(new Lz77Decompressor().Decompress(bmdRawBr)); var bmd = bmdBr.ReadNew(); // Set up bones @@ -78,6 +78,9 @@ var firstChild } } + // Set up mesh + { } + // Set up animations if (fileBundle.BcaFiles != null) { foreach (var bcaFile in fileBundle.BcaFiles) { diff --git a/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/Bmd.cs b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/Bmd.cs index d4d88bdc1..24e0cefcb 100644 --- a/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/Bmd.cs +++ b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/Bmd.cs @@ -33,6 +33,10 @@ public partial class Bmd : IBinaryConvertible { [RSequenceLengthSource(nameof(BoneCount))] public Bone[] Bones { get; set; } + [RAtPosition(nameof(DisplayListsOffset))] + [RSequenceLengthSource(nameof(DisplayListCount))] + public DisplayList[] DisplayLists { get; set; } + [RAtPosition(nameof(TexturesOffset))] [RSequenceLengthSource(nameof(TextureCount))] public Texture[] Textures { get; set; } diff --git a/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/DisplayList.cs b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/DisplayList.cs new file mode 100644 index 000000000..918cdec62 --- /dev/null +++ b/FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/schema/bmd/DisplayList.cs @@ -0,0 +1,30 @@ +using fin.schema; + +using schema.binary; +using schema.binary.attributes; + +namespace sm64ds.schema.bmd; + +[BinarySchema] +public partial class DisplayList : IBinaryConvertible { + [Unknown] + public uint Unknown { get; set; } + + public uint DataOffset { get; set; } + + [RAtPosition(nameof(DataOffset))] + public DisplayListData Data { get; } = new(); +} + +[BinarySchema] +public partial class DisplayListData : IBinaryConvertible { + public uint TransformCount { get; set; } + public uint TransformsOffset { get; set; } + + public uint OpcodesByteLength { get; set; } + public uint OpcodesOffset { get; set; } + + [RAtPosition(nameof(TransformsOffset))] + [RSequenceLengthSource(nameof(TransformCount))] + public byte[] TransformIds { get; set; } +} \ No newline at end of file