DirectX10 SetAttributeData command is not Working...

Started by
14 comments, last by EmptyVoid 15 years, 8 months ago
This post has been edited but I am still having the original problem. The SetAttributeData command does not seem to work but HRESULT returns S_OK and there is no debug output. I set all attributes to 10 but when I call DrawSubset(10) I see nothing but when I call DrawSubset(0) it draws. So clearly it's not doing anything... Here is the code:

UINT *attributes = new UINT[number_of_indices/3];
for(DWORD i=0;i<(Number_Of_Indices/3);i++)
attributes=10;
D3DX10CreateMesh( pd3dDevice, layout, (sizeof(layout)/sizeof(layout[0])), "POSITION", number_of_vertices, number_of_indices, D3DX10_MESH_32_BIT, &mesh );
mesh->SetVertexData(0,vertices);
mesh->SetIndexData(indices, number_of_indices);
mesh->SetAttributeData(attributes);
mesh->GenerateAdjacencyAndPointReps(0.01);
mesh->Optimize(D3DX10_MESHOPT_COMPACT | D3DX10_MESHOPT_ATTR_SORT | D3DX10_MESHOPT_VERTEX_CACHE,0,0);
mesh->CommitToDevice();





Am I doing something wrong? Do I need to call any other commands to make it work? [Edited by - EmptyVoid on August 19, 2008 3:17:55 AM]
This is your life, and it's ending one minute at a time. - Fight club
Advertisement
You need to generate an attribute table for your subset. You can do this by calling Optimize(...) after SetAttributeData(...). Optimize() will scan through the attributes and generate an attribute table for subset 10. You can also set attribute tables yourself if you know your mesh's geometry, then you don't need to set attribute data. Take a look at D3DXATTRIBUTERANGE and ID3DXMesh::SetAttributeTable for more information.
How do I create the adjacency buffer so I can use Optimize?
I tired this mesh->GenerateAdjacencyAndPointReps(0) but it does not seem to work because it still gives this error "D3DX10: ID3DX10Mesh::Optimize requires mesh adjacency information"
This is your life, and it's ending one minute at a time. - Fight club
Quote:How do I create the adjacency buffer so I can use Optimize?

Something like the following (in DX9):
DWORD *pAdj;pAdj = new DWORD[mesh->GetNumFaces()*3];mesh->GenerateAdjacency(0.01f,pAdj);mesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT,pAdj,NULL,NULL,NULL);

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:Original post by Buckeye
Quote:How do I create the adjacency buffer so I can use Optimize?

Something like the following (in DX9):
DWORD *pAdj;pAdj = new DWORD[mesh->GetNumFaces()*3];mesh->GenerateAdjacency(0.01f,pAdj);mesh->OptimizeInplace(D3DXMESHOPT_ATTRSORT,pAdj,NULL,NULL,NULL);


I know how to do it in DX9 but I need to know how to do it in DX10.
This is your life, and it's ending one minute at a time. - Fight club
If you know how to do it in DX9 then you should perform similar tests as you would do with a DX9 mesh. Check the return values and try to choose an Epsilon value greater zero. If GenerateAdjacencyAndPointReps returns S_OK look for other possible functions that generate adjacency information. In worst case try to generate adjacency information yourself and set it with SetAdjacencyData, or use attribute tables without attribute data.
Quote:Original post by 84r
If you know how to do it in DX9 then you should perform similar tests as you would do with a DX9 mesh. Check the return values and try to choose an Epsilon value greater zero. If GenerateAdjacencyAndPointReps returns S_OK look for other possible functions that generate adjacency information. In worst case try to generate adjacency information yourself and set it with SetAdjacencyData, or use attribute tables without attribute data.


Here is what I tried:

	D3DX10CreateMesh( pd3dDevice, layout, (sizeof(layout)/sizeof(layout[0])), 0, number_of_vertices, number_of_indices, D3DX10_MESH_32_BIT, &mesh );	mesh->SetVertexData(0,vertices);	mesh->SetIndexData(indices, number_of_indices);	mesh->SetAttributeData(attributes);	mesh->GenerateAdjacencyAndPointReps(0.01);	mesh->Optimize(D3DXMESHOPT_VERTEXCACHE | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_COMPACT,0,0);	mesh->CommitToDevice();


and it still returns this error "D3DX10: ID3DX10Mesh::Optimize requires mesh adjacency information".
This is your life, and it's ending one minute at a time. - Fight club
Any and all assistance would be most appreciated.
This is your life, and it's ending one minute at a time. - Fight club
Check the return values of the functions. Each function returns an HRESULT value that can help you to identify the problem.

if (FAILED(mesh->GenerateAdjacency...))
{
// something is wrong
}

or

HRESULT hr = mesh->GenerateAdjacency...

Compare hr to the "Direct3D 10 Return Codes" you find in the documentation. Probably a function before Optimize fails to succeed. Also try to call CommitToDevice before GenerateAdjacency.
Quote:Original post by 84r
Check the return values of the functions. Each function returns an HRESULT value that can help you to identify the problem.

if (FAILED(mesh->GenerateAdjacency...))
{
// something is wrong
}

or

HRESULT hr = mesh->GenerateAdjacency...

Compare hr to the "Direct3D 10 Return Codes" you find in the documentation. Probably a function before Optimize fails to succeed. Also try to call CommitToDevice before GenerateAdjacency.


I tried to calling CommitToDevice before GenerateAdjacency but it didn't do anything and GenerateAdjacencyAndPointReps is failing but I have no idea why.

[Edited by - EmptyVoid on August 18, 2008 8:27:20 PM]
This is your life, and it's ending one minute at a time. - Fight club

This topic is closed to new replies.

Advertisement