Game Development Reference
In-Depth Information
With the attribute table built, rendering a subset can be done very
efficiently, for only a quick lookup in the attribute table is required to
find all the geometry of a particular subset. Note that without an attrib-
ute table, rendering a subset requires a linear search of the entire
attribute buffer to find the geometry that exists in the particular subset
that we are drawing.
To access the attribute table of a mesh, we use the following
method:
HRESULT ID3DXMesh::GetAttributeTable(
D3DXATTRIBUTERANGE* pAttribTable,
DWORD* pAttribTableSize
);
This method can do two things: It can return the number of attributes
in the attribute table or it can fill an array of D3DXATTRIBUTERANGE
structures with the attribute data.
To get the number of elements in the attribute table, we pass in 0
for the first argument:
DWORD numSubsets = 0;
Mesh->GetAttributeTable(0, &numSubsets);
Once we know the number of elements, we can fill a D3DXATTRI-
BUTERANGE array with the actual attribute table by writing:
D3DXATTRIBUTERANGE table = new D3DXATTRIBUTERANGE [numSubsets];
Mesh->GetAttributeTable( table, &numSubsets );
We can directly set the attribute table using the ID3DXMesh::Set-
AttributeTable method. The following example sets an attribute
table with 12 subsets:
D3DXATTRIBUTERANGE attributeTable[12];
// ...fill attributeTable array with data
Mesh->SetAttributeTable( attributeTable, 12);
10.6 Adjacency Info
For certain mesh operations, such as optimizing, it is necessary to
know the triangles that are adjacent to a given triangle. A mesh's adja-
cency array stores this information.
The adjacency array is a DWORD array, where each entry contains
an index identifying a triangle in the mesh. For example, an entry i
refers to the triangle formed by indices:
Search WWH ::




Custom Search