Triangle Strips (Windows Embedded CE 6.0)
1/6/2010
A triangle strip is a series of connected triangles. Because the triangles are connected, the application does not need to repeatedly specify all three vertices for each triangle. For example, you need only seven vertices to define the following triangle strip.
The system uses vertices v1, v2, and v3 to draw the first triangle, v2, v4, and v3 to draw the second triangle, v3, v4, and v5 to draw the third, v4, v6, and v5 to draw the fourth, and so on. Notice that the vertices of the second and fourth triangles are out of order; this is required to make sure that all the triangles are drawn in a clockwise orientation.
Most objects in 3-D scenes are composed of triangle strips. This is because triangle strips can be used to specify complex objects in a way that makes efficient use of memory and processing time.
The following illustration shows a rendered triangle strip.
The triangle strip primitive is identified by the D3DMPT_TRIANGLESTRIP element of the D3DMPRIMITIVETYPE enumeration.
The following code example shows how to create vertices for this triangle strip.
struct CUSTOMVERTEX
{
float x,y,z;
};
CUSTOMVERTEX Vertices[] =
{
{-5.0, -5.0, 0.0},
{ 0.0, 5.0, 0.0},
{ 5.0, -5.0, 0.0},
{10.0, 5.0, 0.0},
{15.0, -5.0, 0.0},
{20.0, 5.0, 0.0}
};
The following code example shows how to use IDirect3DMobileDevice::DrawPrimitive to render this triangle strip.
//
// It is assumed that d3dmDevice is a valid
// pointer to a IDirect3DMobileDevice interface.
//
d3dmDevice->DrawPrimitive( D3DMPT_TRIANGLESTRIP, 0, 5 );