# NNSG3dRenderObj

## Syntax

    #include <nnsys/g3d/kernel.h>

    typedef struct NNSG3dRenderObj_
    {
        u32 flag; // NNSG3dRenderObjFlag

        NNSG3dResMdl*         resMdl;
        NNSG3dAnmObj*         anmMat;
        NNSG3dFuncAnmBlendMat funcBlendMat;
        NNSG3dAnmObj*         anmJnt;
        NNSG3dFuncAnmBlendJnt funcBlendJnt;
        NNSG3dAnmObj*         anmVis;
        NNSG3dFuncAnmBlendVis funcBlendVis;

        // Callback information
        NNSG3dSbcCallBackFunc cbFunc;              // No callback if NULL.
        u8                    cbCmd;               // Specify the stop position with a command. NNS_G3D_SBC_***** (Define in res_struct.h).
        u8                    cbTiming;            // NNSG3dSbcCallBackTiming (Define in sbc.h).
        u16                   dummy_;

        // Called immediately before the rendering begins. Generally used to set
        // the callback vectors for NNS_G3dRS.
        NNSG3dSbcCallBackFunc cbInitFunc;

        // Pointer to the region managed by the user.
        // If the pointer is set in advance, it can be used in the callback.
        void*                 ptrUser;

        u8*                   ptrUserSbc;

        struct NNSG3dJntAnmResult_*   recJntAnm;
        struct NNSG3dMatAnmResult_*   recMatAnm;

        u32 hintMatAnmExist[NNS_G3D_SIZE_MAT_MAX / 32];
        u32 hintJntAnmExist[NNS_G3D_SIZE_JNT_MAX / 32];
        u32 hintVisAnmExist[NNS_G3D_SIZE_JNT_MAX / 32];
    }
    NNSG3dRenderObj;

## Description

The `NNSG3dRenderObj` structure collects and stores the data needed to render a model. The structure stores the following data:

- Pointer to the model resource (`NNSG3dResMdl`)
- Pointer to the animation object (`NNSG3dAnmObj`)
- Pointer to the animation blend function
- Callback settings
- Pointer to the initialize function
- Pointer to the buffer that stores the animation calculations (`NNSG3dJntAnmResult`, `NNSG3dMatAnmResult`)
- Flag group for optimizing and customizing operations

The following processes must be conducted in order to use the `NNSG3dRenderObj` structure:

1. Allocate a region for the structure using the `NNS_G3dAllocRenderObj` function (can also allocate to the stack without using this function)
2. Initialize the structure with the `NNS_G3dRenderObjInit` function
3. For animation, add the animation object using the `NNS_G3dRenderObjAddAnmObj` function
4. If a callback process is needed, register the callback function using either the `NNS_G3dRenderObjSetCallBack` or `NNS_G3dRenderObjSetInitFunc` function
5. If the joint and material calculation results are to be reused, register a buffer in the `NNSG3dRenderObj` structure using the `NNS_G3dRenderObjSetJntAnmBuffer` or `NNS_G3dRenderObjSetMatAnmBuffer` function
6. Render using the `NNS_G3dDraw` function
7. Once the allocated region is no longer necessary, release it using the `NNS_G3dFreeRenderObj` function

You do not need to prepare the `NNSG3dRenderObj` structure if you are rendering with the `NNS_G3dDraw1Mat1Shp` function.

## See Also

Kernel

## Revision History

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

CONFIDENTIAL