I'm working on generating a planet made out of a hexagon grid. The poles aren't needed - making this a bit easier. Is there a better way to turn the cylinder into a sphere that would have uniform hexagons/triangles?
Here's the desired steps:
- Generate a 2D plane of hexagons (ok)
- Turn the plane into a Cylinder (ok)
- Turn the Cylinder into a Sphere / Geosphere (kind of works)
For step 2, I'm just using Sin and Cos to move the vertices into a circular shape.
For step 3, right now I'm just using: vertices[i] = vertices[i].normalized * radius;
Image to visualize the problem as it is currently.
Note that the poles are cut off on purpose. The red parts show what one hexagon mesh looks like. I would have to keep them roughly the same size and orientation since they are used for gameplay and visual elements. Each hex has a list of neighbors and works like a graph basically.
Instead of cylinder to sphere mapping I would do a sphere triangulation...
I would first start with 2 hexagons
each start at pole and end on the equator or do the half only and mirror the other when all done...
then recursively subdivide the triangles
so divide lines to half and change the mid point coordinate to align with sphere surface. This will create triangulated sphere. Subdivide to valid number of points to form hexagons and have enough grid points.
change the hexagon mid-point coordinates back to plane of hexagon
So take the other 6 point and compute average coordinates which gives you the point for middle ...
Something like this:
for more ideas look here:
[edit1] triangulation (no hexagon corrections)
Was a bit curious so I tried to encode this usage is simple:
So here is the result overview
top and bottom poles looks good enough, some distortion is present along the equators but partially it can be caused also by fish-eye. If the initial shape is feed with closer to wanted result start geometry then it may have much better results