Skip to main content
gamedev.net
🔒 Locked

extracting data from a subset

Started by renman29 Sep 29, 2006 at 4:44 AM 3 replies 850+ views
Original Post
renman29
renman29
I searched around and can't seem to find anything about extracting data from only one particular subset of a mesh. I'm thinking it has something to do with attribute tables, but I can't seem to figure out how to do this. Basically I'm trying to pick a subset/sub-mesh from an already loaded x file, and record its contents into another data structure, and then I will later need to modify the contents of that subset/mesh. Is there some kind of way to lock the vertex buffer / index buffer for a particular subset? (btw - I used OptimizeInPlace) Any kind of ideas for solving this type of problem are more than welcome. :)
Nik02
Nik02
The attribute buffer is used to store which triangles are in which subset. Depending on the optimization status, the buffer can contain two things:

If the mesh is unoptimized, the attribute buffer will contain a DWORD for each triangle, determining in which subset a given triangle belongs to. As each adjacent triangle can belong to a different subset, it can be very slow for D3DX to search for triangles of a given subset at draw time.

If the mesh is optimized with attribute range optimization, the adjacency buffer consists of an array of D3DXATTRIBUTERANGE structures that store the subset index and the start and end points of the triangle indices which belong to that subset. When you ask for the attribute table from the mesh, a DWORD parameter gets filled by the number of subsets currently in the mesh, and this is (not surprisingly) the number of elements of the attribute range array.

To get a triangle from a subset, first get it's three indices by looking up into the index buffer and multiplying the desired triangle index by three (since 3 indices == 1 triangle). Then, with the three indices, look up the vertex data from the vertex buffer.
Niko Suni
renman29
renman29
Aha! :D
So if I use these flags, D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT with optimize, and GetAttributeTable, and then use the D3DXATTRIBUTERANGE data to give me the FaceStart and count (multiplying each face# by 3 to get the corresponding indices) - I'll have the span of indices that make up the polygons of that subset.

I'll go to work on that. Thank you very very much! (^-^)

[Btw - Just out of curiousity, I'm now wondering if the AttribId's in each D3DXATTRIBUTERANGE are consecutive? (ie: Are they always like: 0,1,2,3,4,... or sometimes not?)]
Nik02
Nik02
Quote:
Original post by renman29
[Btw - Just out of curiousity, I'm now wondering if the AttribId's in each D3DXATTRIBUTERANGE are consecutive? (ie: Are they always like: 0,1,2,3,4,... or sometimes not?)]


It would make sense for them to be consecutive, but since the behavior is not guaranteed, I wouldn't assume it.
Niko Suni

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.