Sign in to follow this  

collision of meshes

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

i have meshes with a bounding sphere around them. Now, when a sphere touches a another sphere around a mesh I would like to refine my collision detection to sphere vs mesh. How do i find out the correct vector that pushes my sphere away when it touches any part of the mesh. my problem is that even if i know the spheres are touching, I dont know how to do this with meshes. I'm guessing that I have to check every polygon of the mesh and check its distance is less than or equal to zero then find the polygons' normal to reverse it. code sample using C# and DirectX would be nice.

Share this post


Link to post
Share on other sites
you can do that. find the closest point on each triangles (if triangle is close enough) to the sphere centre, push the sphere away from that point. you can have a look at this, which is an example.

triangle-sphere collision

it's not in c# and is using OpenGL+GLUT (you may need the glut DLL), but the code should be simple enough. It all hinges on the "closest point on triangle" function and anyway. There is also code for building a basic AABBtree, but you can skip that.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
There's also the SOLID library which implements the GJK method. Or you could just search around for sample implementations of GJK if you want to do it yourself.

Share this post


Link to post
Share on other sites
I don't think you'll find much in C#. Most of the collision libraries are old hats, they've been around for ages, and are likely to be in C++, if you're lucky. Some in C. I don't think anybody did ports in C#, since it's so recent. The language barrier is nothing compared with the complexity of some algorithms. You'll have to do the implementation/port/build DLLs yourself.

Share this post


Link to post
Share on other sites

This topic is 4732 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

Sign in to follow this