Sign in to follow this  
EmptyVoid

I require assistance with D3DX10CreateMesh.

Recommended Posts

EmptyVoid    102
I'm trying to create a mesh but I'm a bit confused... Here is my code:

E_VERTEX *vertices = new E_VERTEX[number_of_vertices];
DWORD *indices = new DWORD[number_of_indices];
DWORD *attributes = new DWORD[number_of_indices/3];

// Then it fills the arrays with data from a file but I don't see the point in showing all that.

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((UINT*)attributes);

delete [] vertexdata;
delete [] facedata;
delete [] attributes;







When I call DrawSubset(0) I see nothing. What am I doing wrong? [Edited by - EmptyVoid on August 14, 2008 4:45:05 AM]

Share this post


Link to post
Share on other sites
SiS-Shadowman    359
That's not much code you show us. Did you setup the matrices correctly? Renderstates? Does the camera point to the mesh?

You should check for error codes:

if( FAILED( pd3dDevice->Draw.... ) )
{

}


You can check nearly every DirectX call with that and find out what is wrong.
I wrote a macro for that that throws an exception when a function fails.

V( pd3dDevice->Draw... );

Share this post


Link to post
Share on other sites
EmptyVoid    102
Quote:
Original post by SiS-Shadowman
That's not much code you show us. Did you setup the matrices correctly? Renderstates? Does the camera point to the mesh?

You should check for error codes:
*** Source Snippet Removed ***
You can check nearly every DirectX call with that and find out what is wrong.
I wrote a macro for that that throws an exception when a function fails.
*** Source Snippet Removed ***


Well I changed form vertex an index buffers to a mesh so I'm pretty sure all of that is set up right but I'm not sure I'm creating the mesh right. I just need someone to tell me if the code I posted is correct.

Share this post


Link to post
Share on other sites
jollyjeffers    1570
Just a friendly note from your neighbourhood moderator - I'm all game for a bit of creativity in subject titles, but this one really goes too far "No one ever looks at the posts I need help with unless I name them creatively *sigh*". I haven't had time to browse your previous subject lines, but it could be that your non-creative subjects aren't actually descriptive enough rather than that you need whacky "out there" subjects.

More importantly, as a shared resource for the entire community I want these forums to look reasonably clean and tidy. Nothing shouts "n00b pit" like a bunch of "OMG HELPZ NEEEEEDDED!! LOLZ!!" subject lines littering the front page (yes, I know that this title isn't as bad!). Everyone is welcome but I don't want to discourage the many very talented and knowledgeable contributors from visiting this forum.

Carry on [smile]

Jack

Share this post


Link to post
Share on other sites
SiS-Shadowman    359
Quote:
Original post by EmptyVoid
Well I changed form vertex an index buffers to a mesh so I'm pretty sure all of that is set up right but I'm not sure I'm creating the mesh right. I just need someone to tell me if the code I posted is correct.


And does D3DXCreateMesh return D3D_OK?

Share this post


Link to post
Share on other sites
EmptyVoid    102
Quote:
Original post by jollyjeffers
Just a friendly note from your neighbourhood moderator - I'm all game for a bit of creativity in subject titles, but this one really goes too far "No one ever looks at the posts I need help with unless I name them creatively *sigh*". I haven't had time to browse your previous subject lines, but it could be that your non-creative subjects aren't actually descriptive enough rather than that you need whacky "out there" subjects.

More importantly, as a shared resource for the entire community I want these forums to look reasonably clean and tidy. Nothing shouts "n00b pit" like a bunch of "OMG HELPZ NEEEEEDDED!! LOLZ!!" subject lines littering the front page (yes, I know that this title isn't as bad!). Everyone is welcome but I don't want to discourage the many very talented and knowledgeable contributors from visiting this forum.

Carry on [smile]

Jack


I don't think talented people would care that much but I do think it would make it hard to search for by people looking for help in the future, so I'll change it.

It only had 20 views in 7 hours and 10 were mine. But after I changed the title I got 100 more in less then a hour and replies.

Share this post


Link to post
Share on other sites
EmptyVoid    102
Quote:
Original post by SiS-Shadowman
Quote:
Original post by EmptyVoid
Well I changed form vertex an index buffers to a mesh so I'm pretty sure all of that is set up right but I'm not sure I'm creating the mesh right. I just need someone to tell me if the code I posted is correct.


And does D3DXCreateMesh return D3D_OK?


Yes it does and I think the problem may be because I left the first value zero in SetVertexData but I don't know what I need to put there if that's the problem.

Share this post


Link to post
Share on other sites
SiS-Shadowman    359
I understand your confusion. I looked at the msdn and I don't understand what value you need to set there. I've never worked with IDX meshes, I wrote my own class.
I think this value represents the index of the vertexbuffer, so 0 should be fine in your case. It's very odd however, that I couldn't find an example in the D3D10 samples ordner that uses the IDX10 Mesh, they all seem to use the "old" one from dx9 (I've looked at about 5 samples). Did you try to use the old one or is there a reason why you need to use the DX10 mesh?

Share this post


Link to post
Share on other sites
EmptyVoid    102
Quote:
Original post by SiS-Shadowman
I understand your confusion. I looked at the msdn and I don't understand what value you need to set there. I've never worked with IDX meshes, I wrote my own class.
I think this value represents the index of the vertexbuffer, so 0 should be fine in your case. It's very odd however, that I couldn't find an example in the D3D10 samples ordner that uses the IDX10 Mesh, they all seem to use the "old" one from dx9 (I've looked at about 5 samples). Did you try to use the old one or is there a reason why you need to use the DX10 mesh?


Can you use the old one with DirectX10?

Share this post


Link to post
Share on other sites
EmptyVoid    102
Quote:
Original post by SiS-Shadowman
They seem to use it in the SDK Samples, so my guess would be: yes. Give it a try.


D3DXCreateMeshFVF(number_of_indices, number_of_vertices, D3DXMESH_MANAGED | D3DXMESH_32BIT, D3DFVF_XYZB5 | D3DFVF_LASTBETA_UBYTE4 | D3DFVF_NORMAL | D3DFVF_TEX1, (LPDIRECT3DDEVICE9)pd3dDevice, mesh);

The code crashes because the Device is not a LPDIRECT3DDEVICE9.

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