Jump to content
  • Advertisement
Sign in to follow this  
vidalsasoon

collision of meshes

This topic is 5037 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
Advertisement
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!