The end goal is to get a table of “central vertices” where the neighbor of each central vertex cannot be a central vertex – AKA creating chunks on an icosphere that are hexagonal or pentagonal
I have attempted using the following code:
function generator:return_centers(adjacency_map)
local centers = {}
local is_neighbor = {}
for vertex, neighbors in adjacency_map do
if not is_neighbor[vertex] then
table.insert(centers, vertex)
end
for _, n in neighbors do
is_neighbor[n] = true
end
end
return centers
end
Which gives me inconsistently spaced center vertices
I understand that the geometry of the icosphere does not allow for perfect chunks, but there is something obviously wrong here. And I seriously need help since I’ve tried many different ways and none of them gave me the end result I wanted.
Maybe some of the chunks you are generating are actually triangle shaped? There’s nothing forbidding the creation of a polygon which isn’t a hexagon or pentagon.
If it helps you could generate polygons around the center points (composed of triangles) and color code them to visualize what your script is doing.
On the off-chance you are trying to make a terrain generator then I’d suggest just using a 3d grid of cubic chunks.
My bad, don’t think I’ve specified. I’m basically trying to create a hex sphere, or rather hex table chunks on a sphere, and I’ve noticed that the algorithm kind of randomly places points which doesn’t allow for uniform coverage of the sphere.
EDIT: Not particularly a terrain generator, rather just messing around with editable meshes