Hello, belfegor, yes may I have your code please?
I am working hard to figure out why the index went exploded to a large number.
Maybe the Index Stride overflows the index buffer?!
Comments:
The index1 at the first iteration already went exploded so that the subsequent read on the
const float* v1 = &m_verts[m_tris[i+1]*3];
becomes undefined....
I will PM you.
Thanks
Jack
auto dxMesh = mesh->GetStaticMesh();
D3DVERTEXELEMENT9 decl[MAXD3DDECLLENGTH];
dxMesh->GetDeclaration(decl);
WORD offsetToPosition = 0;
for (UINT i = 0; i < MAXD3DDECLLENGTH; ++i)
{
if (D3DDECLUSAGE_POSITION == decl[i].Usage)
{
offsetToPosition = decl[i].Offset;
}
}
// Get Vertex Information
DWORD vertStride = dxMesh->GetNumBytesPerVertex();
DWORD numVerts = dxMesh->GetNumVertices();
DWORD indStride = sizeof(WORD);
DWORD opt = dxMesh->GetOptions();
if((opt & D3DXMESH_32BIT) == D3DXMESH_32BIT)
{
indStride = sizeof(DWORD);
}
BYTE* pIndices;
dxMesh->LockIndexBuffer(0, (LPVOID*)&pIndices);
DWORD numInd = dxMesh->GetNumFaces() * 3;
for(DWORD i = 0; i < numInd; i += 3)
{
int index0 = *(int*)(&pIndices[indStride * i + 0]);
int index1 = *(int*)(&pIndices[indStride * i + 1]);
int index2 = *(int*)(&pIndices[indStride * i + 2]);
addTriangle(index0, index1, index2, tcap);
}