How do you get proper indices for vertices?


This is how I obtain indices and vertices but the indices all go from 0 → max they dont repeat the numbers? When I try to use them to access the vertices the index is out of range.

image
I think this is how I should do it instead.

EDIT:
I face the same issue getting them like this the problem is not solved.

Well find out how many you have and maybe at the second loop instead of indices>num excetera just imput a number limit/

< indices->num(); i++) is not obligatory, you are saying to count all the indices and you got a pointer to the Num() , the function I take it gets the number of the total indices so “i” counts all of them.
Trying replacing "indiced->Num(); with a number, but you have to find out the limit number so you don’t go above that, so you are not out of range and get the same error.

You just add then to the array with your array.add the number from the loop, you got the “i” in the add definition to know how many times it adds from the loop. Indices are just “integer numbers” I take it in this case.

You are adding how many indices are there, total number of indices, or you are adding indice numbers ,213, 142, 123 and so on.

You can do the same with vertices, do you have a section, where you dump the array data ?

Also make notice to use the pointer version of vertex possition buffer when you specify it first. “Your vertex buffer = VertexBuffer* yourvertexbufferobject” I see a buffer for indices where is your buffer for possition vertex. The indices is the type of “Int” I take it and the PossitionVertexBuffer is what in this case ? an Fvector ? So where is the pointer for PossitionVertexBuffer. The vertices are not the indices. The indices are used to plot between the vertices, the vertex possition is a coordinate of vectors ? X,Y,Z.

1 Like

I dont fully understand, cus it seems like the vertex array has the same size as the index array.

The number of trianlges in the mesh is around 7000, so the number of indices should be 3 times that but it says the number of vertices is the same amount.

Because maybe your indice buffer is your vertex buffer and you do not have a vertex possition buffer just a indice index buffer with vertice indices.

You need two buffers, probally why they are the same because you are looking at the same buffer maybe. Where are you getting your data from inside the buffer. The manechine mesh ?

From what I see you are missing the PossitionVertexBuffer and it’s pointer address, you got a sintax with it inside your loop but you first need to declare that with a pointer address to load buffer into memory.

You have two buffers, 1 is the indice the other is the possition.
These buffers you load the mesh into them, then the buffer gets loaded into the arrays, from the statement you have in the loop with “array.add”. I take it “data” is the mesh value from the declaration of your indice buffer but where is the one with possition. Is waterplane your vertex possition buffer mesh data ?

You are missing components probaly, you need a static mesh variable , then the variable gets loaded into the two buffers. If I were you I would try to put everything into one loop, there is no connection between the loops, the vertex buffer I used had everything into one loop and when I tried to make it with two loops for texture cords it did not work.

Also note you can have fewer indices and more vertex points, if you display less indices it’s just going to draw partially to the point where you inserted the indices and rest of the mesh will not be displayed. At least this is the case with the most of this stuff landscapes, pmc, rmc and so on.