Quantcast
Channel: Community | MonoGame - Latest topics
Viewing all articles
Browse latest Browse all 6821

Weird results when trying to extract data from index buffer...

$
0
0

@Optmisitic_Peach wrote:

I'm trying to create a list of vertices from a model I load. I first load the model, then loop through meshes and then mesh parts and finally check if it's using the index buffer.

When I check if it's using the index buffer, I use this:

if (MeshPart.IndexBuffer != null)
{
        if (MeshPart.IndexBuffer.IndexCount <= 0)
        {
            throw new Exception(); // This may be in error, I'm not sure how monogame handles this...
        }
        //Use the indices here
}

When I use this method, I then extract the indices like so:

int[] Indices = new int[MeshPart.IndexBuffer.IndexCount];
MeshPart.IndexBuffer.GetData(Indices);
foreach (var b in Indices)
{
    Vertices.Add(VertexArr[b]);
}

Unfortunately I get illogically large numbers as "indices" like:


This happens even though my vertex buffer's # of vertices is 108.

How would I properly use the index buffer and check if I should use it?
Thanks!

Posts: 3

Participants: 2

Read full topic


Viewing all articles
Browse latest Browse all 6821

Trending Articles