Skip to main content
GameDev.net gamedev.net
🔒 Locked

Get/SetAttributeTable question

Started by majek Feb 24, 2009 at 11:25 AM 0 replies 1.1k views
Original Post
majek
majek
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.
// 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);

This doesn't seem to work. DrawSubset(0) draws the entire mesh and DrawSubset(1) does nothing. Am I doing something wrong?
majek
majek
got any ideas? any help would be greatly appreciated.

Topic Locked

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

Sign in to reply to this topic.