سؤال

I have a model file containing multiple meshes (ie: a tree, a car, ...) that is used as a static background for our game. My goal is to store the model's vertices and indices as two buffers and assign these buffers to the GPU. However, I'm a bit confused on the way to go.

This Riemer's XNA Tutorial states that the model itself has a one big vertexbuffer and one big indexbuffer containing informations of all its meshes (and meshparts), but it doesn't seem possible to access these buffers. However, it is possible to access the ModelMeshParts' buffers, but I can't concatenate all of them into a single buffer.

My guess would be to extend the model processor to store the model vertices and indices in arrays at runtime. Is there an easier way to do so, since Riemer says that those buffers are already defined? I'm confused about that statement.

Thank you for answering.

هل كانت مفيدة؟

المحلول

Actually, there is only 1 vertex buffer and 1 index buffer for the entire model. The Vertex buffer that is exposed in any ModelMeshPart is the entire model's vertex buffer and it is the same buffer that is exposed in any other MMPs. No need to concatenate them, the entire buffer is in each MMP.

Each MMP has its own start index of that buffer and each MMP has its own variable that describes the number of vertices that are consecutive from the start index that are used for that particular MMP.

enter image description here

So in this diagram of the model's VB, ModelMesh[1]->ModelMeshPart[1] has a start index of 300 and its number of vertices is 75. So this way, when drawing the MMP, the device knows to use only those few vertices of the entire VB.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top