DirectXCollision - any way of getting more information about intersection?

I've been doing a simple 3D rigid body simulator and I've come at a point where I need to handle collisions between objects. So far using the new DirectXMath alongside DirectXTK's SimpleMath has been an immense help.

I've been using the BoundingBox and BoundingOrientedBox classes from the DirectXCollision library and they are great for determining if two objects intersect but don't give any more information other than that. I need to be able to retrieve the points of contact and the normal of intersection in order to properly calculate a rigid body response.

My question is - is there any way to retrieve that information using the DirectX libraries or should I learn it and implement my own approach?


Yes and no.

With DirectX math lib you can get intersection details about intersection of very primitive shapes with very primitive shapes, such as plane-line, plane-plane, triangle-plane. But you have only basic ("true, false" or "-1, 0, 1") info about more complex intersections such as ray-box, box-box, etc.

So, solutions:

  • you can roll out your own intersection functions for boxes, based on DirectX math library primitives. You will reinvent the wheel (partially), but this will allow you to keep existing calculation code untouched. Not so much to code, but you will need intensively use goggle for algorithms, and know MSDN ref by heart. Finally, it can be really ugly.
  • you can use another lib, such as Bullet, where plenty of intersections types available right now. They are already debugged and ready to go. But you will probably need to tear out all you DirectX math code with a dirty guts, if it was deeply integrated.
  • you can make something like a thin layer of abstraction (adapter) to an existing interface. You will be able to quickly swap any implementation you like, now or in the future. But it must be done in a smart way, as such additional level of indirection can slow up your super-fast math. It`s a pretty much coding and later debugging and pain, but it worth it.

Hope it helps somehow. Happy coding! ;)

Need Your Help

curl command not executing via shell script in bash

linux bash shell curl gnome-terminal

I'm learning shell scripting! for the same I've tried downloading the facebook page using curl on ubuntu terminal.

rss feed google media:group

javascript api rss

My problem is the following: I wrote a rss.xml with a

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.