Sign in to follow this  

VB from non-interleaved data

Recommended Posts

Puppet    181
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
jollyjeffers    1570
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.


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