Jump to content
  • Advertisement
Sign in to follow this  
dartainiar

mesh editor : use vertexbuffer or mesh?

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

I try to make my own mesh editor use directx9 in c++ Using vertexbuffer is easy to control every triangle in mesh but it is hard to interact with my mesh because I have to implement all interactive function. Using mesh is easy to control mesh with mouse input.but I don't know how to modify my mesh .Like to add or to del triangle ,move the vertex on mesh etc. If any one can tell me how to modify vertex and face in ID3DXMesh,or to transfer vertexbuffer into mesh,or better way?

Share this post


Link to post
Share on other sites
Advertisement
For LPD3DXMESH you can just call the method like so to get a vertex buffer (assuming direct x 9.0)

LPDIRECT3DVERTEXBUFFER9 meshVB;
m_pMesh->GetVertexBuffer(&meshVB);



or you can just directly lock the vertex buffer using code similar to this

VERTEX *vertices;
m_pMesh->LockVertexBuffer(D3DLOCK_DISCARD, (BYTE**)&vertices);
//do vertices changes
m_pMesh->UnlockVertexBuffer();



obviously your parameters would change, but that's basically it :)

Share this post


Link to post
Share on other sites
You would need to create a new mesh with the new number of vertices and/or faces.

D3DXCreateMesh() is the function to use.

Then lock the buffers of both, copy existing ones from old to new, and add the new ones to the new mesh.

Share this post


Link to post
Share on other sites
Quote:
Original post by DXnut
You would need to create a new mesh with the new number of vertices and/or faces.

D3DXCreateMesh() is the function to use.

Then lock the buffers of both, copy existing ones from old to new, and add the new ones to the new mesh.


Or, allocate enough space for your original mesh in advance. The way the "big" editors do this, is that they keep the editable mesh separate from the graphics system so as to allow unlimited flexibility in editing it, regardless of what system will be rendering it.

I recommend keeping an editable mesh in your own data structures (ie. not a d3d mesh), and creating a new d3d mesh when your data changes. For simple transformations, you don't need to re-create the renderable mesh as shaders can do the work for you.

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!