From 089c1d4a09ae43883033730092957a5aeffb5b60 Mon Sep 17 00:00:00 2001 From: MeltyPlayer Date: Sat, 30 Nov 2024 16:49:42 -0600 Subject: [PATCH] Gathered Nitro model bundles and created an empty loader for them. --- .../Nitro/src/api/NsbmdModelFileBundle.cs | 11 ++++++++++ .../Nitro/Nitro/src/api/NsbmdModelImporter.cs | 20 +++++++++++++++++++ .../UniversalAssetTool.csproj | 1 + .../src/api/GlobalModelLoader.cs | 4 ++++ .../PhantomHourglassFileBundleGatherer.cs | 11 +++------- .../SuperMario64DsFileBundleGatherer.cs | 12 ++++++++++- 6 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelFileBundle.cs create mode 100644 FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelImporter.cs diff --git a/FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelFileBundle.cs b/FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelFileBundle.cs new file mode 100644 index 000000000..8a2e66c35 --- /dev/null +++ b/FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelFileBundle.cs @@ -0,0 +1,11 @@ +using fin.io; +using fin.model.io; + +namespace nitro.api; + +public class NsbmdModelFileBundle : IModelFileBundle { + public required IReadOnlyTreeFile NsbmdFile { get; init; } + + public required string? GameName { get; init; } + public IReadOnlyTreeFile MainFile => this.NsbmdFile; +} \ No newline at end of file diff --git a/FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelImporter.cs b/FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelImporter.cs new file mode 100644 index 000000000..5ef3cbab4 --- /dev/null +++ b/FinModelUtility/Formats/Nitro/Nitro/src/api/NsbmdModelImporter.cs @@ -0,0 +1,20 @@ +using fin.model; +using fin.model.impl; +using fin.model.io.importers; +using fin.util.sets; + +namespace nitro.api; + +public class NsbmdModelImporter : IModelImporter { + public IModel Import(NsbmdModelFileBundle fileBundle) { + var nsbmdFile = fileBundle.NsbmdFile; + + var files = nsbmdFile.AsFileSet(); + var model = new ModelImpl { + FileBundle = fileBundle, + Files = files, + }; + + return model; + } +} \ No newline at end of file diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/UniversalAssetTool.csproj b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/UniversalAssetTool.csproj index c0223e100..57035196b 100644 --- a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/UniversalAssetTool.csproj +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/UniversalAssetTool.csproj @@ -140,6 +140,7 @@ + diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/api/GlobalModelLoader.cs b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/api/GlobalModelLoader.cs index 336aacf72..8e45d1354 100644 --- a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/api/GlobalModelLoader.cs +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/api/GlobalModelLoader.cs @@ -18,6 +18,8 @@ using modl.api; +using nitro.api; + using pmdc.api; using ttyd.api; @@ -55,6 +57,8 @@ MeleeModelFileBundle meleeModelFileBundle => new MeleeModelImporter().Import(meleeModelFileBundle), ModModelFileBundle modModelFileBundle => new ModModelImporter().Import(modModelFileBundle), + NsbmdModelFileBundle nsbmdModelFileBundle + => new NsbmdModelImporter().Import(nsbmdModelFileBundle), OmdModelFileBundle omdModelFileBundle => new OmdModelImporter().Import(omdModelFileBundle), OotModelFileBundle ootModelFileBundle diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs index 2471bf16e..bfb6b45e4 100644 --- a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/phantom_hourglass/PhantomHourglassFileBundleGatherer.cs @@ -4,6 +4,7 @@ using SceneGate.Ekona.Containers.Rom; using uni.platforms; +using uni.platforms.ds; using Yarhl.FileSystem; @@ -20,13 +21,7 @@ public void GatherFileBundles( return; } - using var game = NodeFactory.FromFile(phantomHourglassRom.FullPath); - game.TransformWith(); - - var names = new List(); - - foreach (var node in Navigator.IterateNodes(game)) { - names.Add(node.Name); - } + var fileHierarchy + = new DsFileHierarchyExtractor().ExtractFromRom(phantomHourglassRom); } } \ No newline at end of file diff --git a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/super_mario_64_ds/SuperMario64DsFileBundleGatherer.cs b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/super_mario_64_ds/SuperMario64DsFileBundleGatherer.cs index 1cb248ff8..0ec9c2bf7 100644 --- a/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/super_mario_64_ds/SuperMario64DsFileBundleGatherer.cs +++ b/FinModelUtility/UniversalAssetTool/UniversalAssetTool/src/games/super_mario_64_ds/SuperMario64DsFileBundleGatherer.cs @@ -1,6 +1,8 @@ using fin.io.bundles; using fin.util.progress; +using nitro.api; + using uni.platforms; using uni.platforms.ds; @@ -16,6 +18,14 @@ public void GatherFileBundles( return; } - new DsFileHierarchyExtractor().ExtractFromRom(superMario64DsRom); + var fileHierarchy + = new DsFileHierarchyExtractor().ExtractFromRom(superMario64DsRom); + + foreach (var bmdFile in + fileHierarchy.Root.FilesWithExtensionRecursive(".bmd")) { + organizer.Add(new NsbmdModelFileBundle { + GameName = "super_mario_64_ds", NsbmdFile = bmdFile + }.Annotate(bmdFile)); + } } } \ No newline at end of file