Jump to content
  • Advertisement
Sign in to follow this  
pOtrek

[MDX] Meshes sharing the same Vertex and Index Buffer

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

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 ?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 ?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

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!