# NNSG3dGlb

## Structure Definition

    #include <nnsys/g3d/glbstate.h>

    typedef struct
    {
        u32     cmd0;             // G3_MtxMode -> G3_LoadMtx44 -> G3_MtxMode -> G3_LoadMtx43
        u32     mtxmode_proj;     // GX_MTXMODE_PROJECTION
        MtxFx44 projMtx;          // Projection matrix
        //
        u32     mtxmode_posvec;   // GX_MTXMODE_POSITION_VECTOR
        MtxFx43 cameraMtx;        // Camera matrix

        u32     cmd1;             // G3_LightVector * 4
        u32     lightVec[4];      // Light vector

        u32     cmd2;             // G3_MatColorDiffAmb -> G3_MatColorSpecEmi -> G3_PolygonAttr -> G3_ViewPort
        u32     prmMatColor0;
        u32     prmMatColor1;
        u32     prmPolygonAttr;
        u32     prmViewPort;

        u32     cmd3;             // G3_LightColor * 4
        u32     lightColor[4];    // Light color

        u32     cmd4;             // G3_MultMtx43 -> G3_Scale -> G3_TexImageParam
        MtxFx33 prmBaseRot;
        VecFx32 prmBaseTrans;
        VecFx32 prmBaseScale;
        u32     prmTexImageParam;

        u32 flag;   // NNSG3dGlbFlag
        MtxFx43 invCameraMtx;
        MtxFx43 srtCameraMtx;
        MtxFx43 invSrtCameraMtx;

        MtxFx43 invBaseMtx;

        MtxFx44 invProjMtx;
        MtxFx44 invCameraProjMtx;

        VecFx32 camPos;
        VecFx32 camUp;
        VecFx32 camTarget;
    }
    NNSG3dGlb;

## Description

The `NNSG3dGlb` structure manages the types of data used for multiple models and entire scenes, such as projection matrices, light color and direction, and camera position and direction. The structure stores data for the following.

- Projection matrix
- Camera matrix (camera's position, viewpoint, and upward vector)
- Light direction
- Light color
- Viewport
- Object's world transformation matrix (SRT)
- Default material color, polygon attributes
- Various cached matrices

The `NNSG3dGlb` structure's only instance is the `NNS_G3dGlb` global variable, which you can initialize before use by calling the `NNS_G3dGlbInit` function. To access the data members held in this structure, use the `NNS_G3dGlb*` functions.
To apply the `NNSG3dGlb` structure's data in the Geometry Engine before you render with the `NNS_G3dDraw` function, call the `NNS_G3dGlbFlushP`, `NNS_G3dGlbFlushVP`, or `NNS_G3dGlbFlushWVP` function. When the `NNS_G3dMdlUseGlbXXXXX` functions are used on model resources, the settings in this structure are used for such items as the default material color.
Note that G3D will sometimes use the data stored in the `NNSG3dGlb` structure when such information as the camera matrix is needed when rendering models such as those including billboards.

## See Also

Global State

## Revision History

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

CONFIDENTIAL