Game Development Reference
In-Depth Information
in the method name is, of course, short for field of view. The LH part indicates that
this is the method to use if you are working in a left-handed coordinate system. We
are using a left-handed coordinate system in this demo because video games gen-
erally use the left-handed coordinate system. There is, of course, another version
of this method that ends in RH for use in right-handed coordinate systems. For a
more in-depth look at these two types of coordinate systems, take a look at this art-
icle on Microsoft's MSDN website http://msdn.microsoft.com/en-us/library/windows/
desktop/bb324490(v=vs.85).aspx .
Clipping is the removing of objects from the render list that don't need to be drawn
in the current frame—generally because they are not visible anyway. This provides
performance benefits and is necessary since trying to render everything in your 3D
world is not practical unless it happens to be a very small world. Trying to do so may
result in very low frame rates.
The near clipping plane is the minimum distance an object must be from the camera
to be rendered. If an object is closer to the camera than this, it will not be rendered.
This can prevent objects from being partially rendered if the player gets too close to
them. Likewise, the far clipping plane is the maximum distance an object can be from
the camera and still be drawn. An object farther away than this will not be drawn.
Note that Direct3D takes care of basic clipping for us.
The next bit of code creates the view matrix using the Matrix.LookAtLH() meth-
od.Thethreeparameterswepassinareall Vector3 objects. Thefirstoneisthepo-
sition of the camera (in other words, the player's viewpoint) in 3D space. The second
parameter is the coordinates for the camera to look at. And the last parameter is
simply a vector that specifies which way is up in our 3D world. We are using the pos-
itive y axis as the vertical axis here, which is what you'll use most of the time.
Under this code, we have new vertex data, but it is far too big to show here, so check
out the downloadable code to see it. It specifies a position, color, and texture co-
ordinates for each vertex, which is a big departure from our previous demo that only
had a position for each vertex. This means that the input elements array will be very
different this time too. Again, check out the downloadable code to see this.
Lastly, we need to add this code to the bottom of this method:
Search WWH ::




Custom Search