Jump to content
  • Advertisement
Sign in to follow this  
Puppet

VB from non-interleaved data

This topic is 4851 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 am currently writing an editor and my editor's mesh objects store the data in seperate arrays. A mesh holds positions, optionally diffuse colors and normals, plus up to 4 UV sets, each in their own array. DX vertex buffers are interleaved, which is understandable but a bit annoying. Is there a neat way of handling the copying of these arrays into a vertex buffer? Any misc functions? I can create the FVF flags for my data, but the actual vertex struct can look very different depending on what data the mesh contains, as there are many combinations. When I copy my data into the VB I could just calculate the size of the current FVF vertex and do some pointer fiddling and for each data array copy an element at a time, doing one pass for each array (using the stride of the FVF). This is a bit ugly and proabably rather slow. I'm building and editor and one might say speed isn't critical, but some updates in the editor will be. Quick feedback is a good thing. The alternative is to use interleaved data in my mesh objects, but that makes for very awkward and slow manipulation of the data. I'm just wondering if there's a nice/fast way of building VBs from non-interleaved data. I'm sure someone here on GameDev has figured out something clever :) Thanks, Christer

Share this post


Link to post
Share on other sites
Advertisement
Have you looked at using multiple streams?

Admittedly, it's not something I've had any great need to use - but from my understanding you could have a few vertex buffers (e.g. position/diffuse/texcoord) and then set them to the first 3 streams on your device and compose them together when rendering.

That way you still keep your preferred style of storing data, and you don't really need to manipulate it to be interleaved.

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!