yorke Posted March 20, 2017 Share Posted March 20, 2017 Hi all, my first post here. I'm learning babylon.js after having worked in three.js and I must say that I love this framework, many thanks to its creators for such a professional production. Actually I'm experiencing a little problem with collision detection between particles "fired" from a SolidParticleSystem and a mesh: I can trigger the collision between the particle and the mesh using particle.intersectsMesh(window.engine.scenes[0].meshes[15]) but intersectMesh() seems to become true when collision occurs with mesh's BoundingBox, which is way too approximate when I use a human mesh. Is there a way to calculate the exact point of collision from particle to mesh? I thought i could fire a BABYLON.Ray when intersectMesh() becomes true and retrieve the "real" intersection with mesh, is this a good approach or you think it can be done better? Are there any examples of using Babylon.Ray to retrieve exact intersection with a mesh? Thanks to all Quote Link to comment Share on other sites More sharing options...
hunts Posted March 20, 2017 Share Posted March 20, 2017 @yorke nice to have you in the forum, have you tried "intersectPoint(vector3)"? yorke 1 Quote Link to comment Share on other sites More sharing options...
jerome Posted March 20, 2017 Share Posted March 20, 2017 http://doc.babylonjs.com/overviews/solid_particle_system#particle-intersections you could test with the intersectsMesh() method from the AbstractMesh class by forcing the precise mode : yourMesh.intersectsMesh(theParticle, true); Note well, that testing against OBB (oriented bounding boxes) will be done only for the mesh (the particle BBox will keep axis aligned) and that this kind of test needs really more CPU. Testing with Ray is another option... and requires even more CPU. Wingnut and yorke 2 Quote Link to comment Share on other sites More sharing options...
yorke Posted March 20, 2017 Author Share Posted March 20, 2017 Thanks for your kind suggestions, i'll give it a try this evening and report the results. I've another question on the same subject (collision between solid particle and mesh): are there any functions that can give you the normal of the mesh face hit by the particle? I mean: I surely know the vector that gives me the direction of the particle bullet, but no one grants me that the mesh face hit is normal to that vector (e.g. a sideswiped mesh). Many thanks yet! Quote Link to comment Share on other sites More sharing options...
jerome Posted March 20, 2017 Share Posted March 20, 2017 About the normal of the facet hit by some particle, something exists : http://doc.babylonjs.com/tutorials/how_to_use_facetdata var norm = mesh.getFacetNormal(50); // returns the world normal of the mesh 50th facet If the mesh facet hit by the particle is the 50-th one, for instance Quote Link to comment Share on other sites More sharing options...
yorke Posted March 20, 2017 Author Share Posted March 20, 2017 Tnx jerome, I just saw some playgrounds of yours about facets and collision and they're really impressive. So let me understand better: With: yourMesh.intersectsMesh(theParticle, true); I have the coordinates of the impact point on the mesh, that come from the particle coordinates. How can I use this coordinate to retrieve the mesh's hit facet index inside the mesh tree structure? Quote Link to comment Share on other sites More sharing options...
jerome Posted March 20, 2017 Share Posted March 20, 2017 intersectsMesh() just returns a boolean. You can't get the intersection point from it. The only way I know to get the facet id (or index) is to use either a PickingInfo object, either the facetData provided functions 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.