Game Development Reference
In-Depth Information
Specifying a model's vertex stream
Every 3D model has a pivot point , also called its origin , which is the point around
which the model will rotate and scale. In a 3D modeling package this point can be
positioned wherever you want it to be, but to make the mathematics easier in a game
we would normally treat the point (0, 0, 0) as the pivot point.
Each triangle in the model is defined by three vertices, and each vertex consists of
an x, y, and z component which declares the position of the vertex in what is called
model space (sometimes also referred to as object space ). This just means that the
components of each vertex are relative to the model's pivot point.
The following diagram shows an example of a cube. The pivot point is positioned at
the very centre of the cube and is hence the origin of model space. The corner points
use both positive and negative values, but each component has an absolute value of
100 , which yields a cube with edges of length 200 units. For clarity, the three front
faces of the cube also show how they have been built from two triangles.
In order to provide Marmalade with the vertices of the cube, we simply use
Marmalade's three-component floating pointer vector class CIwFVec3 to provide an
array of vertices. As with the 2D rendering, we've already seen this is called a vertex
stream, except that this time the stream consists of three component vectors.
 
Search WWH ::




Custom Search