   D3DX10Mesh subsets
  Hello everyone,I'm having troubles with setting the attribute data of a mesh, for now, im trying to create a simple quad ( 2 tris ), each triangle in a different subset, so i wrote the following:void hxObject::CreateFromBuffers ( _hxVertex* vertexBuffer, DWORD* indexBuffer,UINT* AttributeBuffer, UINT numVertices, UINT numTriangles ){_numFaces = numTriangles;_numVertices = numVertices;if ( FAILED ( D3DX10CreateMesh ( _MainCore->_device, _Effect->_elementDesc, _Effect->_numElements,_Effect->_elementDesc[0].SemanticName, _numVertices, _numFaces, D3DX10_MESH_32_BIT, &_mesh ) ) )return;_mesh->SetIndexData ( indexBuffer, _numFaces * 3 );_mesh->SetVertexData ( 0, vertexBuffer );_mesh->GenerateAdjacencyAndPointReps ( 0.001f );_mesh->Optimize ( D3DX10_MESHOPT_ATTR_SORT | D3DX10_MESHOPT_VERTEX_CACHE, 0, 0 );_mesh->CommitToDevice ( );if ( AttributeBuffer ){_mesh->SetAttributeData ( AttributeBuffer );}else{UINT* attributeBuffer = new UINT[_numFaces];for ( UINT i = 0; i < _numFaces; i++ )attributeBuffer = 0;_mesh->SetAttributeData ( attributeBuffer );}   //test the number of subsetsUINT numSubsets;D3DX10_ATTRIBUTE_RANGE att;_mesh->GetAttributeTable ( &att, &numSubsets );_vaild = true;}passing the arguments:_hxVertex vb[4];DWORD ib[6];UINT ab[2];vb[0] = _hxVertex ( -5.0f, 0.0f, 5.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f );vb[1] = _hxVertex ( 5.0f, 0.0f, 5.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f );vb[2] = _hxVertex ( -5.0f, 0.0f, -5.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f );vb[3] = _hxVertex ( 5.0f, 0.0f, -5.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f );ib[0] = 0;ib[1] = 1;ib[2] = 2;ib[3] = 3;ib[4] = 2;ib[5] = 1;ab[0] = 0;ab[1] = 1;tobj.CreateFromBuffers ( vb, ib, ab, 4, 2 );however, numSubsets is still 1, even though i have 2 different numbers in the attribute data { 0, 1 }, shouldnt this mean that triangle 0 is in subset 0 and triangle 1 is in subset 1 ? and thus, i should have 2 subsets? why is numSubsets = 1 over there then?Thank you for readingregards-Hassan   
  I have just the same problem, but I've read that you have to optimize after you set your attribute buffer. Doesn't works for me, but maybe you have more luck than me. :)   ;Quote:Original post by mind in a boxI have just the same problem, but I've read that you have to optimize after you set your attribute buffer. Doesn't works for me, but maybe you have more luck than me. :)Oh well, that doesn't make any difference ;/   ;  Oh actually, changing the order to this fixed the problemif ( FAILED ( D3DX10CreateMesh ( _MainCore->_device, _Effect->_elementDesc, _Effect->_numElements,_Effect->_elementDesc[0].SemanticName, _numVertices, _numFaces, D3DX10_MESH_32_BIT, &_mesh ) ) )return;_mesh->SetIndexData ( indexBuffer, _numFaces * 3 );_mesh->SetVertexData ( 0, vertexBuffer );_mesh->GenerateAdjacencyAndPointReps ( 0.003f );_mesh->CommitToDevice ( );if ( AttributeBuffer ){_mesh->SetAttributeData ( AttributeBuffer );}else{UINT* attributeBuffer = new UINT[_numFaces];for ( UINT i = 0; i < _numFaces; i++ )attributeBuffer = 0;_mesh->SetAttributeData ( attributeBuffer );}_mesh->Optimize ( D3DX10_MESHOPT_ATTR_SORT | D3DX10_MESHOPT_VERTEX_CACHE, 0, 0 );Thanks alot "mind in a box"! ( maybe it should work with you now ;) )[Edited by - Hassanbasil on May 16, 2010 6:44:00 AM]