• 9
• 11
• 11
• 9
• 20

# [DirectX10/Assimp] Index buffer trouble

This topic is 2906 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I've tried to build in Assimp into my engine, but I have some trouble with the index buffer. DirectX means that the values in the Index buffer are invalid:
D3DX10: ID3DX10Mesh: Fatal error: index buffer contains invalid entries
And after looking at the Assimp viewer I just got more questions. Here is what I try to do:
//-------------Indices--------------
DWORD* Indices = new DWORD[MeshScene->mMeshes[NumMesh]->mNumFaces*3]; //A Vertex has 3 points, so *3
UINT Face=0;
for(UINT i=0;i<MeshScene->mMeshes[NumMesh]->mNumFaces;i++)
{
//Fill our index buffer
int ii=0;
for(ii=0;ii<MeshScene->mMeshes[NumMesh]->mFaces[Face].mNumIndices;ii++)
{
Indices=MeshScene->mMeshes[NumMesh]->mFaces[Face].mIndices[ii];
i++;
}

Face++;

}
*oIndices=Indices; //Finished filling the index buffer, set the output
*IndicesSize=MeshScene->mMeshes[NumMesh]->mNumFaces*sizeof(DWORD)*3; //Set index buffer size in bytes


I used another loader before, and I set the Indices just the way I did it here. Here is a part of my old loading function, but the parameters are still the same:
Mesh->GetIndexBuffer(&mb);
void* MeshIndexData;
DWORD* IndexData=new DWORD[mb->GetSize()/sizeof(DWORD)];

mb->Map(&MeshIndexData,&size);

memcpy(IndexData,MeshIndexData,mb->GetSize());

mb->Unmap();

*IndicesSize=mb->GetSize();
*oIndices=IndexData;
mb->Release();


In the code of the Assimp viewer I have seen this:
g_piDevice->CreateIndexBuffer( 2 * mesh->mNumFaces * nidx, ...

while nidx is the face-style (Point=1,Line=2,Triangle=3), so for most meshes it is 3. But why the *2? Please help me! :( Edit: I found some logical errors in the code above and updated it. But it still isn't working as it should! (Same error) [Edited by - mind in a box on May 5, 2010 11:40:02 AM]