Game Development Reference
In-Depth Information
Rendering an exported 3D model
It is time to render the model on the screen and this too is incredibly easy. All we
have to do is set our view and model matrices using IwGxSetViewMatrix and
IwGxSetModelMatrix , then execute the following:
lpCube->Render();
The variable lpCube is the pointer to the CIwModel instance that we retrieved from
the resource manager in the previous section.
In actual fact the Render method can take two optional parameters. The first
parameter is a bool value that tells Marmalade to check a bounding sphere for the
model against the clipping planes to see if it actually needs to be rendered. This
parameter defaults to true , so the check is done by default. The bounding sphere is
generated automatically for us by the model builder code.
The second parameter is a flags field. Aside from one flag that is supposed to
have something to do with a 2D screen rotation (I say "supposed" because I can't
say it did very much when I tried it), the other flags are only relevant when dealing
with animated 3D models that contain normal data, so we will not worry over these
for now.
Releasing 3D model data
Since our 3D model data has been loaded into memory using the resource group
system, we can make use of the same mechanism of destroying groups to release
model data from memory that we no longer need. As a recap, we just do the
following if we have a pointer to the CIwResGroup containing the 3D data:
IwGetResManager()->DestroyGroup(lpCubeGroup);
Alternatively we can release a group from memory by destroying it by name,
like this:
IwGetResManager()->DestroyGroup("Cube");
 
Search WWH ::




Custom Search