Build a triangle strip that looks like the following.
o-o-o- -o-o
|\|\|\ . . . \|\|
o-o-o- -o-o
Given inner radius r1
, outer radius r2
, starting angle a
, ending angle b
, you can generate your vertices as follows.
r * [cos(t); sin(t)], for r in {r1, r2}, t in [a, b]
Number the vertices as follows.
1-3-5-7-
|\|\|\|\ . . .
0-2-4-6-
Then given vertices 0, 1, ..., 2*N-1
, the triangles in your triangle strip correspond to the following 3-tuple rows of vertex indexes.
0 1 2
1 2 3
2 3 4
3 4 5
4 5 6
.
.
.
2*N-3 2*N-2 2*N-1
Because of the obvious repetition and pattern here, XNA and graphics in general encode the vertex indexes of a triangle strip as the more-compact array [0, 1, . . ., 2*N-1]
instead.
I'll let you figure out the XNA-specific portion of the problem from there. Microsoft's example is pretty straightforward:
var N = 4;
var points = 2 * N;
var vertices = new VertexPositionColor[points];
for (int x = 0; x < points / 2; x++)
{
for (int y = 0; y < 2; y++)
{
vertices[(x * 2) + y] = new VertexPositionColor(
new Vector3(x * 100, y * 100, 0), Color.White);
}
}
var indices = new short[points];
for (int i = 0; i < points; i++)
{
indices[i] = i;
}
GraphicsDevice.DrawUserIndexedPrimitives<VertexPositionColor>(
PrimitiveType.TriangleStrip,
vertices,
0, // vertex buffer offset to add to each element of the index buffer
points, // number of vertices to draw
indices,
0, // first index element to read
points - 2 // number of primitives to draw
);