Simple sloped building roof between two walls problem

Hi!

I’m trying to create sloped roof for building. There are two walls with different heights. I was looking for some solutions to implement roof slope but none of them worked well.

The only solution that “almost worked (!)” is roof mesh “rotation” solution to fit roof slope to two walls. As you can see the solution is not the best and it’s simply not working right now.

Playground: https://playground.babylonjs.com/#7P3QO9#24.

Working on that for five days and I’m stucked :frowning: There are going to be more complex visualisations in the project and even this simple one does not make sense.

Perfect solution to me would be to provide starting and ending Vector3 vectors as left and right borders of the roof, so the slope would fit ideally.

Can you please help me with that? Fixing my playground code or having some better ideas to create sloped roof between walls are highly appreciated :slight_smile: Thank you in advance!

1 Like

Hi!

        const roofSlopeRadians = -Math.atan2( h, LENGTH)

where h = differenceBetweenWallHeights and LENGTH = distance between walls

You would want to calculate the size if the roof not set it as param. Pythagoras.It will fill the gap between the higher wall and the roof.

2 Likes

I couldn’t sleep so:

3 Likes

Roland, you are awesome! Second solution work like a charm (it does even more than I asked for :slight_smile:). I owe you a very good beer! :slight_smile:

Glad to help you! :wink:

Just click :smiley:

1 Like