CHAPTER 16
To begin a new Direct3D app, click File > New Project in the main menu of Visual Studio. You will be presented with the New Project screen. Click Visual C++ on the left panel, and then click Direct3D App on the middle panel. Give your new project a name. Mine is called Direct3DTesting, as shown in Figure 41.

Once Visual Studio has created the project you can click Start Debugging and you should see a spinning colored cube (as depicted in the preview pane of Figure 41).
3-D Coordinates
We will describe points in our 3-D examples using a standard Cartesian x, y, and z system. Each of the x, y, and z values refers to a point in 3-D space. Each axis can be thought of as an infinite plane perpendicular to the other two axes. They are often summarized as three lines, as shown in Figure 42.

3-D Axes
We will use the x value of a coordinate to represent how far left or right a point is, the y value to represent how high or low the coordinate is, and the z value to represent how far into or out of the screen the coordinate is. In addition, as an object's x value increases, the object moves rightward. As the object's y value increases, it moves upward. As the object's z value increases, the object moves closer to the camera (or out of the screen).
Vertices
A vertex is a point in 3-D space used to represent the corner of an object, shape, or the end of a line. To specify a 3-D vertex, we need to supply the three coordinates mentioned previously. The coordinates are almost always 32-bit floating point values. Each element (x, y, or z) specifies a position along the dimension, and collectively they describe an exact and unique point in 3-D space.
Note: I will be using x, y, then z as the order for my elements when describing vertices. So something like (9.0f, 8.0f, 5.0f) means 9 along the x-axis, 8 along the y-axis and 5 along the z-axis.
In Figure 43 the yellow ball represents a vertex. In reality, the vertex does not have a physical form; it represents an infinitely small point. The vertex is at position (1.2f, 0.4f, 0.7f). This means it is 1.2 units right of the blue x-axis origin, 0.4 units above the origin of the green y-axis, and 0.7 units away from the origin of the red z-axis.

A Point
In Direct3D, vertices are far more flexible than simple points in space. A vertex can carry lighting and coloring information about a point, as well as any other information required. In their most basic form (and the way we will be using them, they consist of a position and color, each described with three or four floating point values.
Lines
A 3-D line can be formed from any two vertices. They are exactly the same as lines in 2-D space, only the points which define the ends each have 3 dimensions. Lines are important in DirectX, because three of them makes a triangle (and as we shall see, 3-D graphics is almost nothing but rendering massive numbers of triangles). Lines also allow us to render 3-D objects as wire frames, so we can easily see the triangles from which the objects are made.
Triangle
Instead of describing 3-D objects with billions of points, objects are usually summarized and are described as a collection of small triangles. The triangles collectively form a mesh, which is a net-like structure. Each triangle is made up of three vertices and three lines. Any three distinct vertices can be used to form a triangle, and if there are enough triangles almost any imaginable shape can be approximated. Modern graphics cards are staggeringly efficient at rendering triangles.
Matrices
Everything from scaling, placement, and the rotation of objects is controlled by matrices in Direct3D. Displaying 3-D graphics consists of multiplying large data sets of vertices and triangles by transformation matrices. There are some matrices which are almost always used; they have a special purpose in 3-D graphics and they have come to be known as the world matrix, the view matrix, and the projection matrix.