Jump to content
  • Advertisement
Sign in to follow this  
EmptyVoid

DirectX10 SetAttributeData command is not Working...

This topic is 3651 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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"

Share this post


Link to post
Share on other sites
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);

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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".

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!