stravant wrote the original triangle fill code that most if not all triangle fill plugins use in some fashion:
local function setupPart(part)
part.Anchored = true
part.FormFactor = 'Custom'
part.CanCollide = PolyDraw.CanCollide
part.BrickColor = PolyDraw.BrickColor
part.TopSurface = 'Smooth'
part.BottomSurface = 'Smooth'
end
function CreateTriangle(parent, a, b, c)
local this = {}
local mPart1 = Instance.new('WedgePart')
setupPart(mPart1)
local mPart2 = Instance.new('WedgePart')
setupPart(mPart2)
function this:Set(a, b, c)
local ab, bc, ca = b-a, c-b, a-c
local abm, bcm, cam = ab.magnitude, bc.magnitude, ca.magnitude
local edg1 = math.abs(0.5 + ca:Dot(ab)/(abm*abm))
local edg2 = math.abs(0.5 + ab:Dot(bc)/(bcm*bcm))
local edg3 = math.abs(0.5 + bc:Dot(ca)/(cam*cam))
if edg1 < edg2 then
if edg1 < edg3 then
else
a, b, c = c, a, b
ab, bc, ca = ca, ab, bc
abm = cam
end
else
if edg2 < edg3 then
a, b, c = b, c, a
ab, bc, ca = bc, ca, ab
abm = bcm
else
a, b, c = c, a, b
ab, bc, ca = ca, ab, bc
abm = cam
end
end
local len1 = -ca:Dot(ab)/abm
local len2 = abm - len1
local width = (ca + ab.unit*len1).magnitude
local maincf = CFrameFromTopBack(a, ab:Cross(bc).unit, -ab.unit)
if len1 > 0.2 then
mPart1.Parent = parent
mPart1.Size = Vector3.new(0.2, width, len1)
mPart1.CFrame = maincf*CFrame.Angles(math.pi,0,math.pi/2)*CFrame.new(0,width/2,len1/2)
else
mPart1.Parent = nil
end
if len2 > 0.2 then
mPart2.Parent = parent
mPart2.Size = Vector3.new(0.2, width, len2)
mPart2.CFrame = maincf*CFrame.Angles(math.pi,math.pi,-math.pi/2)*CFrame.new(0,width/2,-len1 - len2/2)
else
mPart2.Parent = nil
end
end
function this:SetProperty(prop, value)
mPart1[prop] = value
mPart2[prop] = value
end
this:Set(a, b, c)
function this:Destroy()
mPart1:Destroy()
mPart2:Destroy()
end
return this
end
If you want to recreate the features that a specific plugin has, look into its code to see how its modified stravant's fill.
1 comment
...which you can do by going to C:\Users\user\AppData\Local\Roblox\InstalledPlugins, look at all of them (the folder names are random), and open the rbxm.