Platform SDK: DirectX

Step 1.1: Prepare the Wall Segments

[C++]

This section pertains only to application development in Visual Basic. See Direct3D Immediate Mode C/C++ Tutorials.

[Visual Basic]

The Using Alternate Primitive Styles tutorial describes the wall segments in your scene with D3DVERTEX types, which are untransformed and unlit vertices. When you use untransformed and unlit vertices, you effectively request that Direct3D use its own internal algorithms to perform transformation and lighting operations.

You can define each wall segment in 3-D space by calculating and saving the information for a pair of vertices, as demonstrated in the following code from the DrawPrims application:

Private Sub InitGeometry()
 
    ' Set up the wall geometry.
    Dim x As Double, _
        y As Double, _
        z As Double
        
    Dim i As Integer
    
    For i = 0 To NUM_WALL_SIDES - 1
        x = Sin(2 * pi * i / (NUM_WALL_SIDES - 1))
        z = Cos(2 * pi * i / (NUM_WALL_SIDES - 1))
        
        Call g_dx.CreateD3DVertex(x * 10#, -0.1 * 10#, z * 10#, -x, 0, -z, 0, 0, g_vWall(2 * i + 0))
        Call g_dx.CreateD3DVertex(x * 10#, 0.1 * 10#, z * 10#, -x, 0, -z, 0, 0, g_vWall(2 * i + 1))
        
    Next i

In the preceding code, the DirectX7.CreateD3DVertex method is used to fill an array of D3DVERTEX types, g_vWall, with vertex component data. The code locates the x- and z- coordinates of the vertex by using trigonometric functions. The CreateD3DVertex method requires that you specify your coordinates in model coordinates. Since we have used untransformed and unlit vertices, the system will apply world, view, and projection transformations to the model coordinates to properly position them within your scene. Also, the x-, y-, and z-coordinates of the vertex are scaled by a value of ten to properly size the wall segments.

After defining the geometry for the wall segments in the scene, you can move on to preparing another geometric primitive for your scene, a cone. Again, note that the order in which specific objects are defined is not critical.

Defining a cone in 3-D space is demonstrated in Step 1.2: Prepare the Cone.