线条带Line strips

线条带是由互连的线段组成的基元。A line strip is a primitive that is composed of connected line segments. 你的应用程序可使用线条带创建不封闭的多边形。Your application can use line strips for creating polygons that are not closed. 封闭多边形是通过线段将最后一个顶点连接到第一个顶点的多边形。A closed polygon is a polygon whose last vertex is connected to its first vertex by a line segment. 如果你的应用程序基于线条带生成多边形,则不能保证顶点共面。If your application makes polygons based on line strips, the vertices are not guaranteed to be coplanar.

示例Example

下图显示了渲染的线条带。The following illustration shows a rendered line strip.

线条带示意图

下面的代码显示如何为此线条带创建顶点。The following code shows how to create vertices for this line 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}
};

下面的代码示例显示如何在 Direct3D 中渲染线条带。The code example below shows how to render a line strip in Direct3D.

//
// It is assumed that d3dDevice is a valid
// pointer to an IDirect3DDevice interface.
//
d3dDevice->DrawPrimitive( D3DPT_LINESTRIP, 0, 5 );

相关主题Related topics

基元Primitives