BSP face triangles.


(Code) #1

Greetings.

Im trying to get the triangles in a bsp file.
Ive read the stickie, but it just confused me :banana:

ive tryed this :


	unsigned short unEdge = 1;
	unsigned short unVert = 0;
	unsigned short unZeroIndex = (unsigned short)(ctpFace->nVertexIndex + cnpIndexs[ctpFace->nMeshVertIndex]);
	unsigned short unIndex = 0;
	while (unEdge < (ctpFace->nNumOfVerts - 1))
	{
		tpDest[unVert].fPosition[0]		= ctpVertexs[unZeroIndex].fPosition[0];
		tpDest[unVert].fPosition[1]		= ctpVertexs[unZeroIndex].fPosition[1];
		tpDest[unVert].fPosition[2]		= ctpVertexs[unZeroIndex].fPosition[2];
		tpDest[unVert].fTextureCoord[0]	= ctpVertexs[unZeroIndex].fTextureCoord[0];
		tpDest[unVert].fTextureCoord[1]	= ctpVertexs[unZeroIndex].fTextureCoord[1];
		unVert++;

		unIndex = (unsigned short)(ctpFace->nVertexIndex + cnpIndexs[ctpFace->nMeshVertIndex + unEdge]);
		tpDest[unVert].fPosition[0]		= ctpVertexs[unIndex].fPosition[0];
		tpDest[unVert].fPosition[1]		= ctpVertexs[unIndex].fPosition[1];
		tpDest[unVert].fPosition[2]		= ctpVertexs[unIndex].fPosition[2];
		tpDest[unVert].fTextureCoord[0]	= ctpVertexs[unIndex].fTextureCoord[0];
		tpDest[unVert].fTextureCoord[1]	= ctpVertexs[unIndex].fTextureCoord[1];
		unVert++;

		unEdge++;

		unIndex = (unsigned short)(ctpFace->nVertexIndex + cnpIndexs[ctpFace->nMeshVertIndex + unEdge]);
		tpDest[unVert].fPosition[0]		= ctpVertexs[unIndex].fPosition[0];
		tpDest[unVert].fPosition[1]		= ctpVertexs[unIndex].fPosition[1];
		tpDest[unVert].fPosition[2]		= ctpVertexs[unIndex].fPosition[2];
		tpDest[unVert].fTextureCoord[0]	= ctpVertexs[unIndex].fTextureCoord[0];
		tpDest[unVert].fTextureCoord[1]	= ctpVertexs[unIndex].fTextureCoord[1];
		unVert++;
	}

and this :


	unsigned short unEdge = 0;
	unsigned short unVert = 0;
	unsigned short unIndex = 0;
	while (unEdge < ctpFace->nNumOfVerts)
	{
		if (unEdge != 0) { unEdge -= 2; }

		unIndex = (unsigned short)(ctpFace->nVertexIndex + cnpIndexs[ctpFace->nMeshVertIndex + unEdge]);
		tpDest[unVert].fPosition[0]		= ctpVertexs[unIndex].fPosition[0];
		tpDest[unVert].fPosition[1]		= ctpVertexs[unIndex].fPosition[1];
		tpDest[unVert].fPosition[2]		= ctpVertexs[unIndex].fPosition[2];
		tpDest[unVert].fTextureCoord[0]	= ctpVertexs[unIndex].fTextureCoord[0];
		tpDest[unVert].fTextureCoord[1]	= ctpVertexs[unIndex].fTextureCoord[1];
		unVert++;
		unEdge++;

		unIndex = (unsigned short)(ctpFace->nVertexIndex + cnpIndexs[ctpFace->nMeshVertIndex + unEdge]);
		tpDest[unVert].fPosition[0]		= ctpVertexs[unIndex].fPosition[0];
		tpDest[unVert].fPosition[1]		= ctpVertexs[unIndex].fPosition[1];
		tpDest[unVert].fPosition[2]		= ctpVertexs[unIndex].fPosition[2];
		tpDest[unVert].fTextureCoord[0]	= ctpVertexs[unIndex].fTextureCoord[0];
		tpDest[unVert].fTextureCoord[1]	= ctpVertexs[unIndex].fTextureCoord[1];
		unVert++;
		unEdge++;

		unIndex = (unsigned short)(ctpFace->nVertexIndex + cnpIndexs[ctpFace->nMeshVertIndex + unEdge]);
		tpDest[unVert].fPosition[0]		= ctpVertexs[unIndex].fPosition[0];
		tpDest[unVert].fPosition[1]		= ctpVertexs[unIndex].fPosition[1];
		tpDest[unVert].fPosition[2]		= ctpVertexs[unIndex].fPosition[2];
		tpDest[unVert].fTextureCoord[0]	= ctpVertexs[unIndex].fTextureCoord[0];
		tpDest[unVert].fTextureCoord[1]	= ctpVertexs[unIndex].fTextureCoord[1];
		unVert++;
		unEdge++;
	}

And ive tryed doing it โ€œmanualyโ€ on a box, i failed :banghead:

Could someone give me some light on how i could fetch those faces and make triangles out of it?

Thanks :moo: