3DXI Objects
 
 
 

An IGameObject is a scene entity with relevant properties. IGameObject defines the type of object, whether a camera, a lights etc. IGameNode is the container for IGameObjects. The developer must then cast the object to its correct interface, as shown in the following code from the IGameExporter sample (edited for clarity):

//child is an IGameNode pointer
IGameObject * obj = child->GetIGameObject();
switch(obj->GetIGameType())
{
    case  IGameObject::IGAME_MESH:
        if(exportGeom )
        {
            IGameMesh * gM = (IGameMesh*)obj;
             if(gM->InitializeData())
            {
                 DumpMesh(gM,geomData);
            }
             else
            {
                DebugPrint("BadObject\n")
            }
        }
        break;
    case  IGameObject::IGAME_SPLINE:
        if(exportSplines)
        {
            IGameSpline * sp = (IGameSpline*)obj;
             sp->InitializeData();
             DumpSpline(sp,splineData);
        } 
        break;
}
child->ReleaseIGameObject();

In the above example, we call IGameObject::GetIGameType() and cast the IGameObject to its associated interface. The following table is a list of IGameObject types and their associated interfaces:

IGame Object Type

IGame Interface

IGAME_UNKNOWN

IGameGenObject

IGAME_LIGHT

IGameLight

IGAME_MESH

IGameMesh

IGAME_SPLINE

IGameSpline

IGAME_CAMERA

IGameCamera

IGAME_HELPER

IGameHelperObject

IGAME_BONE

IGameHelperObject

IGAME_IKCHAIN

IGameIKChain

IGAME_XREF

IGameXRefObject

To preserve memory, IGameObject has an InitializeData() method which instructs the 3DXI system to start the actual object conversion. Objects such as editable meshes can consume much memory, so this conversion happens only at the request of the developer. For example: in the case that only the simple node transformation data is required, you do not need to call InitializeData().