# extracting data from a subset

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

## Recommended Posts

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. :)

##### Share on other sites
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.

##### Share on other sites
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?)]

##### Share on other sites
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.

##### Share on other sites
Ok, I'll just have it do a sort check.
Thanks :D

1. 1
Rutin
19
2. 2
3. 3
JoeJ
15
4. 4
5. 5

• 20
• 19
• 11
• 13
• 17
• ### Forum Statistics

• Total Topics
631697
• Total Posts
3001761
×