Array of Verticies

Quick question. If i have all of the verticies of a sphere saved in an array how would I know which vertex is which in the array? For instance, if I had say the vert at the top of the sphere how could I get all the ones on the circle around it from that array? [ say the top vert is vertex[0] would the ones around it be vertex[1], vertex[2] . . . etc or more like vertex[0] vertex[23] vertex[45] etc etc] and documentation would be helpful.

There is no simple way.

You have to, quite simply, look at every other vertex, see where it is, and make your decisions based on that.

You are probably thinking that the rendering pipeline, or perhaps the physics system, “has this information” in some way. unfortunately that is absolutely not the case. There is a huge discussion about it here:

I urge you to download the attached demo programs, example models, and so on.

There is also a very important point: there is a common misconception among people new to fooling with 3D models that in some sense verts “must not be” or alternately “must be” shared-where-possible. This is utterly incorrect, as explained at vast length on that page.

(If you have not yet reached the point of knowing about shared verts - bear it in mind for the future!)

Anyway in answer to your very specific question:

#“so there’s no order at all to how it makes the index?”

that is absolutely correct: there is absolutely no order - whatsoever - at all - to the vertices in a 3D model.

#“is there another way to get nearby vertices?”

again correct, there is absolutely no way, whatsoever - at all - to get nearby vertices. you may find this strange if you’re new to the topic, but it’s true.

prepare to loop a lot :slight_smile:

Note that if you spend your life working with the mesh, it becomes hugely about spatial hashing … systems for you to essentially speed up the process of finding verts in certain physical areas. For now, just loop and measure the distance :slight_smile:

Many systems completely avoid this problem by storing the model conceptually in a totally different manner - our italian friends at meshlab for example more or less work on half-edges for example, not triangles. But the answer to your question is no, you just have to loop, loop, loop.