Some code I made for creating an icosahedron based on this article: catch 22 - Andreas Kahler's blog: Creating an icosphere mesh in code. I hope this helps you alot, I’m still kinda new to posting interesting stuff on the Devforum and would appreciate any feedback.
local t = (1+math.sqrt(5))/2;
local icosahedronVerts = {
Vector3.new(-1,t,0),
Vector3.new(1,t,0),
Vector3.new(-1,-t,0),
Vector3.new(1,-t,0),
Vector3.new(0,-1,t),
Vector3.new(0, 1, t),
Vector3.new(0,-1,-t),
Vector3.new(0,1,-t),
Vector3.new(t,0,-1),
Vector3.new(t,0,1),
Vector3.new(-t,0,-1),
Vector3.new(-t,0,1),
}
local icosahedronTris = {
{1,12,6},
{1,6,2},
{1,2,8},
{1,8,11},
{1,11,12},
{2,6,10},
{6,12,5},
{12,11,3},
{11,8,7},
{8,2,9},
{4,10,5},
{4,5,3},
{4,3,7},
{4,7,9},
{4,9,10},
{5,10,6},
{3,5,12},
{7,3,11},
{9,7,8},
{10,9,2},
}
local function Generate()
local Part = Instance.new("MeshPart",workspace)
Part.Name="Icosahedron"
Part.Anchored=true
Part.Position=Vector3.new(0,10,0)
Part.Size=Vector3.new(4,4,4)
local EditableMesh = Instance.new("EditableMesh")
for i=1,#icosahedronVerts do
EditableMesh:AddVertex(icosahedronVerts[i])
end
for i=1,#icosahedronTris do
EditableMesh:AddTriangle(icosahedronTris[i][1],icosahedronTris[i][2],icosahedronTris[i][3])
end
EditableMesh.Parent=Part
return Part,EditableMesh
end
Generate()