![]() We will now go ahead and see how we can create matrices in XNA. We've now looked at how matrices are used, and how they are used in the fundamental transformation process of our game. (It "projects" the points onto the screen.) This transformation essentially gets the vertices into screen coordinates, although the computer still has more work to do as it draws the model on the screen (like rasterization). ![]() It gives the computer the information it needs to determine where on the screen each of our vertices should appear. This matrix essentially tells us what type of camera we are using. The third and final step of the process is to apply the projection matrix. In a sense, this transformation tells us where the player is located in the world. That is, where the player's camera or eye is located at. This matrix will put our coordinates into view space, which is where the vertices are in relationship to the viewer. This next transformation is the view matrix. The next step is to take our world space coordinates and apply another transformation to them. The world matrix basically tells us where the model is located in the world. World space coordinates represent where the vertices (and the entire model) are in relationship to the whole world. ![]() This transforms our model space coordinates into world space. At this point, we apply the world matrix. The coordinates of our vertices represent where they are in relation to the rest of the model. We start off with our vertices in model space. The standard transformation path looks like the image below: There are three different matrices that correspond to these three transformations. When we go to draw a model on the screen, there are typically three different transformations that need to be done. Let’s now take a look at several matrices that are used throughout computer graphics. And the best part is that XNA is built in such a way that we don’t even have to really know how it is doing it. We will see that matrices can do all sorts of things. In our games, we can think of matrices as a type of transformation. A matrix can be used to transform the model's coordinates into coordinates in our game world. However, in our game, we want to draw the model in a particular spot in our world, not at the origin. When we create the model, all of the vertices are centered around the origin of the center of the model. For example, let's say we have a model that we've created in a 3D modeling program. For the purposes of our games, a matrix is just a mathematical toy that takes points in one coordinate space and transforms them into another coordinate space. What we really care about is how matrices can be used to make cool games. We don't need to look at the details too much, but if you want to know more about them, you can look up 'linear algebra' on Google or Wikipedia. They also have other operations that you can do with them, aside from these simple ones. They can be added, subtracted, and multiplied, like numbers. And, of course, the numbers in a matrix can have any value in them, not just 1's and 0's. ![]() This matrix has four rows and four columns, but a matrix can have any number of rows or columns. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |