Physics Body Editor pre-3.0 update!
The new Physics Body Editor, my most popular tool, is under heavy development since a few weeks. The long awaited 3.0 update will bring dynamic objects and custom joints to link the rigid bodies that can be created since the first version. Until this release, I’m happy to propose the revision 2.9 of the application!
A description for newcomers: this application was designed to greatly facilitate the creation of collision shapes (called fixtures in most physics engines, like Box2D). Designing collision shapes can be a real burden since physics engine do not work with concave polygons, and use meter units, not pixel units. See the image below for a quick illustration.
This version is roughly the same as the 2.0 one, but with an UI entirely rewritten, and many new features to help you create your collision shapes.
- Auto-trace is now present! You can automatically generate the contours of your images,
- Body reference point location can now be changed and placed anywhere,
- Circle shapes are supported! Hold CTRL before creating a shape,
- Bodies are now named. No more image paths as loader keys…
- Bodies without associated images can be created,
- A “debug physics” option lets you see the real box2d bodies under the hood,
- The application automatically checks for updates.
I changed the UI of the application based on feedback I received (thank you for that). Most of the commands are now available directly in the canvas area as sliding buttons. If an action is possible, the corresponding button will slide inside the canvas. Once the action is no more available, the button will hide itself. This behavior facilitate the learning of the application mechanism, by not showing you every possible option right from the beginning. I find it more convenient, tell me what’s your opinion on this.
In the same aim, I enhanced the body list on the left. Instead of just showing the path of the image, it shows the image itself, as well as the name of the body and the image path. The list also lets you rearrange the order of the bodies. Note that the “New body” dialog (see next image on the right) is now much more intuitive. Note also that it lets you create a body without any image associated to it. Indeed, now that bodies are named, associated images are optional. This may let you create models without render, for test purposes for instance. You can then test your game in early steps, and ask the designer for graphics later (it is always possible to attach a new image to an existing body at any moment).
Finally, I included a visual XY axis in the canvas to show what are the coordinates of the points you may place. Like in previous versions, the application defines the width of an image to be always equal to 1. Its height is computed based on this fact. Note that since we are defining models (physics bodies), the units used are not expressed in pixels, but in meters (or “world units”). Remember that physics engine do not work with pixels, but with meters. This is important, because in your games, the loader will always ask you the scale you want to apply on the bodies before returning them. This makes sense because all the bodies defined in the application are saved with their meter coordinates. Therefore, based on the previous facts, they are all 1 meter large. However, not all your game objects are 1 meter large I guess, that’s why the loader needs to scale them to your needs.
About circle shapes, one may argue that they are not necessarily useful for polygon-based bodies. It may be true, but they will be incredibly useful for the 3.0 update. Just 1 word: wheels. Indeed, if you want to build a car without circle shapes, you’ll end up with broken suspension quickly. They are also helpful in many occasions to reduce the number of polygons and thus increase performances.
The loader has also be rewritten since the application now only outputs to JSON format. You’ll find a loader for LibGDX bundled with the application zip file. Loader works like before, with a subtle difference: the keys used to retrieve your bodies are no more the image paths, but the name of the bodies defined in the application instead.
Since the output format is JSON, it should be easy for anyone to write a custom loader for any other game framework. If you do so, I would love to include it in the release, just tell me about it. Just have a look at the provided LibGDX loader sources, it should be easy to convert to any framework and language.
Download page (application, loaders and demos):
First steps video
To demonstrate the usage of the provided loader, I made a small demo application with balls falling into a bottle. The bottle body was indeed defines using the Physics Body Editor. It is a dynamic body which falls from over the ground at the start of the demo and then stabilizes itself while it is filled with balls.
Creating the bottle is as fast as possible: only one line of code is required to attach the fixtures to the body: the loader handles everything.