Jump to content

Check meshes overlapping


Gwir
 Share

Recommended Posts

I need to verify the overlap of two meshes, specifically the offsets of position rotation and scaling.

My current solution is to check the worldMatrix of both meshes and it works good for position and scaling offsets. Since I rotate meshes with Mesh.rotate() method, i have no way to get the rotation offset.

And even if I get those values, meshes could be perfectly overlapped even if they have different roration values (a box for example).

Is it possible to check meshes overlap or am I missing something?

Link to comment
Share on other sites

Hi @Gwir, good to see you again.

Any chance you could make a playground scene... showing the issue?

Also, you might want to check out http://playground.babylonjs.com/?10

Here, we see three kinds of intersection-testing... happening.  One with a low-precision bounding box, one with high-precision, and one mesh-to-point intersection.  The spheres turn red upon intersection.  Maybe this is enough to get you rolling.  If not, we'll keep experimenting.  But, it is easiest if you create a playground, so we can ALL work on the situation easier.  Thx.

Link to comment
Share on other sites

http://www.babylonjs-playground.com/#15BK6Z#0

Check the simple intersection is not enough, i need to verify if box is completely (or at least within a certain range) overlapped to box2, i can do that comparing the worldMatrixes.

But i need also to get the overlap "accuracy", it's simple for position and scaling but rotation values for box are always zeroes rotating it with rotate() method, and worldMatrix is not usefoluf for this purpose. 

Link to comment
Share on other sites

Thx for the PG.  When you use .rotate, that creates and uses a Quaternion to hold the rotation.  http://www.babylonjs-playground.com/#15BK6Z#1

Take a look at line 33, and the console.

Also, don't forget about the "point-in-space" intersection.  Perhaps you could use 8 of those, one for each corner of the box you are testing.  If any of the 8 intersection points... are not intersecting the other box, then it is not perfectly aligned.  I don't know if that would work for you, but it is something to consider.

Also, keep in mind that square and rectangular boxes set with .visibility = 0... can still do intersection tests.  So, surrounding a box with invisible mesh, possibly parented to the box, could provide intersection assisting  (by watching the invisible boxes for intersection or lack of intersection).  In a way, you are surrounding the box with "intersection sensors".

Just some ideas... might be useful.  Maybe more and better ideas will come from others.  Be well.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...