The problem of meshcollision

this is my scene model, I need to implement a function is the scene of linkage, when I click on a certain floor, he should go to judge me under the current floor had collision model and which model (because of my lower floor also allows drag model) of the upper floor, then go to upwards to find know no collision model, and finally the currently selected floors high than I did in those models is hidden;So I want to ask you, what should I do


Hi ranwei. When you say “collision”, maybe you mean “picking”? IF SO, maybe you could use scene.multiPick. It returns array of ALL things hit with pick… then you decide which mesh is selected/picked.

Maybe layerMasks, maybe renderingGroups. Your building has layers, right?

Perhaps, when you hide something, use mesh.setEnabled(true/false) and not visibility/alpha.

I don’t understand your post very well, so I am giving general advice. I’m not sure if you REALLY mean “collision” or if you REALLY mean “picking”.

If picking problem, check multiPick and multiPickWithRay. If multiPick returns array.length > 1, then multiple things were picked (in picking-depth order), and you need to decide WHICH picked mesh is the desired picked mesh.

Also, maybe you want to set bottom floor isPickable = false… IF upper floor is blocking/unhidden. Then when upper floor is hidden, re-set lower floor isPickable = true, to allow bottom floor dragging again.

Careful layers/renderGroups management, and careful isPickable and setEnabled() management too, perhaps. My advice might not fit your need. Just some ideas. Stay tuned for more comments.

Short answer: Do the function :smiley:.
At least try something with simple boxes maybe and put a link with the code here. Unfortunately I really don’t understand what do you want to archieve :frowning:

aaaand

!!! Please don’t post your issue in ‘n’ different topics which don’t have to do with your problem. !!!
!!! Don’t create multiple topics for the same issue. It is not the first time when you are doing this. !!!

3 Likes

How to say? The previous project of the company was implemented by C++, which was to add AABB bounding boxes to the model, add each one, and then detect the collision, which models have collision to the model you selected, and then calculate the position and so on, and only obtain the above model, etc., like this.

sorry!But I’m really in a hurry, and I really don’t know how to get started on this, and second of all, it’s useless for me to put up the code, because I haven’t even started this feature yet, right

http://120.78.84.216/
This is what I put on the server, and then I can look at it

for the collision pickup you mentioned, is it done by the camera emission line?

Ah, boundingBox collision between floors. (not a picking issue). Sorry, I was confused.

Maybe bounding box “intersection” testing?

https://playground.babylonjs.com/#KQV9SA#0

Also, see console.log(mesh.getBoundingInfo().boundingBox); There are many properties on a mesh boundingBox… for measuring its width, height, depth. (often called “extends”). So you can measure stuff, and set positions of floors… by stacking them (because you can do boundingBox measuring).

Maybe THAT will help?

image
this is my GetBoungdinginfo() for each grid, but I don’t know what I can do with it
image
I would like to try this collision event to get which models my current model has collision with, but it doesn’t seem to be of any use


collision cannot be obtained

according to what you said, when I click on a node, I get the boundary box information of the model under the node. Then how can I get the coordinates of each model that collids with it through calculation, and then judge that the model above my current model chooses to hide

I don’t think you need onCollideObservable, but I am still not sure what you are trying to do. I am having problems understanding the objective.

Stacking floor-levels? Get extendsY of bottom mesh, then negative extendsY of upper floor/level… then you can position top floor perfectly atop bottom floor. (perfect stack).

But I am confused. Do you want to drag top level and make it “snap” to top of bottom level? I’m trying to help, but i don’t understand.

Do you know how to upload a video to reply others? If yes, I can upload a video to you directly

I have tried to understand your posts. Using a different language must be very frustrating.

Collision may be the wrong word for you to use.

Objects can only collide if they are moving, here is a video of a grey car and a red car collide YouTube

Two meshes collide if one or both of them are moving and at some point they meet.

Perhaps you need the word touch?

https://www.babylonjs-playground.com/#MECK03

If the playground above the red and green boxes touch. You can also say the red and green boxes are in contact.

So the red box touches the green box, the yellow box, the blue box, the purple box and the black box.

You can also say the red box is in contact the green box, the yellow box, the blue box, the purple box and the black box.

You can also say the red box is next to the green box, the yellow box, the blue box, the purple box and the black box.

Here is another playground https://www.babylonjs-playground.com/#MECK03#1. Each floor is a different color. Can you explain what you want to happen when you click on one of the boxes on the green floor?

2 Likes

Let me see if I understand this correctly.

  1. You want a player object to have collision response with the building models.
  2. When the system registers a collision on a New floor, detect all floors Above the player object, and make them invisible, so that in a top-down or third-person-camera setup, all you see is the floors beneath the player, so that if the player moves up stairs or a slope to a new floor, no further floors or roof are obstructing the view.

Simple example: Babylon.js Playground
(WASD to move)
Not quite sure this is what you’re after, though.

Am I understanding you correctly?

The key is that I have no players, this is not a game, just a show, I click on the level of the directory tree, and then decide what to show and hide

I don’t see any touching, it’s just setting him up so they can be together

For what you just said, collisions, it’s true that the static model has no collisions.I always thought that I made a mistake, but if there is no collision detection, is there any other way to detect the model above me, because the function I need is to interact with the above model with the current model to see if I can choose to hide the above model

I uploaded a video directly, you can look at it, and then you know what I mean