yorke

Collision detection

7 posts in this topic

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 :)

 

Share this post


Link to post
Share on other sites

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.

yorke and Wingnut like this

Share this post


Link to post
Share on other sites

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!

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.