- Home /
Hexagonal Grid mesh issues
Hi, I am trying to create a hexagonal grid for my terrain mesh. I started out by creating my vertices, so that the first vertex ( vert[0] ) is set at a starting point, vert[1] to vert [6] in the first 'onion shell' vert[7] to vert[18] in the next and so forth. A fairly easy implementation.
However now I need to create the triangles and this is where i run into a wall, since there is no obvious system of which index numbers should make up the triangles.
My first idea was to use a Dictionary too keep track of what vertex was on a given set of coordinates. However as I started to implement this, and later did some googling on the idea, I found that using a Vector3 as a key for a dictionary is not recommended, and i kept getting "KeyNotFound" despite that key being present in the dictionary.
I then tried to use Hexagonal integer coordinates and Vector3Int, however I kept getting that some Exception.
So after 2 days trying to solve the issue, I come here begging for help
Do anyone have an idea of how I can keep track of what vertex is on a given position? Or another approach worth considering?
One more thing: I need a method to identity the Center Verticies (0,8,10,12,14,16,18,19) and so forth, I can't figure out an equation that will give me the sequence. How would one go about that problem?
Thank you in advance
/mikael