Thane_1Join Date: 2009-04-08 Post Count: 3406 |
I made a script for it, you can have it. Look at the bottom of it, the number on line 114 is the amount of sides you want on your pyramid, keep the bool values set to false. Make a part in workspace named "Part1" and change it's size to whatever you want, then run this script in the Command Bar. Remember, 2 sides of Part1 need to be the same, like (5,10,5) or (4,12,4).
local NumberWords = {"Pent","Hex","Hept","Oct","Non","Dec"}
function GenerateWedge(Sides,Diamater,Height,Cframe,Reverse,In,AdjustAngle)
local Sided = {}
local LastAdj
for a = 1,Sides do
table.insert(Sided,nil)
end
if Sides >= 3 then
local SideLength = Diamater*(math.tan(math.pi/Sides)) --(2Radius*tan(pi/#sides))
local Thickness = Diamater/2
local Model = Instance.new("Model")
--print("NumberWords: "..
Model.Name = "Cone"--"Cone"..tostring(#NumberWords >= Sides-4) and NumberWords[Sides-4].."agon" or Sides.."agon"
for Side = 1,Sides do
local SideModel = Instance.new("Model",Model)
SideModel.Name = "Side"..Side
local Part = Instance.new("WedgePart",SideModel)
Part.FormFactor = "Custom"
Part.BottomSurface = "Smooth"
local Negate = Instance.new("Part")
Negate.FormFactor = "Custom"
Negate.BottomSurface = "Smooth"
Negate.Name = "Negate"
if Thickness < 0.2 or Height < 0.2 or SideLength < 0.2 then
local Mesh = Instance.new("SpecialMesh",Part)
Mesh.MeshType = "Wedge"
Mesh.Scale = Vector3.new(math.min(1,SideLength/0.2),math.min(1,Height/0.2),math.min(1,Thickness/0.2))
Part.Size = Vector3.new(math.max(0.2,SideLength),math.max(0.2,Height),math.max(0.2,Thickness))
Negate.Size = Vector3.new(math.max(0.2,SideLength),math.max(0.2,Height),math.max(0.2,Thickness*2))
if not LastAdj then
--LastAdj = (math.max(0.2,SideLength)/2) / (math.max(0.2,Thickness))
LastAdj = math.atan(math.max(0.2,Thickness) / (math.max(0.2,SideLength)/2))
end
else
Part.Size = Vector3.new(SideLength,Height,Thickness)
Negate.Size = Vector3.new(SideLength,Height,Thickness*2)
if not LastAdj then
--LastAdj = (Thickness) / (SideLength/2)
LastAdj = math.atan((SideLength/2)/Thickness)
end
end
print(math.deg(LastAdj))
local Ang = math.rad((360/Sides)*Side)
local Ang2 = math.rad((360/Sides)*(Side+1))
local Ang3 = math.rad((360/Sides)*(Side-1))
Part.CFrame = Cframe * CFrame.Angles(0,Ang,0) * CFrame.new(Diamater/2-(Thickness/2),0,0) * CFrame.Angles(0,math.rad(-90),0)
Negate.CFrame = Cframe * CFrame.Angles(0,Ang3+math.rad(90)+LastAdj,0) * CFrame.new(SideLength/2,0,Thickness/2) --* CFrame.Angles(0,0,0)
local Negate2 = Negate:clone()
Negate2.CFrame = Cframe * CFrame.Angles(0,Ang2+math.rad(90)-LastAdj,0) * CFrame.new(-SideLength/2,0,Thickness/2) --* CFrame.Angles(0,0,0)
if Side == 1 then
Sided[Sides] = Negate
Sided[Side+1] = Negate2--
elseif Side < Sides-1 then
Negate.Parent = Sided[Side-1]
Sided[Side+1] = Negate2--
Sided[Side].Parent = SideModel
Sided[Side+1] = Negate2--
elseif Side == Sides-1 then
Negate.Parent = Sided[Side-1]
Sided[Side].Parent = SideModel
Sided[Sides] = {Sided[Sides],Negate2}--
elseif Side == Sides then
Negate.Parent = Sided[Side-1]
Negate2.Parent = Sided[1]--
Sided[Side][1].Parent = SideModel
Sided[Side][2].Parent = SideModel
end
Sided[Side] = SideModel
end
return Model
end
end
function ConvertWedge(Part,Sides,In,AdjustAngle)
local Rotation = CFrame.Angles(0,0,0)
local Height,Diamater
local Size = Part.Size
for _,Child in pairs(Part:GetChildren()) do
if Child.ClassName == "SpecialMesh" or Child.ClassName == "BlockMesh" or Child.ClassName == "CylinderMesh" then
Size = Size * Child.Scale
end
end
if Part.Size.X == Part.Size.Z then Rotation = CFrame.Angles(0,0,0) Height = Part.Size.Y Diamater = Part.Size.X
elseif Part.Size.X == Part.Size.Y then Rotation = CFrame.Angles(math.rad(90),0,0) Height = Part.Size.Z Diamater = Part.Size.X
elseif Part.Size.Z == Part.Size.Y then Rotation = CFrame.Angles(math.rad(180),math.rad(0),math.rad(90)) Height = Part.Size.X Diamater = Part.Size.Z
end
if Diamater and Height then
local Model
if not In and not AdjustAngle then
Model = GenerateWedge(Sides,Diamater,Height,Part.CFrame * Rotation)
elseif In and not AdjustAngle then
Model = GenerateWedge(Sides,Diamater,Height,Part.CFrame * Rotation,In)
elseif In and AdjustAngle then
Model = GenerateWedge(Sides,Diamater,Height,Part.CFrame * Rotation,In,AdjustAngle)
end
for _,Piece in pairs(Model:GetChildren()) do
if Piece:IsA("BasePart") then
Piece.BrickColor = Part.BrickColor
Piece.Material = Part.Material
Piece.CanCollide = Part.CanCollide
Piece.Anchored = Part.Anchored
Piece.Transparency = Part.Transparency
Piece.Reflectance = Part.Reflectance
end
end
Part:Destroy() --Get rid of old part
return Model
else --Didn't work
return "[ Error: For some reason the shape could not be converted ]"
end
end
local Shape = ConvertWedge(game.Workspace.Part1,9,false,false)
Shape.Parent = game.Workspace
|