Game Development Reference
In-Depth Information
Once we have our two rotation matrices, we multiply them together to generate
the final model matrix using the PreMult method. The order in which matrices are
multiplied together is very important as the end rotation will vary depending on the
order used. Marmalade provides us with PreMult and PostMult methods to allow
us to determine whether the calling matrix is the first matrix or the second in the
multiplication.
When we have our model matrix ready, we just call IwGxSetModelMatrix to use it
for rendering.
Rendering the model
All the hard work is now done and we can finally submit our cube for rendering. The
following code will submit all our streams and our cube will be rendered. Hopefully
you'll see just how close it is to the code we used for rendering in 2D:
IwGxSetColClear(128, 190, 220, 255);
IwGxClear();
IwGxSetMaterial(lpMaterial);
IwGxSetVertStreamModelSpace(v, lVertexCount);
IwGxSetNormStream(n, lVertexCount);
IwGxSetColStream(c);
IwGxDrawPrims(IW_GX_TRI_STRIP, i, lIndexCount)
IwGxFlush();
IwGxSwapBuffers();
Using a 3D modeling package to create
model data
We've seen how to create the streams of data for a cube in code, and to be honest it's
not pretty! Even a simple shape such as a cube requires so much data that it becomes
very difficult for us to keep track of it all and almost impossible to create a more
complex 3D shape.
Luckily there is an easier way. We can use a 3D modeling package to create, color,
and texture a 3D model and export all the required data in a format that Marmalade
can then load and use.
 
Search WWH ::




Custom Search