# NNSG3dAnmObj

## Syntax

    #include <nnsys/g3d/kernel.h>

    typedef struct NNSG3dAnmObj_
    {
        fx32                  frame;
        fx32                  ratio;
        void*                 resAnm;     // Pointer to the animation data block within the resource file
        void*                 funcAnm;    // Cast as function pointer to various animations. This comes with a default value, but can be changed
        struct NNSG3dAnmObj_* next;
        const NNSG3dResTex*   resTex;     // When texture block information is required (only for texture pattern animations)
        u8                    priority;
        u8                    numMapData;
        u16                   mapData[1]; // Becomes an array with number of elements equal to numMapData (NNSG3dAnmObjMapData)
    }
    NNSG3dAnmObj;

## Description

The `NNSG3dAnmObj` structure collects the data needed to fetch animation data from the animation resource. The `NNSG3dAnmObj` structure stores the following data. `mapData` is a variable-length array, so it is not correct to get its size with `sizeof(NNSG3dAnmObj)`.

`NNSG3dAnmObj` Structure Members | Description
--- | ---
frame | Animation frame count.
ratio | The animation blend ratio (used for motion blending).
resAnm | The pointer to a single animation resource.
funcAnm | The pointer to a function that computes animations
next | Specified with `NNS_G3dRenderObjBindAnmObj` or `NNS_G3dRenderObjReleaseAnmObj`.
resTex | Pointer to the texture resource. Used only for texture pattern animations.
priority | The order of priority for being registered to `NNSG3dRenderObj`.
numMapData | Length of the `mapData` array.
mapData | The table used to map the model resource material IDs/joint IDs to the animation resource index.

The `NNSG3dAnmObj` structure can be used for the playback of animation by registering it in the `NNSG3dRenderObj` structure with the `NNS_G3dRenderObjAddAnmObj` function. The following processes are necessary to use `NNSG3dAnmObj` for animation playback:

1. Secure a region for the structure using the `NNS_G3dAllocAnmObj` function. Note that the size of the structure will differ, depending on the number of material IDs and joint IDs for the model.
2. Initialize the `NNSG3dAnmObj` structure using the `NNS_G3dAnmObjInit` function.
3. Register animation object in `NNSG3dRenderObj` using the `NNS_G3dRenderObjAddAnmObj` function.
4. Use the `NNS_G3dAnmObjSetBlendRatio` function to set the blend ratio for the number of frames that will be played by the `NNS_G3dAnmObjSetFrame` function. (This is usually only done when multiple joint animations have been registered).
5. Render the animation-attached model using the `NNS_G3dDraw` function.
6. To stop animation playback, use the `NNS_G3dRenderObjRemoveAnmObj` function to remove the animation object from `NNSG3dRenderObj`.
7. If `NNSG3dAnmObj` is no longer being used, release the structure's region using the `NNS_G3dFreeAnmObj` function.

`NNSG3dAnmObj` cannot be used for animation playback if rendering is performed with the `NNS_G3dDraw1Mat1Shp` function.

## See Also

Kernel

## Revision History

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

CONFIDENTIAL