I have re-written the vertex code to work just like the example above. The vertex buffer seems to be correct because I rendered the points in world space and they form a box (and other model shapes I have tested). The only thing left is the index buffer.
I don't understand how to calculate the new indices. In the index buffer I loop through each triangle but then I don't know how to look up the value of the new index. The code below is my setup, although it uses old indices.

Code:
for (unsigned i = 0; i < dwNumTris; i++) {
	MD7_TRIANGLE tr;
	memcpy(&tr, &pTriangles[i], sizeof(MD7_TRIANGLE));

	// triangle
	pIndexBuffer[i*3+0] = tr.v_index[0]; // old index
	pIndexBuffer[i*3+1] = tr.v_index[1]; // old index
	pIndexBuffer[i*3+2] = tr.v_index[2]; // old index
}