Game Development Reference
In-Depth Information
Loading and rendering an exported 3D
animation
We're now in a position to start rendering a 3D animation, and as with rendering a
static 3D model it's also surprisingly easy to do.
Adding the IwAnim API to a project
Before we can use Marmalade's animation functionality, we first need to add the
IwAnim API to our project. This API builds on top of the IwGraphics API required
for rendering static 3D models.
As with all such Marmalade APIs, we add support for IwAnim to a project by listing
iwanim in the subprojects section of the MKB file. We must then call IwAnimInit
after IwGraphicsInit has been called, and at shutdown time we need to call
IwAnimTerminate .
Loading and accessing a 3D animation
The GROUP file format comes to our rescue once again in order to get animation
data loaded into memory. The export process will have created a GROUP file for us
already that will include the GEO, MTL, SKEL, and SKIN files, so we just need to
add entries for the ANIM files that we want to use.
With everything referenced in the GROUP file, we just need to load it into memory
using the resource manager, and then access the resources in the same way as we do
for any other resource.
The following code snippet illustrates how we might load a GROUP file and then
access the resources needed for rendering an animated 3D model:
CIwResGroup* lpFlagGroup = IwGetResManager()->
LoadGroup("Flag/Flag.group");
CIwModel* lpFlag = static_cast<CIwModel*>(lpFlagGroup->
GetResNamed("Flag", "CIwModel"));
CIwAnimSkel* lpSkel = static_cast<CIwAnimSkel*>(lpFlagGroup->
GetResNamed("FlagPoleBase", "CIwAnimSkel"));
CIwAnimSkin* lpSkin = static_cast<CIwAnimSkin*>(lpFlagGroup->
GetResNamed("Flag", "CIwAnimSkin"));
CIwAnim* lpFlagWobble = static_cast<CIwAnim*>(lpFlagGroup->
GetResNamed("FlagWobble", "CIwAnim"));
Right, now that we have the resources in memory, we need to do something
with them.
 
Search WWH ::




Custom Search