How are the vertex indices supposed to be arranged for drawing a triangle strip as far as XNA/D3D are concerned? I am guessing that it would follow this formula:
Let N be the index of the first vertex in an array of vertices.
Triangle 1: N + 0, N + 1, N + 2
Triangle 2: N + 1, N + 3, N + 2
Triangle 3: N + 2, N + 3, N + 4
Triangle 4: N + 3, N + 5, N + 3
So basically even-numbered triangles have their second and third vertices swapped, otherwise it is fairly straightforward where the first index is dropped from the previous triangle and the other two are slid over.
Does this seem right? I am trying to convert a triangle strip from a model into a triangle list (for a polysoup collision mesh). Here is a pseudo-code implementation:
List<Triangle> triList = new List<Triangle>();
int idx = 0;
for (int i = 2; i < start + numelements; i++)
{
Triangle tri = new Triangle();
bool isEven = (i % 2 == 0); //is this an even or odd triangle?
tri.v0 = i - 2; //always two indexes back
tri.v1 = isEven ? i : i - 1; //alternate the order of the next two
tri.v2 = isEven ? i - 1 : i;
//if not degenerate add to the list
if (tri.v0 != tri.v1 && tri.v1 != tri.v2 && tri.v2 != tri.v0)
triList.add(tri);
}