Game Development Reference
In-Depth Information
When a model is loaded into memory, all its vertices are expressed in terms of
model space. We don't want to manually change that vertex data in memory, be-
cause it would result in poor performance and would prevent positioning multiple
instances of the model at several locations in the world.
What we want instead is a way to tell the graphics card where we want the par-
ticular model to be drawn. And it's not just location: some models may need to
be rotated differently, some may need to be scaled, and so on (as demonstrated
in Figure 4.2 ) . So the desired solution would be to pass the model data (in model
space) to the graphics card as well as the little bit of additional data needed place
the model in the world.
Figure 4.2 Object in model space (a), and several instances of the object posi-
tioned/oriented relative to world space (b).
It turns out that for that extra bit of data, we are going to use our trusty matrices.
But first, before we can use matrices we need a slightly different way to represent
the positions of the triangles, called homogenous coordinates.
Homogenous Coordinates
Asmentionedearlier,sometimes 3Dgameswillactually use4Dvectors.When4D
coordinates are used for a 3D space, they are known as homogenous coordinates ,
and the fourth component is known as the w-component .
In most instances, the w-component will be either 0 or 1. If w = 0, this means that
the homogenous coordinate represents a 3D vector. On the other hand, if w = 1,
this means that the coordinate represents a 3D point. However, what's confusing is
that in code you will typically see a class such as Vector4 used both for vectors
Search WWH ::




Custom Search