Gwir Posted August 24, 2016 Share Posted August 24, 2016 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? Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 24, 2016 Share Posted August 24, 2016 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. Quote Link to comment Share on other sites More sharing options...
Gwir Posted August 25, 2016 Author Share Posted August 25, 2016 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. Quote Link to comment Share on other sites More sharing options...
Wingnut Posted August 25, 2016 Share Posted August 25, 2016 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. Quote Link to comment Share on other sites More sharing options...
Gwir Posted August 25, 2016 Author Share Posted August 25, 2016 Thank you, didn't know the existence of rotationQuaternion.toEulerAngles(), it seems to work for me. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.