Game Development Reference
In-Depth Information
ModelView transformation
Each model or object we want to draw on the scene has coordinates defined with
respect to its own origin and axis; we call it object space . When an object is added
to the scene and if its own origin coincides with the scene's origin, then its vertices
need not be transformed for rendering; but if we want to move the object or rotate it,
then we will have to transform its vertices to screen/world coordinates. ModelView
transformation is used to transform an object's vertices to world coordinates. An
example of this is shown in the following diagram:
Z
V 4
Z(object)
V 0
V1
V5
X
V7
X(object)
V3
V2
V6
X(world)
Object space
Object in world space
Also, if we move our camera/view around the object, or rotate our camera, then we
would need to transform its vertices, changing the world's origin to the camera's
position as the origin.
In a nutshell, first model vertices have to be transformed with respect to the scene's
origin and then transformed by switching the world's origin to the camera/view
position. The final set of all these transformations is maintained as a single 4 x 4
matrix, called the ModelView transformation matrix. The new positions of the
model's vertices are obtained via the cross product of each coordinate/vertex of the
model with the ModelView transformation matrix, Vf = Mv * V . Here, Vf is the final
vector, Mv is the [4 x 4] ModelView matrix, and V is the vector corresponding to
each vertex. Each coordinate of a vertex is denoted as [ x , y , z , w ], where you can put
w as 1 for all purposes of this chapter.
 
Search WWH ::




Custom Search