imagine a Sphere, for example an icosahedron at first depthlevel with 80 triangles. I’ve built that icosahedron from scratch - means I’ve generated it, not loaded it as a mesh. The normalvector to the center of each triangle is stored in a std::vector called grid.
What I want is the icosahedron to be my planet and each triangle to be a cell on it. Every cell has three neighbours, one for each edge. Is there an easy way to find out about the neighbours of each triangle / normal in std::vector? The direction is important: I want to know which neighbour is left, right, up and down.
I already found the three neighbours at first depthlevel (80 triangles), but one level higher (320 triangles) my method fails: I tried to measure the angle between the normals (about 19 degrees at first level) but it varies too much. In the end I nead the information for depthlevel 4 minimum.
Since you’re generating the triangles, you can store all of the required adjacency tables yourself, right? Other than doing that, there’s no easy to way to ask for adjacency information in a GeomVertexData.
Thank you one more time, David!
Fact is that I need a more detailed icosphere with more than 1000 triangles. The algorithm I implemented uses recursion to subdivide the triangles into four new ones each step. the problem about it, is that I know the three neighbours of the triangle in the center of the old triangle, but to find the neighbours to the other three triangles I have to step back in recursion - thats crazy!
I heard about a method in computergraphics, where vertices in a primitive, for example an icosahedron, are sorted in a way, that one vertice connected to the next vertice in the list builds up a new triangle. that would be some kind of visible neighbourhood. unfortunately our prof hasn’t gone into details. did you hear about it?
After you have made one subdivision pass, turning N big triangles (whose neighbors you knew) into N * 4 little triangles, you can go back and compute the neighbors of each of your N * 4 little triangles using the neighborhood relationship you remember from the big triangles. You don’t have to recurse all the way back for this, just back one step. Then you can update the adjancy graph with this new information.
Each time you repeat the subdivision pass, again you only have to go back one step to get the previous neighbors.
Of course, a big recursive algorithm would work too.
Thank you guys! I’ll try davids way, my problem seems to be too complicated thinking…