[MDX] Meshes sharing the same Vertex and Index Buffer

Started by
3 comments, last by Promit 15 years, 10 months ago
In my application there will be a lot of simular objects (up to 100 000). I want all of my meshes that have the same texture to use the same vertex and index buffer so i had to call DrawIndexedPrimitives only once for one set of objects. How to acomplish this ?
Advertisement
If by "meshes" you mean the Mesh class, I do not think this is possible. You'll have to write your own mesh code. You may be able to get around with instancing, particularly shader instancing. Whether that will work or not depends on the details of what "similar" means.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Yes, i mean Mesh class.
Similar objects have the same surface properties like texture, material. They could differ in shape.

I found that I can use code like this:

CustomVertex.PositionNormal[] vertices = (CustomVertex.PositionNormal[])                mesh.LockVertexBuffer(typeof(CustomVertex.PositionNormal),                    LockFlags.ReadOnly, mesh.NumberVertices);


to build my own buffers but i was wondering if i can use methods like SetVertexBufferData() and SetIndexBufferData().

Can they be used when vertex buffer and index buffer of given Mesh are shared with other meshes?

Will they automatically change buffer size and reindex indexes ?

Or are they just the same as VertexBuffer.SetData() and IndexBuffer.SetData() ?

And finally how to get information about type of data stored in mesh object (triangleListm triangleFan ,ect.) becouse it's necessary in DrawIndexedPrimitives() call ?
A little more detail along the lines of what Promit asked would be useful. However, if you've got identical meshes and you just want to draw them lots of times with different transforms (e.g. different XYZ locations or different scales) then you definitely want to look into the Instancing SDK sample and read the associated paper.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Quote:Original post by pOtrek
to build my own buffers but i was wondering if i can use methods like SetVertexBufferData() and SetIndexBufferData().
You can't tell it to use certain buffers. It will always create its own buffers, and you can simply copy data over.
Quote:And finally how to get information about type of data stored in mesh object (triangleListm triangleFan ,ect.) becouse it's necessary in DrawIndexedPrimitives() call ?
Mesh always uses indexed triangle lists.

It sounds like you're probably on your own. I guess it's conceivable that you could use the subset functionality to pull this off somehow, but I'm not sure of the details.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.

This topic is closed to new replies.

Advertisement