The problem of meshcollision

Mathematics using information from the boundingbox find the center, width, height and depth of the boundingbox

For two meshes, meshA and meshB when
centerA.y > centerB.y meshA is above mesh B

when meshA is above meshB and Math.abs(centerA.x - centerB.x) < a limit and Math.abs(centerA.z - centerB.z) < a limit then meshA is directly above mesh B

when meshA is directly above meshB and centerA.y - centerB.y = (heightA + heightB) / 2 then meshA is touching meshB

A playground to illustrate https://www.babylonjs-playground.com/#MECK03#2

Is that what we call a touch? Just go ahead and figure out where the bounding box is. Is that right

In this playground https://www.babylonjs-playground.com/#MECK03#3

green and red touch
blue and yellow are not touching

purple and black intersect

Yes


I’m sorry I didn’t understand when I was loading the model, this callback, it returned 0 and 1, right, so I should also get the bounding box information of 1, right

Yes as in this playground https://www.babylonjs-playground.com/#QY1WYT#104

Use the inspector to check out the nodes

You can use the inspector in your own projects scene.debugLayer.show();

https://doc.babylonjs.com/how_to/debug_layer

Thank you very much!Yesterday I saw you gave me the calculation way, imagine I have ABCDE five squares, later, when I selected the starting square A should have A variable gain to block A bounding box of the information, then you should have A variable gain is the boundary of the block B, C, D, E frame information, and then two to compare and determine which block the Y axis is in the upper part of A square, and then choose to hide them

2 Likes

@Wingnut
SorryI need you help!
There are two sets of models in my PG. When I select a set of models, they will be hidden together with the second set of models. This is not what I want. My purpose is to select which set of models to hide only the top of the selected model. model
https://playground.babylonjs.com/#U8MEB0#59

Oh, sorry ranwei… I was enjoying 4 days of boat racing on a nearby lake. Have you made progress?

I HOPE so… because I am still confused about goal. Perhaps this problem is too advanced for me.

No, this is a little bad, I don’t know how to do
https://www.babylonjs-playground.com/#3M7Q1U#26

My function is that when I click on the first set of models, it will only hide all the models above the currently selected model, instead of hiding the other set of models
https://www.babylonjs-playground.com/#3M7Q1U#22
This is my original example. There are two sets of models, building one and building two. When I click on the model of building one, he will hide the model of building two


  • This is my answer@RaananW , but I don’t quite understand

Please stop opening THOUSANDS of threads. Keep the one you have and try to do your homework. The community will not create the code for you.

Create a simple repro in the playground with the MINIMAL amount of code. We do not want all your code. Just the problematic one.

Please do this or I will delete all your threads.

Sorry!I can’t delete all my content, it takes 14 hours to delete it again, so please close all my content, I just need help from others, but no one replied to me

It is ok to keep what you already opened. No worries. But just stop opening more

And please: Create a simple repro in the playground with the MINIMAL amount of code. We do not want all your code. Just the problematic one.

it’s no porblem

I know of at least 4 people, including me, that have replied to you. Unfortunately you do not make what you want to do clear to us and so I stopped answering.

The picture has made things clearer I hope. I am giving you one method that gives one way to do what the picture says.

It is all about how you structure the data that describes your scene. A separate building needs separate code. If the same type of thing is happening to different building you could use a function to act on the different data.

I know, I have been perfecting the pseudo code that you and Raanaw gave me. When I still encounter new problems, it makes me confused. In the scene, I let the model know which layer he is, whether it is group A or B. Group building, but when I click on the model, I get the mesh object, I can’t get its floor and build, and the method you told me before can only be used in scenes with less buildings. My project will load different models because of different models. Some may have one or twenty buildings. If each model is filled with floor array, it will take a lot of time, And, when I don’t know how many sets of models I should add, I can’t use this way anymore.https://www.babylonjs-playground.com/#3M7Q1U#31

With some thought you can adapted it, good luck.

1 Like

https://www.babylonjs-playground.com/#2EHGYF#10

I am testing “toggle all layers above picked layer”, there.

It uses multi-pick ray, shooting upwards from picked mesh. It works with ANY number of layers.

But… do we need to remove “top” of layer (with a click) so we can look at furniture inside? :slight_smile:
If need to look inside layer, then… hmm. More difficult. Maybe right click… not sure.

Maybe I am FAR off-topic… but I still wanted to test up-aimed multi-pick Ray, for learning.