Microsoft DirectX 8.1 (Visual Basic) |
A triangle list is a list of isolated triangles. They might or might not be near each other. A triangle list must have at least three vertices. The total number of vertices must be divisible by three.
Use triangle lists to create an object that is composed of disjoint pieces. For instance, one way to create a force-field wall in a 3-D game is to specify a large list of small, unconnected triangles. Then apply a material and texture that appears to emit light to the triangle list. Each triangle in the wall appears to glow. The scene behind the wall becomes partially visible through the gaps between the triangles, as a player might expect when looking at a force field.
Triangle lists are also useful for creating primitives that have sharp edges and are shaded with Gouraud shading. See Face and Vertex Normal Vectors.
The following illustration depicts a rendered triangle list.
The following code shows how to create vertices for this triangle list.
Private Type CUSTOMVERTEX x As Single y As Single z As Single End Type Dim Vertices(5) As CUSTOMVERTEX With Vertices(0): .x = -5.0: .y = -5.0: .z = 0.0: End With With Vertices(1): .x = 0.0: .y = 5.0: .z = 0.0: End With With Vertices(2): .x = 5.0: .y = -5.0: .z = 0.0: End With With Vertices(3): .x = 10.0: .y = 5.0: .z = 0.0: End With With Vertices(4): .x = 15.0: .y = -5.0: .z = 0.0: End With With Vertices(5): .x = 20.0: .y = 5.0: .z = 0.0: End With