Game Development Reference
In-Depth Information
Figure 10.3: Notice that the geometry and attribute buffer
are sorted by attribute such that the geometry of a particu-
lar subset is contiguous. We can now easily mark where the
geometry of one subset begins and ends. Note that every
“Tri” block in the index buffer represents three indices.
In addition to sorting the geometry, the D3DXMESHOPT_ATTRSORT
optimization builds an attribute table. The attribute table is an array of
D3DXATTRIBUTERANGE structures. Each entry in the attribute table
corresponds to a subset of the mesh and specifies the block of memory
in the vertex/index buffers, where the geometry for the subset resides.
The D3DXATTRIBUTERANGE structure is defined as:
typedef struct _D3DXATTRIBUTERANGE {
DWORD AttribId;
DWORD FaceStart;
DWORD FaceCount;
DWORD VertexStart;
DWORD VertexCount;
} D3DXATTRIBUTERANGE;
AttribId —The subset ID
FaceStart —An offset into the index buffer ( FaceStart * 3 )
identifying the start of the triangles that are associated with this
subset
FaceCount —The number of faces (triangles) in this subset
VertexStart —An offset into the vertex buffer identifying the
start of the vertices that are associated with this subset.
VertexCount —The number of vertices in this subset
We can easily see the members of the D3DXATTRIBUTERANGE struc-
ture at work graphically in Figure 10.3. The attribute table for the mesh
in Figure 10.3 would have three entries—one to correspond with each
subset.
Search WWH ::




Custom Search