I am trying to create multiple BoundingBoxes
on a Model
by following this tutorial:
https://electronicmeteor.wordpress.com/2011/10/25/bounding-boxes-for-your-model-meshes/
However, I keep getting this error: Requested range extends past the end of the array.
on this line:
part.VertexBuffer.GetData(part.VertexOffset * stride, vertexData, 0, part.NumVertices, stride);
I can't figure out why it is giving me that. I load my model and try to create the boxes like this:
Model model = this.Content.Load<Model>("Cube");
MeshModel box = new MeshModel(model);
Instead of passing a String
path of the model, I just pass the Model
itself (I changed the constructor to accept Model model
).
Any help would be appreciated!
Here's what the debugger says (the vertexStride
and VertexBuffer
has 24
which is the same size as the vertexData
so it should be ok):