Trying to understand D3DXMESH and subsets

Started by
4 comments, last by Psyian 18 years, 8 months ago
Hi, i am currently working on a project to create an octree from a DirectX9 mesh. What i am trying to do is find all of the vertice points while recognising and keeping them in the same submesh. I decided the first thing i need to do is to try and figure out how the DrawSubSet function works so that i get a better idea of where the vertice data is stored. I have got quite a way using GetAttribute to get the details of each submesh. I then hit my problem. I am replacing the DrawSubSet function with the DrawIndexedPrimitive: if (FAILED (pdx9->DrawIndexedPrimitive (D3DPT_TRIANGLELIST , pAttributeTable[Index].VertexStart, 0, pAttributeTable[Index].VertexCount, pAttributeTable[Index].FaceStart, pAttributeTable[Index].FaceCount))) The call works perfectly for the first submesh but any other submeshes are not drawn properly. It seems to draw garbage in the right area of the model but all the faces are corrupt. Stepping through the program i can see that pAttributeTable.VertexStart etc.. are all updated as i expect them to be but there must be some sort of offset i need to add to get it to start at the right point in the index list? Has anyone else tried a similar program and could they get it to work? It all sounded simple when i first started out :-( Thanks to anyone who can help :-) [Edited by - Lonewolf9383 on August 5, 2005 10:26:20 AM]
Advertisement

I had a similar problem, only i took a different root. I decided to strip the vertex and index data out of the mesh (and threw it away). I then went through and found out where each polygon was in the octree, and so on.

Sorry not much help to your problem, just an idea to pass by you.

Hope you crack it.
Hi, Thanks for the reply :)

How did you identify each of the submeshes?

Thanks again

I beleive the subset id points the material/texture, so if you had 2 materials you would have 2 subsets. Don't quote em on this but i believe this is how the .x file works. But i think you are after sub objects???!!??, i was only concerned with getting groups of materials. I suspect there must be some
sub-mesh properties in it somewhere.

A quick search on google lead to this, i remember looking at it a while back, it's a good resouce.

http://www.mvps.org/directx/articles/d3dxmesh.htm


Hope it helps, if i remember i'll drag out my old code and have a look, and let you know.


Laters
That looks like exactly what i need :-D

It looks like the weblink has all the details i need to load it all in and manipulate it.

Thanks for the help, i finally feel like i can get somewhere now after several days of pulling out my hair ;)

Excellent. Good luck :)

This topic is closed to new replies.

Advertisement