3DXI Node

The IGameNode is a container which maintains a scene object, any controller associated with that object, or a material in the scene. The following code demonstrates how materials are accessed at the root level using IGameScene. One call to IGameScene::GetRootMaterialCount() obtains the number of materials in the scene, and an enumeration of the count provides a direct index into the material list using IGameScene::GetRootMaterial().

IGameScene* pIGame;

void IGameExporter::ExportMaterials()
{
    TSTR buf;
    if(exportMaterials)
    {
        int matCount = pIgame->GetRootMaterialCount();
        buf.printf("%d",matCount);
        for(int j =0;j<matCount;j++)
        {
            IGameMaterial * mat = pIgame->GetRootMaterial(j);
             if(mat)
                 DumpMaterial(matNode,mat,j);
        }
    }
}

Nodes are accessed in a similar manner. The code, in the following example, accesses and exports the parent (top-level) nodes. ExportNodeInfo() is not a part of the game interfaces.

IGameScene* pIGame

for(int loop = 0; loop < pIgame->GetTopLevelNodeCount();loop++)
{
    IGameNode * pGameNode = pIgame->GetTopLevelNode(loop);
    if(pGameNode->IsTarget())
        continue;
    ExportNodeInfo(pGameNode);
    pIgame->ReleaseIGameNode(&pGameNode); // free the memory
}

Because the IGameNode is simply the object container, GetIGameObject() must be called to access the actual object. Similarly, access to the node's material and controller is accomplished using GetNodeMaterial() and GetIGameControl() respectively. You then call IGameScene::ReleaseIGameObject(), which frees the memory associated with that object. Freeing the memory of the IGameObject does not affect the controller or material data.

Access to a 3ds Max INode can be achieved through the function IGameNode::GetMaxNode().