Game Development Reference
In-Depth Information
Yet again the exporter will include a comment referencing the source modeling
package file before beginning to define an instance of CIwModel , which is the class
used by Marmalade to represent a complete collection of 3D model data.
The CIwModel instance is first given a name. This name actually comes from the
name given to the model in the modeling package and is the name used to access
the model in our code, so it is important for the artist to name things sensibly.
A CMesh instance is declared next, which is a class that groups together all the
various bits of model data. This class, and all the other classes we are about to see
that are contained within it, are only ever used internally to the model builder. Once
the model has been processed these classes will no longer exist in memory, so we
can't use them in our code to access the raw model data.
The scale value used to export the vertex data is listed first in the CMesh instance,
and this is followed by classes which declare the various types of model data. In the
cube example we can see CVerts , CVertNorms , and CVertCols , which are little more
than big lists of vertex, normal, and color data respectively. A similar class called
CUVs also exists to provide texture information.
Next we see a class called CSurface . This class provides polygon information for the
model, and an instance will exist for every material used in the model. The material
used is specified first, and then comes the polygon information. A CQuads instance
is used to provide a list of all the quadrilateral polygons using the material, and a
CTris instance lists the triangular polygons.
A polygon is defined by supplying a collection of data for each vertex in the polygon.
The polygon is supplied as a group of five numbers enclosed in curly braces. These
numbers are indices into the blocks of data specified earlier in the file and occur in
the following order:
{Vertex index, Normal index, UV 0 index, UV 1 index, Color index}
There are two UV values as it is possible for a material to specify two textures that
will be blended together at render time, and each of these textures can have its own
UV stream.
Once all this data has been loaded, the model builder class will analyze it and create
a version of the data that is far more optimal for real-time rendering purposes.
 
Search WWH ::




Custom Search