Libgdx Box2D testbed

I found an hour today to continue working on porting over the original Box2D testbed tests. The ported testbed is very similar to the original one in it’s design. There’s a Box2DTest abstract class which handles things like creating all the rendering resources, mouse input and so on. All tests derive from this class and most often only implement the createWorld() method that populates the world with objects.

The class TestCollection ties all tests together and allows cycling through the tests by pressing the space bar.

Both things are pretty unexciting, porting the tests is also not really that impressive but rather tedious. The last piece in the puzzle is a renderer which can render the physics world. For this i wrote the Box2DDebugRenderer class, located in the main API so you can also use it when trying to debug your games. It uses an ImmediateModeRenderer internally so don’t expect the performance to be stellar.

Here’s a video of the tests ported so far. I could iron out a bug in the PrismaticJoint and a few other things along the way and all seems to work well. Richard of Rokon fame reported a bug in the default CollisionListener which i couldn’t reproduce. The CollisionFilters test also proves that my implementation of that is indeed correct. I could imagine that not being careful with your shorts (16-bit integer you pervert…) might be a problem in Java, so watch out for that.

Video footage taken on my trusty netbook with software OpenGL so the performance sucks a little 🙂

Libgdx 0.6 will be released on sunday with all those nice fixes. I hope to be able to port the rest of the tests over (won’t port raycasting and presolve tests yet though, that has to wait).

2 thoughts on “Libgdx Box2D testbed

Leave a Reply

Your email address will not be published.