How to approach making a "roof system"

How can I make something like this possible?

A roof system from bloxburg:

As you can see, they are somehow placing models and scaling them to fit the rectangular shapes within this house. For visualisation (warning, art was never apart of my strong side): Untitled

My guess is that what is happening, it is finding all touching “nodes” at the end and start of each wall and when 4 nodes are touching, they group the parents of that node to form a room. Next step is where I am stumped. How is it drawing out the shapes (different sizes of rectangles) to fill the area surrounded by the walls?

Further videos for reference:
https://i.gyazo.com/aa333a93d87f6eb92b118baa0aa1df0c.mp4

3 Likes

Pseudocode that will probably give a nice result:

parts = {}
while has empty space do
    add findLargestRectangle(empty space) to parts
    remove rectangle from the remaining empty space
end

For find largest rectangle the Google search you want is “find largest rectangle in matrix”, it’s a classic algorithms problem in computer science so there are many pieces of sample code out there for it.

That will give you a few large sections and some small details joining the large sections together, which is the structure that real examples tend to have.

5 Likes

So I figured out what I had to do (I know it is late lol).

I’d place nodes at the top of each of my wall and then use some for loop to get the nodes nearby to finally draw some triangles. :roll_eyes: Was a lot to learn.

2 Likes

Could you help me with this system, please? I’m trying to make a roof for a dodecagon.

Could you help me with the same system?