Reputation: 275
So, I'm kinda lost. For the game I'm working on, I want to make the 'world' a geometric dome (sphere made of equilateral triangles). In order to generate the world and play the world, I need to find a way to save all the edges and vertexes and be able to calculate neighbors. I'm unsure how to save all of the different vertexes and edges in a way that you could easily figure out which points neighbor each edge and which edges neighbor each point. What methods could I use to accomplish this?
Upvotes: 0
Views: 122
Reputation: 7946
There are many ways to do what you ask. Wavefront OBJ files store the coordinates of each vertex as an indexed list, and then define each face as and cycle of vertex indices clockwise around the face normal.
I don't like this because you have to do processing to figure out certain aspects of connectivity. For a triangle mesh as you are describing, I prefer to store the vertices, and their 1-ring. The 1-ring are the indices of the adjacent vertices clockwise around the vertex.
Doing it this way allows you to move from triangle to triangle much easier. If for vertex V you have it's 1 ring (v1, v2, v3, v4), then you immediately know it's on triangles (v, v1, v2), (v, v2, v3), ..., (v, v4, v1). for example.
This blog post goes into more detail: http://bluntobject.wordpress.com/2007/03/13/mesh-data-structures-vol-2-vertex-one-rings/
If a vertex is on the boundary or is non-manifold, you don't have a complete 1-ring. I handle this as a list of partial 1-chains.
Upvotes: 1