Calculating Corners Between separate wall meshes

I’m Currently following the Build House From plans documentation

in my case I need each set of points to build a separate wall mesh, knowing that the " baseData" array will contain a set of points

Build Walls separately | Babylon.js Playground (babylonjs.com)

in my playground line 641 when I switch the value of ( interior: true ) , it builds the walls but it doesn’t build the corners properly

also if I switch the interior : false , it builds walls connected but not the correct density (width) of the wall


Screenshot 2022-05-04 035418

This playground is quite extensive, so it will be hard for me to find the right point, but it does feel like since you added depth to the walls you need to add this depth to the length of the wall, otherwise the corners will not be visible. As this might lead to z-fighting over the two walls colliding, it might be better to make only two of the walls longer, or actually add corner meshes in the depth of the thickness of the walls, but you will have to experiment with that.

If you want individual walls then it would be much simpler to build each wall as a box of the required size or, if you want windows, doors or angled corners, with CreatePolygon.

2 Likes

Indeed, this doesn’t make sense. In fact, thinking of it, it doesn’t make sense in real world/architecture. Either you make 2 walls facing longer (including the corner/depth of the side walls) and the 2 others smaller (or you eventually alternate) with each wall having the next ‘corner’ included in its size and of course excluding the other side (which is made by the other wall). Else, you would add pillars to each corner.

Edit: And then, there is a huge amount of code in this PG for virtually nothing. Although not very sexy (in terms of maths and choice of vars), I quickly rushed this one for you so you can compare:

I could actually have created the duplicate walls with instances or clones, since they are the same. Interested? Look in the doc for 'createInstance()’

1 Like

Huge amount of code for proper corner calculation and applying texture? Also, external wall and internal wall must have different material applied to it. Check screenshots above.

Your PG:

PG from babylon doc:

1 Like

Apologies (no offense) but it’s the first time we see this. Indeed, this house looks much better and there is more to it :smiley: It actually looks good. A neat little house (near the beach may be? :sunglasses:
I told ya my PG was just rushed (in 10mn and then, based on your box example).
I still maintain there’s too much code even to build this version.
You can use wrapping and faceUV. You can also merge meshes and construct with single or multimat.
As explained by @JohnK, you can use CreatePolygon with holes for your walls with windows.
There’s plenty to do with less effort and less code (my opinion only)

Edit: Unless of course you are building an editor or creating a serie of dynamically built houses (or procedural)? In case, my apologies (again :pleading_face:) But if so, please be a bit more specific towards your needs. It will help us give a better answer (if we are qualified). Clearly, I’m not qualified for the editor :dizzy_face:(but in case, others in this forum could help)

Thank you all for your help, I Have found the solution with the help of Naznarok

2 Likes