Sign in to follow this  
EmptyVoid

DirectX10 SetAttributeData command is not Working...

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[i]=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
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
Out of the 200 or so people who viewed this I know one of you must know whats wrong... One of you must have tried to use the GenerateAdjacencyAndPointReps or attribute buffer or even Optimize.

Share this post


Link to post
Share on other sites
Quote:
Original post by EmptyVoid
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, so I'm going to link the full source code and hope someone can figure it out:

*** Source Snippet Removed ***

Well, you haven't really given us any idea either. Help us to help you. How is it failing? Is it crashing, blue-screening, or returning a failed error code? What is the return HRESULT? What do the debug runtimes say?

Share this post


Link to post
Share on other sites
Quote:
Original post by Sc4Freak
Quote:
Original post by EmptyVoid
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, so I'm going to link the full source code and hope someone can figure it out:

*** Source Snippet Removed ***

Well, you haven't really given us any idea either. Help us to help you. How is it failing? Is it crashing, blue-screening, or returning a failed error code? What is the return HRESULT? What do the debug runtimes say?


The program continues as if nothing was wrong. There is no debug output and HRESULT returns "E_FAIL". I have no idea whats going on...

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this