Drawing a model

Now that the model has been loaded, we are ready to draw it. We do this in the Draw() function of our game. Games redraw dozens of times per second, and each redraw is called a frame. We need to clear the screen before drawing a new frame, and we do so using XNA's GraphicsDevice.Clear() function. The single argument allows us to change the color to which the screen is cleared:

GraphicsDevice.Clear(Color.CornflowerBlue);

The first step of drawing the model itself is to calculate the view and projection matrices. To calculate the view matrix, we will use the CreateLookAt() static function of the Matrix class, which accepts as arguments a camera position, target, and up direction. The position is simply where in 3D space the camera ...

Get 3D Graphics with XNA Game Studio 4.0 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.