Jump to content
  • Advertisement
Sign in to follow this  
PhiberOptic

Extracting data from Indexbuffer / XMesh

This topic is 4895 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

Hi there. I got a question for you guys! I'm using D3D9 and writing a little 3d app. I'm using the built in D3DX mesh tools to load a simple static mesh from a x-file. The problem I got is that I want to access individually faces to do some math / sorting manually. To do that I will require the vertexbuffer copied to my own stucture (wich I have done) then I also need the data from the indexbuffer, but I don't know how to access it. I wrote this code:
	struct looseIB
	{
		WORD i[3];
	};
	looseIB* pIB = new looseIB[ numFaces ];
	void* pCpy = NULL;
	mesh->LockIndexBuffer(0,(void**)&pCpy);
		memcpy(pIB,pCpy,sizeof(looseIB)*numFaces);
	mesh->UnlockIndexBuffer();	

But it didn't work, the pIB is filled with "bullshit". I tried to change to DWORD i[3]; also. Do anyone know how to do this? Do I have to add other members to my struct or something? Thanks

Share this post


Link to post
Share on other sites
Advertisement
Have you turned up D3D/D3DX debug output?

I can't see anything obviously wrong with your fragment, but the debug output might well be warning/hinting as to why the call isn't doing what you want it to [smile]

hth
Jack

Share this post


Link to post
Share on other sites
I solved it. The xfile contained 4 vertex / face so, when I made a mesh with triangles, my code actually worked! :)

However, how do one know when to handle 4verts/face or 3 verts/face.

Share this post


Link to post
Share on other sites
Quote:
Original post by PhiberOptic
However, how do one know when to handle 4verts/face or 3 verts/face.


Never tried it, but presumably ID3DXMesh::GetNumVertices( ) divided by ID3DXMesh::GetNumFaces( ) would give you 3 or 4 accordingly...

Jack

Share this post


Link to post
Share on other sites
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!