Drawing models
There are several steps we need to take when drawing 3D models. Start by downloading the start files and open the MainGame
class. Once this is done, we need to declare our View
and Projection
matrices. As these contain our camera settings, they will be the same for all 3D models. For each model, we'll need to add fields, load the model, and then draw it.
Adding fields
We'll create three fields: a field for the hero of type Model
, and fields for the View
and Projection
matrices of type Matrix
.
Model _hero; Matrix _view, _projection;
Initialize
In the Initialize
method, we will set the values for our View
and Projection
matrices.
We can create the
View
matrix by using the staticMatrix.CreateLookAt
method. It has three arguments. The first is the position of the camera, the second what it's looking at, and the third the up vector. We will place the camera 20 units along the positive z axis, pointed back at the origin.For the
Projection
matrix we will use an orthographic projection...