NSBMD Files (NITRO-System Binary Model) store a set of 3D models, and optionally also textures. It follows the [NNS G3D Binary File Format|G3D Binary File Format] with the signature {{{"BMD0"}}}. An NSBMD file must contain a {{{MDL0}}} block, and may contain a [TEX0|NSBTX] block. !!MDL0 Block The {{{MDL0}}} block stores a model set. The structure of the {{{MDL0}}} block begins with a model dictionary mapping model names to model resources. Each entry in this dictionary is a 32-bit offset to the model data relative to the start of the block. The model data structure pointed to by the model set dictionary is as follows: ||Offset||Type||Meaning | 0x00 | u32 | Size of model data | 0x04 | u32 | Offset to SBC dictionary relative to the start of this struct | 0x08 | u32 | Offset to material data relative to the start of this struct | 0x0C | u32 | Offset to shape dictionary relative to the start of this struct | 0x10 | u32 | Offset matrix dictionary relative to the start of this struct | 0x14 | u8 | SBC type | 0x15 | u8 | Scaling rule | 0x16 | u8 | Texture matrix mode | 0x17 | u8 | Number of nodes | 0x18 | u8 | Number of materials | 0x19 | u8 | Number of shapes | 0x1A | u8 | ID of first unused matrix | 0x1B | u8 | | 0x1C | fx32| Model scale | 0x20 | fx32| Inverse model scale | 0x24 | u16 | Number of vertices | 0x26 | u16 | Number of polygons | 0x28 | u16 | Number of triangles | 0x2A | u16 | Number of quads | 0x2C | fx16| Bounding box X (multiply by model scale to get real position) | 0x2E | fx16| Bounding box Y | 0x30 | fx16| Bounding box Z | 0x32 | fx16| Bounding box X Size (multiply by model scale to get real size) | 0x34 | fx16| Bounding box Y Size | 0x36 | fx16| Bounding box Z Size | 0x38 | fx32| Box scale | 0x3C | fx32| Inverse box scale | 0x40 | ... | Dictionary of node info | ... | ... | SBC dictionary | ... | ... | Material data | ... | ... | Shape dictionary | ... | ... | Matrix dictionary !Node Data !SBC Data SBC data defines the command lists that will be executed by the library to render the model. These are a higher-level command list than the hardware displaylists. The first byte of an SBC command is the opcode byte, where the low 5 bits are the command number, and high 3 bits are the flags. The SBC commands are documented here: ||Opcode||Mnemonic||Description | 0x00 | {{{NOP}}} | No-operation. Takes no arguments. | 0x01 | {{{RET}}} | Return: ends SBC list processing. | 0x02 | {{{NODE}}} | Sets the current node. First operand is 1-byte node index. Second operand is the node visibility setting (least significant bit indicates visibility). | 0x03 | {{{MTX}}} | Restores a matrix from a position on the matrix stack. The operand is a 1-byte index on the stack to restore from. Should be less than 31. | 0x04 | {{{MAT}}} | Sets the current active material. The operand is a 1-byte material index. | 0x05 | {{{SHP}}} | Runs a displaylist specified by a shape resource. The operand is a 1-byte shape index. | 0x06 | {{{NODEDESC}}} | Specifies node details. | 0x07 | {{{BB}}} | | 0x08 | {{{BBY}}} | | 0x09 | {{{NODEMIX}}} | | 0x0A | {{{CALL}}} | | 0x0B | {{{POSSCALE}}} | | 0x0C | {{{ENVMAP}}} | | 0x0D | {{{PRJMAP}}} | !Material Data The material data defines the set of materials and their various properties. Its structure looks like the following: ||Offset||Type||Meaning | 0x00 | u16 | Offset to the Texture->Material dictionary relative to this struct | 0x02 | u16 | Offset to the Palette->Material dictionary relative to this struct | 0x04 | ... | Material data dictionary The material data dictionary contains a map of material names to offsets to material data. The material data structure looks like the following: ||Offset||Type||Meaning | 0x00 | u16 | Tag (should be 0) | 0x02 | u16 | Material data size | 0x04 | u32 | Diffuse and ambient color | 0x08 | u32 | Specular and emissive color | 0x0C | u32 | Polygon attributes (for {{{POLYATTR}}} command) | 0x10 | u32 | Polygon attributes mask (bits used by the material are 1) | 0x14 | u32 | Teximage_Param | 0x18 | u32 | Teximage_Param mask (bits used by the material are 1) | 0x1C | u16 | Texpltt_Base | 0x1E | u16 | Flags | 0x20 | u16 | Texture original width (set at runtime) | 0x22 | u16 | Texture original height (set at runtime) | 0x24 | fx32| Width of texture (set at runtime) | 0x28 | fx32| Height of texture (set at runtime) | ... | fx32| S Scale (if flags bit 1 clear) | ... | fx32| T Scale (if flags bit 1 clear) | ... | fx16| Sine of texture rotation (if flags bit 2 clear) | ... | fx16| Cosine of texture rotation (if flags bit 2 clear) | ... | fx32| Texture S translation (if flags bit 3 clear) | ... | fx32| Texture T translation (if flags bit 3 clear) | ... | fx32[[16]| Effect matrix (if flags bit 13 set) !Shape Data The shape data defines the set of shapes, or displaylists, that make up the model. The shape dictionary stores named offsets to the shape data relative to the start of the dictionary. The data this dictionary points to is outlined below: ||Offset||Type||Meaning | 0x00 | u16 | Item tag (should be 0). | 0x02 | u16 | Size of shape data (should be {{{0x10}}}) | 0x04 | u32 | Shape flags. \\ Bit 0 will be set if the Normal command exists in the displaylist \\ Bit 1 will be set if the Color command exists in the displaylist \\ Bit 2 will be set if the Texcoord command exists in the displaylist \\ Bit 3 will be set if the MtxRestore command exists in the displaylist | 0x08 | u32 | Offset to displaylist data relative to this structure | 0x0C | u32 | Size of displaylist in bytes !Matrix Data