Sign in to follow this  

vb to ID3DXMesh

This topic is 4340 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

given a vb, how to convert vb to ID3DXMesh? or how to copy vb data to ID3DXMesh? or how to let ID3DXMesh use existed vb stead of copy operation? given a ib and vb, how to get a "full" tri data? I mean I do not wanna ib, I just wanna a vb in which tri defined.that is a list of tri consist of 3 vertices.

Share this post


Link to post
Share on other sites
Quote:
Original post by luasitdown
given a vb, how to convert vb to ID3DXMesh?
or how to copy vb data to ID3DXMesh?
or how to let ID3DXMesh use existed vb stead of copy operation?

Take a look at the MeshFromOBJ sample. That sample will read in an .obj file and create an ID3DXMesh object from the raw data. The main idea is that you have to create three pieces: a vertex buffer, an index buffer, and an attribute table. The vertex and index buffers are created when you first call D3DXCreateMesh and D3DXCreateMeshFVF.
Quote:
Original post by luasitdown
given a ib and vb, how to get a "full" tri data? I mean I do not wanna ib,
I just wanna a vb in which tri defined.that is a list of tri consist of 3 vertices.

You need to lock both the index and vertex buffers. Use the IDirect3DVertexBuffer9::Lock and IDirect3DIndexBuffer9::Lock methods. You can then use the index buffer to access the vertex buffer data.

neneboricua

Share this post


Link to post
Share on other sites
The only reason you would even want to convert a vb and ib to an ID3DXMesh is to use the mesh interfaces to clean or optimize the mesh, all of which require an ib. Of course you can also create subsets with a mesh. If all you have is a vb you don't need a mesh at all. You can still create your vb in managed memory.

ID3DXMesh::DrawSubset() does a DrawIndexedPrimitive. With your vb, you just do a DrawPrimitive.

Share this post


Link to post
Share on other sites
Quote:
Original post by DXnut
The only reason you would even want to convert a vb and ib to an ID3DXMesh is to use the mesh interfaces to clean or optimize the mesh, all of which require an ib. Of course you can also create subsets with a mesh. If all you have is a vb you don't need a mesh at all. You can still create your vb in managed memory.

ID3DXMesh::DrawSubset() does a DrawIndexedPrimitive. With your vb, you just do a DrawPrimitive.


I wanna use D3DXIntersect it just need the ID3DXMesh.

Share this post


Link to post
Share on other sites

This topic is 4340 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.

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