Help with Fortunes Algorithm

Hello, I am currently working on a breakable glass system and I had this idea on how to make but I need a bit of information before jumping into coding it. (the system is utilizing fortunes algo to detect where the wedges would be)

What I’m facing is that I don’t know how I can implement it into lua and go about getting points on a parts to utilize the algorithm,

If there’s any solution/idea I would love to hear it! :grinning_face_with_smiling_eyes:

1 Like

It’s not very clear what you are trying to do. But if you are trying to position parts you should use the parts CFrame which contains the position and rotation of a part.

Yes, but how would I a few points on a single basepart utilizing CFrame.

Sir I don’t understand what that means.


I suggest you learn how the 3d space works and learn Positions and CFrames.

Why don’t you watch this tutorial:

What Is CFrame? | Roblox CFrame Tutorial | LookVector, Angles & More! - YouTube

In Fortunes algorithm you would have points that would calculate the distance between them and fill the area between those pixel points
image
I am saying how I can do this in a 3D workspace unlike the 2D workspace shown in the image.

I’m not aware of Fortunes (is that a game?)

I’m not sure what you mean by “fill” but if you want to draw a line between 2 points you can do

local middlePoint = part1.CFrame:Lerp(part2.CFrame,0.5) -- using :Lerp to get the middle point between the parts

local length = (part1.Position - part2.Position).Magnitude -- using subtraction to get the length

linePart.CFrame = CFrame.lookAt(middlePoint,part2.CFrame.Position) -- using CFrame.lookAt so it has the correct orientation
linePart.Size = Vector3.new(1,1,length) -- setting the size to "length" on the z axis

if there are multiple points you can make multiple lines


“filling” a 3d space is much more complicated and would require a lot of resizing of parts and triangles and stuff.

Fortunes algorithm isn’t a game and there is actually a lot of information on it.

2 Likes

The points you’re talking about are chosen arbitrarily, you need to generate them yourself randomly by treating the face of the part that you’re trying to break as a plane. Just pick a face and go to town!

Here’s an example for the top or bottom face of a part.

local points = {}
for i = 1, 10 do -- make 10 points
	points[i] = Vector3.new(
		Part.Size.X * math.random(),
		0, -- doesn't matter what the Y value is, we only care about 2 dimensions
		Part.Size.Z * math.random()) 
	
end

Now you run Fortune’s algorithm on the points table.

2 Likes

Thank you for giving context as to what the OP was talking about, since I did not know this I was pretty confused on what the OP wanted.

1 Like