This week's reading assignment is Chapter 4 from the textbook: "Creating 3D Objects". While there are less assigned pages for reading from the book this week (about 30), I will be providing a lot more supplemental material. Although the textbook does a great job giving an overview of the topics, and I generally like the order the information is presented in, it still only does a cursory job covering a lot of the necessary information.

When talking about "3D Graphics API's" we need to focus on all three elements at once. That is, we need to focus on the 3D Math, the Graphics Hardware, and the Programming API which exposes the other two elements.

**3D Mathematics**

The textbook fails in effectively covering 3D Mathematics. As with many authors of the genre, Carter chooses to emphasize the fact that the XNA Framework Library already provides classes for Vectors, Matrices, etc... and trusts the reader to either already know the fundamental mathematics or to go and learn more on their own time. As with nearly all books on Graphics API's, in this book we "do not discuss 3D math ... because there are many texts available that cover it." This is unfortunate but understandable. What Carter really means is, 3D mathematics is a difficult, time consuming topic to write about as it requires lots of visual aids (which authors generally have to make themselves) and could fill the page count of the entire book if done well.

With all that said, this is a workshop, not a textbook and understanding 3D mathematics is a pre-requisite to working effectively in 3D. When talking about "3D Mathematics" we're talking about the math required to manipulate, view, and render 3D primitives. This involves Vectors, Matrices, and potentially quaternions if you're looking for more advanced ways of storing rotations.

Ultimately, we'll use these mathematical concepts to represent an object's position in the world, it's position relative to our virtual camera, and what it looks like when projected from 3D space onto a 2D surface. While, I, like Chad do not have the time to write a textbook on 3D mathematics, there are a number of great tutorials on the web and we should take this week to provide and discuss those resources. Any and all questions on 3D mathematics is welcome. I challenge you to discover the best 3D tutorials on the web and provide links to them this week.

**The Graphics Hardware**

One of the reasons I chose Chad Carter's book as the textbook for this course is that it covers 3D primitives before covering 2D sprites. This may seem counter-intuitive but in reality it makes a lot of sense. While the mathematics involved in 3D rendering is more complex than 2D, most 2D API's we use today leverage the fact that our GPU's are built for 3D rendering. Gone are the days when we could simply copy byte arrays to video memory and expect them to show up on screen. Today, video cards (and drivers) have something called a 3D Graphics Pipeline, which is a series of stages data you wish to be drawn must go through before being shown on your screen.

When using the SpriteBatch class in XNA, you're really just creating a ton of pre-transformed triangles which are then being rendered as quads by the GPU hardware, using your "sprite" as the texture for the triangles. With that in mind, understanding the Graphics Pipeline makes you not only a capable 3D graphics programmer, but also a more efficient 2D programmer.

The other useful observation here is that all 2D "sprites" go through the same stages as your 3D triangles. This means that any and all effects we learn to do in 3D can also be used in 2D.

**The Graphics API**

XNA represents physical hardware components and data with a fairly complete set of classes, structs, and interfaces. These range from simple Color structs, to VertexBuffers which represent a collection of 3D points, all the way to the fairly complex GraphicsDevice class. The textbook takes a cursory look at the most important of these types, which are all related to 3D primitives. We'll take a closer look at some additional ones in the supplemental material, with the rest of them coming in Weeks 4, 6, 7, and 13.

**Supplemental Reading**Below is a list of supplemental reading that might help this week's reading make more sense to you. I am likely to add to this list over the course of the week (or even the workshop) and will make an announcement when I've added additional reading or resources.

- Essential Math for Game Programmers - Great tutorial website on 3D math. Start with the Core Mathematics section.
- Direct3D 9.0 Graphics Pipeline Diagram - This is the most comprehensive diagram I've seen for the DirectX 9.0 Graphics Pipeline. As XNA is largely a managed wrapper around DirectX 9.0 this is almost all relevant. Note: This is not entirely accurate for Xbox 360, but should be 99% accurate for PC
- Microsoft.Xna.Frame.Graphics Namespace - List of all the classes, structs, and interfaces in the Graphics Library. We'll talk about almost all of them over the course of the workshop.
- GameDevelopedia.com - My own blog. See tutorials 2-4 on the right hand side.

XNA 4.0 Source Code

XNA 4.0 Source Code

DiscussionDiscussion

Please use the Week 2 XNA 4.0 Workshop Forums for any discussion of this week's reading.