# NNSG3dResMdl

## Syntax

    #include <nnsys/g3d/binres/res_struct.h>

    typedef struct NNSG3dResMdl_
    {
        u32                size;        // Model size
        u32                ofsSbc;      // Offset to SBC, with &NNSG3dResMdl as the starting point
        u32                ofsMat;      // Offset to NNSG3dResMat, with &NNSG3dResMdl as the starting point
        u32                ofsShp;      // Offset to NNSG3dResShp, with &NNSG3dResMdl as the starting point
        u32                ofsEvpMtx;   // Offset to NNSG3dEvpMtx, with &NNSG3dResMdl as the starting point
        NNSG3dResMdlInfo   info;        // Model information (fixed length)
        NNSG3dResNodeInfo  nodeInfo;    // Node information
        // SBC
        // Materials
        // Shapes
        // EvpMtxs
    }
    NNSG3dResMdl;

    typedef struct NNSG3dResMdlInfo_
    {
        u8         sbcType;
        u8         scalingRule;
        u8         texMtxMode;
        u8         numNode;

        u8         numMat;
        u8         numShp;
        u8         firstUnusedMtxStackID;
        u8         dummy_;

        fx32       posScale;
        fx32       invPosScale;

        u16        numVertex;
        u16        numPolygon;
        u16        numTriangle;
        u16        numQuad;

        fx16       boxX, boxY, boxZ;
        fx16       boxW, boxH, boxD;

        fx32       boxPosScale;
        fx32       boxInvPosScale;
    }
    NNSG3dResMdlInfo;

## Description

The `NNSG3dResMdl` structure serves as the root for all of the data structures that store data for a single model. Access to the model data is achieved through this structure. The `NNSG3dResMdl` structure exists as data inside the `.nsbmd` file. It is created when the `.imd` file is converted by `g3dcvtr`.
The following data can be accessed through the `NNSG3dResMdl` structure:

- Material
- Shape
- SBC string (the mode's structure serialized and encoded)
- Information on each node's stationary position
- Information on the CG tool being used, the number of polygons, and so on.

This structure and the material, shape, and other data obtained through this structure are not changed by the G3D library during rendering (except when changed from within a callback).

Members of the `NNSG3dResMdlInfo` Structure | Description
--- | ---
sbcType | Structure Byte Code type identifier (`NNSG3dSbcType`).
scalingRule | Scaling rule identifier (`NNSG3dScalingRule`).
texMtxMode | Texture matrix calculation method identifier (`NNSG3dTexMtxMode`).
numNode | Number of nodes in the model.
numMat | Number of materials in the model.
numShp | Number of shapes in the model.
firstUnusedMtxStackID | ID of the first matrix in the matrix stack not used in the rendering of this model.
posScale | Scale value by which the vertex position coordinates are multiplied.. The value passed to the geometry engine's scale command.
invPosScale | Inverse of `posScale`.
numVertex | The `vertex_size` attribute of the `<output_info>` element in the `.imd` file is used here as is.
numPolygon | The `polygon_size` attribute of the `<output_info>` element in the `.imd` file is used here as is.
numTriangle | The `triangle_size` attribute of the `<output_info>` element in the `.imd` file is used here as is.
numQuad | The `quad_size` attribute of the `<output_info>` element in the `.imd` file is used here as is.
boxX, boxY, boxZ | The `xyz` attributes of the `<box?test>` element in the `.imd` file are used here as they are.
boxW, boxH, boxD | The `whd` attributes of the `<box?test>` element in the `.imd` file are used here as they are.
boxPosScale | The scale value by which the box's coordinates are multiplied.
boxInvPosScale | Inverse of `boxPosScale`.

## See Also

Kernel, Model, Binary resource

## Revision History

2007/05/17 Added structure definition.
2004/10/13 Initial version.

CONFIDENTIAL