Ghostdog Posted October 18, 2016 Share Posted October 18, 2016 Hi, all in all I just want to have a round boundingBox for my sphere mesh .. and .. as just having the space to ask .. a customizedBox for irregular formed meshes. After reading some of the babylon tutorial sides and topics and web, I want to know if my understanding in correct: For intersections between meshes I can use the bounding boxes that are available for every mesh in a scene. .. and as to see in http://playground.babylonjs.com/#CTHIE#1 the means real boxes! .. furthermore the boxes are take if I uses the actionManager functions to detect mesh intersection between meshes mesh1.actionManager.registerAction(new BABYLON.ExecuteCodeAction( { trigger: BABYLON.ActionManager.OnIntersectionExitTrigger, parameter: mesh2 } , function () { mesh1.position.x = 0.0; })); So if I have two spheres then it can happen that in the worst case both bounding boxes will hit on there edges with each other .. without any intersections of the spheres. In https://doc.babylonjs.com/tutorials/Intersect_Collisions_-_mesh there is the statement: " But this bounding box can be more or less precise, and that’s why we have our second parameter. In short, if this parameter is set to true (false by default), then the bounding box is closer to the mesh (OBB bounding type), but it’s a more costly calculation." .. Having the corresponding PG http://playground.babylonjs.com/?10 and trying "intersectsMesh(sphere, true)" still delivers a box (?) On the other hand there seems to be a boundingSphere but only for the camera? https://doc.babylonjs.com/classes/2.4/BoundingSphere How to have a round BoundingSphere or assign a custom mesh as a boundingBox? Did I have to write a detection on my own by looping though sphere vertices of a mesh instead? (sorry for that questions) With best regards Quote Link to comment Share on other sites More sharing options...
jerome Posted October 18, 2016 Share Posted October 18, 2016 in short, all mesh intersections are computed with bounding boxes AND bounding spheres that way : if the two bounding spheres don't intersect, return false else it the two bounding boxes don't intersect return false This means that for spherical meshes, the bounding sphere is similar to the mesh and the intersection is really fast and accurate ! The debug layer only shows the bounding boxes. If you force the parameter precise to true, you only force the bounding boxes to be rotated in the space like their embedded mesh. So instead of having a simple axis aligned process (direct coordinate comparison = AABB), this needs some more complex computation with oriented bounding boxes (OBB what implies some SAT or Separate Axis Theorem application https://en.wikipedia.org/wiki/Hyperplane_separation_theorem ) Having other "impostors" than boxes or spheres is even more complex and requires far more CPU. This is what the physics engines provide out-of-the-box Quote Link to comment Share on other sites More sharing options...
Ghostdog Posted October 18, 2016 Author Share Posted October 18, 2016 hmmm.. this would mean I can catch the bound spheres of two meshes regarding intersection? How? http://www.babylonjs-playground.com/#2DVY2Z#0 Quote Link to comment Share on other sites More sharing options...
jerome Posted October 19, 2016 Share Posted October 19, 2016 you can access a mesh bounding sphere via its boundingInfo object : http://doc.babylonjs.com/classes/2.4/BoundingInfo http://doc.babylonjs.com/classes/2.4/BoundingSphere var bSphere = mesh._boundingInfo.boundingSphere; You can test if two bounding spheres intersect with the static method : http://doc.babylonjs.com/classes/2.4/BoundingSphere#static-intersects-sphere0-sphere1-rarr-boolean BABYLON.BoundingSphere.Intersects(bSphere1, bSphere2); // returns a boolean Quote Link to comment Share on other sites More sharing options...
Ghostdog Posted October 19, 2016 Author Share Posted October 19, 2016 Great !! Thanks once more! 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.