Skip to content

Commit

Permalink
Investigated reading meshes for SM64DS BMDs.
Browse files Browse the repository at this point in the history
  • Loading branch information
MeltyPlayer committed Dec 3, 2024
1 parent e720b60 commit 0e9100d
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
60 changes: 60 additions & 0 deletions FinModelUtility/Games/SuperMario64Ds/SuperMario64Ds/src/010/Bmd.bt
Original file line number Diff line number Diff line change
@@ -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] <optimize=false>;
Original file line number Diff line number Diff line change
Expand Up @@ -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<Bmd>();

// Set up bones
Expand Down Expand Up @@ -78,6 +78,9 @@ var firstChild
}
}

// Set up mesh
{ }

// Set up animations
if (fileBundle.BcaFiles != null) {
foreach (var bcaFile in fileBundle.BcaFiles) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
Original file line number Diff line number Diff line change
@@ -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; }
}

0 comments on commit 0e9100d

Please sign in to comment.