Original Post
Hello again, I read in a book that you can split a mesh into subsets using Get/SetAttributeTable. I'm trying to split my mesh in half into 2 subsets so each one can be rendered with a different texture. This doesn't seem to work. DrawSubset(0) draws the entire mesh and DrawSubset(1) does nothing. Am I doing something wrong?
// Call the OptimizeInplace function to generate the attribute table
Mesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT, 0, NULL, NULL, NULL);
DWORD numFaces = Mesh->GetNumFaces();
DWORD numVertices = Mesh->GetNumVertices();
DWORD numAttr;
D3DXATTRIBUTERANGE* attribTable = new D3DXATTRIBUTERANGE[2];
// Get the number of items within the table
Mesh->GetAttributeTable(NULL, &numAttr);
// Get the whole table into the variable attribTable
Mesh->GetAttributeTable(attribTable, &numAttr);
// Set up the attributes for the first group
attribTable[0].AttribId = 0;
attribTable[0].FaceStart = 0;
attribTable[0].FaceCount = numFaces / 2;
attribTable[0].VertexStart = 0;
attribTable[0].VertexCount = numVertices / 2;
// Set up the attributes for the second group
attribTable[1].AttribId = 1;
attribTable[1].FaceStart = numFaces / 2;
attribTable[1].FaceCount = numFaces / 2;
attribTable[1].VertexStart = numVertices / 2;
attribTable[1].VertexCount = numVertices / 2;
// Write the attribute table back into the mesh
Mesh->SetAttributeTable(attribTable, 2);