Jump to content
  • Advertisement
Sign in to follow this  
Luth

Is there a way to convert vertex list into VB/IB?

This topic is 4833 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've got a long list of triangles (3x Vertex) that I'd like to make a vertex buffer / index buffer out of. Is there any "automatic" way to convert a list of vertices into a VB/IB, eliminating all the duplicates and such?

Share this post


Link to post
Share on other sites
Advertisement
If each 3 vertices is its own triangle (i.e. 0,1,2 make a tri, 3,4,5 make a tri, and so on), you can just make an IB as long as the VB and write a list of numbers starting at 0 and just counting up from there.

As for removing duplicate vertices.. the easiest way to do that would probably be to use the ID3DXMesh interface. Create an ID3DXMesh with the same number of verts and indices as your VB and IB have, copy the VB and IB into the ID3DXMesh, and use the ID3DXMesh::OptimizeInplace method. Then copy your VB and IB back out.

Share this post


Link to post
Share on other sites
Quote:
Original post by Drakex
As for removing duplicate vertices.. the easiest way to do that would probably be to use the ID3DXMesh interface. Create an ID3DXMesh with the same number of verts and indices as your VB and IB have, copy the VB and IB into the ID3DXMesh, and use the ID3DXMesh::OptimizeInplace method. Then copy your VB and IB back out.

I second this approach [smile] I used it a while back (along with some welding and so on..) and it did exactly what I wanted it to do.

If it's in a performance-critical part of your code then it might not be a good choice, but that aside it does make for some relatively simple code on your part. Perfect if you're just going to generate your geometry in an editor or once during application-load.

hth
Jack

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!