Jump to content
  • Advertisement
Sign in to follow this  
mind in a box

[DirectX10/Assimp] Index buffer trouble

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

If you intended to correct an error in the post then please contact us.

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]

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!