Use Box2D for certain 3D concepts

I've been using this technique for awhile now, but I wanted to share with you guys because it has been so trivial to get passable "3D".

I'm writing a sports game, so when the ball falls on someone's head, they just catch it. There is no continued interaction between the ball and player bodies. Here, think all the way back to Super Mario Brothers. Remember how all the collisions between dynamic objects ended? You blinked away health or died or they died or flew away with high speed. That's essentially the trick I use, and it is very convincing for what I needed.

To handle collisions, my custom contact listener goes from the contact back to a b2Body's userdata, which is either null or an instance of my custom game object class. The base class contains 3 values, elevation, height, verticalSpeed for our new axis of motion (bodies with null userdatas are infinitely tall). This means that all 3D shapes are confined to being prismatic extrusions along this new axis. Image

The other constraint is that the dynamic 3D game objects will need to be a single circle, or else special care given to ensure that it is easy for Box2D to handle the case where the contact was ignored, and when the object fell into the other object, that Box2D's collision resolution doesn't act buggy. Two bodies whose fixtures are complex entanglement of decomposed polygons falling on top of one another would be the worst case scenario. A circle-circle or circle-convex polygon body collision would be the best case scenario.

Forgive me, codec issues. :-\ http://www.youtube.com/watch?v=hXTOT5hHi8Y

It also should be valid to keep sustained contact between objects vertically, so one could make a box2D game on 3d terrain. There are probably a limited number of games, such as a tank combat game, where this is a reasonable approach.

In my case, it was less work to make Box2D look 3D with some rendering tricks, than to use a 3D engine, get it running as fast as Box2D, and then map it back to my 2D art anyhow!

Original thread: https://box2d.org/forum/viewtopic.php?t=8832