scurest / apicula

Convert Nintendo DS .nsbmd models
BSD Zero Clause License
157 stars 18 forks source link

"NSMB" "World 1 Map" - not all textures exported #3

Closed mariomadproductions closed 5 years ago

mariomadproductions commented 7 years ago

w1.nsbmd Textures aren't fully exported when converting to COLLADA. These ones are missing: w4_brock4.2 w4_brock4.3 w4_brock4.4

scurest commented 7 years ago

This is because, AFAICT, they aren't used in the model file. Actually, they don't have to used, but the model file needs to declare a material for them before we create an image file for that material.

In addition to producing only the necessary files, this strategy also sidesteps a conceptual problem. To get an image file, you generally need a texture, and a palette to tell you what the colors in the texture are. The texture<->palette relationship is many-to-many and there's not a sure-fire way to know which of these pairs are meaningful besides knowing that that pair is actually used somewhere in the model.

Do you need an image for these? I could rig a new subcommand to dump a specific texture/palette pair to an image file.

(As an immediate work around, you can open w1.nsbmd in a hex editor and change the 1 in the first two occurrences of w4_brock4.1 to 2, 3, or 4 and then run it through apicula to get the corresponding image.)

mariomadproductions commented 7 years ago

I see. I think they are used by the nsbtp though. It's okay, I can export the textures manually with Every File Explorer.

scurest commented 7 years ago

Do you know anything about NSBTP files? I've come across a few but I don't know what they're for.

mariomadproductions commented 7 years ago

They contain animations to swap textures displayed on the model. I think MKDS Course Modifier and Console Tool have some support for them, but I can't find any format docs.

BTW, I've changed my mind - exporting all textures would be a useful feature.

scurest commented 7 years ago

I added an experimental flag --more-textures that will try to extract more of the textures. For textures that are unused:

  1. if the texture is a direct-color texture (contains actual RGBA values), it will always get extracted
  2. if the texture requires a palette, a palette will be guessed based on the name (it tries both the name of the texture and the name of the texture plus _pl, both of which are common IME). If one of these is found, it will be extracted using that.

Call it like

apicula convert w1.nsbmd --more-textures -ow1

This works for w1.nsbmd but I don't know well it works in general.

scurest commented 5 years ago

@mariomadproductions

Heh, this issue is pretty old :)

I've added support for NSBTP files in the extractor and the viewer. If you give them in the converter they won't go into COLLADA (which, as far as I know, doesn't support that kind of animation?), but they will be used for discovering textures/palette pairs! I've tested this and it works for some models in Rune Factory that weren't named in the way that --more-textures expects.

So if you give w1.nsbmd together with the NSBTPs it goes with, the missing textures should be exported now.

And since there are now two new ways to get the textures out, --more-textures and discovery via NSBTP, I'm going to go ahead and close this issue.