Physics Body Editor pre-3.0 update!

Apr 26, 2012 by     66 Comments    Posted under: Desktop applications, Physics Body Editor

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.

New features

  • 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.

Main view of the application (click for larger image)

The application

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

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.

Links

Project repository:
http://code.google.com/p/box2d-editor/

Download page (application, loaders and demos):
http://code.google.com/p/box2d-editor/downloads/list

Reference manual:
http://www.aurelienribon.com/blog/projects/physics-body-editor/

First steps video

[youtube=http://www.youtube.com/watch?v=KASY91EiTXQ]

In-game result

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.

66 Comments + Add Comment

  • Great work ! ;) /clap

  • Hi Aurélien!, I have readed the overview, looks GREAT, I love the changes that you made in this tool!. I will try it when i come back to home.

    I’m currently developing a new game (with a nice monster truck/dynamic track), and PBE 3 will make everything a lot easier :) (can’t wait! really!) …

    I will test this app and I will tell you any ideas / suggestions to make it even better, its not an easy job, you covered A LOT of things.

    Im really impressed! better than expected, and I can see how awesome PBE 3 is going to be!!

    Cheers!!!

  • Man…THANKS.

  • Great job! I am looking forward to the major release.

  • This is awesome, helped get a start to learning how to implement Box2d as well! I’ve sent a small change to the loader as well, just taking the shape in a slightly different direction. Thanks for all of the programs that you have shared with the community!

    • Thanks! I’ll add your change to the loader in the next revision.

  • Great work, big thanks for sharing!
    Only a glitch: the first time i launched it didn’t save any image path although they were visible when i created a new project (third choice, “create bodies from images” button) but the nice JSON format made it easy to workaround the problem. Opening the manually corrected file and resaving it was just fine and any other modification didn’t provoked the problem.
    I just miss the decompositor selection but i’m quite sure it’s just me and it’s not that important :)

    Keep it up, this is sooo useful and well conceived!

    • I can add the decompositor selection back in the tool if you need it :) I never found Ewjordan’s method to be better than Bayazit’s one, but there may be use-cases for it. I’ll try to add an “advanced options” panels.

      About your issue, can you reproduce it again with a new project? What’s your OS? I’ll investigate that. Third choice for new bodies was the least tested one.

      • Hi, thanks for getting back!
        I’m running ArchLinux, i tried spending some time reproducing the issue but to no avail, it just works fine now but i’ll keep you updated whenever i encounter any issue.

  • Hi, very nice tool.

    But how can I work with objects with hole inside?

    Eg http://www.toxiclab.org/img/200512225_gear.jpg
    this image. When I try to auto-trace with hole-detection checked, it creates nothing.
    When I uncheck it, it find just the outside shape. When I try to insert circle in the middle afterwards, in is not recalculated into the outside shape. I hope you understand my problem.

    But once again, very nice tool

    • The tool has the same limitations than what can be done with Box2D. Physics engines do not truly support holed polygons, so you need to fake it. Simple solution: just create 2 polygons, one for each half of your body. They can overlap each other, that won’t cause any trouble.

  • Firstly, thanks for your response. I Thought that your app doing exactly this, taking any kind of polygon (nonconvex, holed) and cut it into convex polygons.
    Secondly, I have little problem with your app, which is very limiting for me, I have submitted it as issue. Please, see http://code.google.com/p/box2d-editor/issues/detail?id=14

    Thank you

    • Holed polygons are very special mathematical constructions, and their complexity is not worth supporting them in a free tool built on spare time. The auto-trace algorithm can detect simple holed polygons though, with variable precision. If you have a fast and simple to implement algorithm to support them, I beg you submit a patch though :)

      About your issue, I’m working on it, that was an untested corner-case. Thanks for reporting!

      • Thank you for such a fast fix of this issue. When do you think it will be available through binary download?

        • Relaunch the tool, it should warn you about a new update ;)

          • Now it works just fine. Thank you very much. Fastest fix of 3rd party app ever :)

  • Hi again :) is it possible to tag some polygons? I want to later know, which polygons were tagged and treat them differently (create them as sensor in my case). It would be really nice if we can attach some custom data to every shape…

    • May be a good idea, I’ll see how I can include that in the UI. Use the issue tracker of the project to propose enhancements, it’s easier for me to remind them like this ;)

  • [...] Update: http://www.aurelienribon.com/blog/2012/04/physics-body-editor-pre-3-0-update/ [...]

  • I might just be missing something, but is it possible to pan in the editing box? As I zoom in it’s only zooming in on the view’s center point, making it difficult to get in close to an area of the object I’m trying to create.

    • Sure, hold right mouse button :)

      • Ah… well, not I feel like an idiot.

        Thank you. This program is incredibly useful!

        • You’re not an idiot, I just saw that I never mentioned this behavior in the user manual. I’ll fix that :)

          Glad you find it helpful. Version 3 is coming and will be much more powerful!

  • This editor is wonderful. One thing, it says that it can save to XML, how do I go about doing that?

    • XML was supported before but is no more. However, I’ll add this support back in the incoming 3.0 version, since it’s used by many people :)

  • This is a great tool. Thanks a lot buddy. Is there any ETA on version 3? Keep up the good work :)

    • No real ETA. I have a TODO list you can’t imagine for all the tools :p
      I’m writing my thesis all day long until end of september, but after that, I’ll be fully dedicated to the tools.

  • Hey, the tool seems really promising. However, when I open it and load a body with an image, the editor pane remains blank, even though the pane on the left (the “Rigid Bodies” pane) lists the new body. I’m running Mac OSX with the latest version of Java (SE 7 Update 7). I’ve tried several versions on the downloads site (2.9.2, 2.9.1, 2.0). Any thoughts on what might be going wrong?

  • any ETA on dynamic body update?!?

    • I stopped giving ETA a long time ago :p
      I want to work on this tool as soon as possible, since I really love it, and use it in my own games. However, recent changes in my life (thesis is about to end, I got a new job, etc) are totally slowing me down. Sorry about that :/

  • Isn’t the retina macbook support? I run the editor on my retina macbook and open the test project, and then select on sprite,but there is nothing displayed, is there any other libs need?

  • And with this loader dont need convert pixels to metters? im trying to use this in my game and the speed of gravity dont works correctly can you spell how to use the units with this loader?

    Thanks!

  • Could you please upload a full sample project of a Physics Body Editor and LibGdx project? I tried a lot to use the exported file in my libgdx project , but every time eclipse throws back some errors . Please Help me Huge thanks.
    Ps: Sorry for my English is not my native language.

  • Very nice work!
    This tool helps me immensely with my work. :)
    I have only one question though, is there anyway to get the fixture that gets attached to the body when using your libgdx loader? Could be useful since you need the fixture to setUserData etc.

    • Can’t remember if that is possible. However, the loader is very simple, so you should be able to hack it easily to add such feature with a few line of codes .

  • Love these tools – thanks so much. I have a question – I had to switch to the nightly releases to get the tilemap support for libgdx.

    The bottle demo json loader throws and class not found exception with the new libgdx jars. I traced it to .parse in the json reader. I could be making a mistake or something but the only thing that changed was the libgdx jars.

    Is this a known problem with the body loader?

    • It’s been awhile since you’ve posted this, but did you ever get this fixed? I seem to be running into the same problem.

  • no such method error ,please update your loader.

    Exception in thread “LWJGL Application”
    com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError:
    com.badlogic.gdx.utils.JsonReader.parse(Ljava/lang/String;)Ljava/lang/
    Object;
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run
    (LwjglApplication.java:116)
    Caused by: java.lang.NoSuchMethodError:
    com.badlogic.gdx.utils.JsonReader.parse(Ljava/lang/String;)Ljava/lang/
    Object;
    at aurelienribon.bodyeditor.BodyEditorLoader.readJson
    (BodyEditorLoader.java:179)
    at aurelienribon.bodyeditor.BodyEditorLoader.
    (BodyEditorLoader.java:41)
    at aurelienribon.bodyeditor.App.createBottle(App.java:126)
    at aurelienribon.bodyeditor.App.create(App.java:73)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop
    (LwjglApplication.java:130)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run
    (LwjglApplication.java:110)

    • hello, I have the same issue where I save the json file and import it via the BodyEditorLoader and Im getting the no such method error, here’s my BodyEditorLoader instantiation:

      BodyEditorLoader heloLoader = new BodyEditorLoader(Gdx.files.internal(“data/heli.json”));

      it is producing this error:

      Exception in thread “LWJGL Application” com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse(Ljava/lang/String;)Ljava/lang/Object;
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:120)
      Caused by: java.lang.NoSuchMethodError: com.badlogic.gdx.utils.JsonReader.parse(Ljava/lang/String;)Ljava/lang/Object;
      at aurelienribon.bodyeditor.BodyEditorLoader.readJson(BodyEditorLoader.java:179)
      at aurelienribon.bodyeditor.BodyEditorLoader.(BodyEditorLoader.java:41)
      at com.badlogicgames.corysgame.bottle.screens.MainMenuScreen.createDynamicBodies(MainMenuScreen.java:73)
      at com.badlogicgames.corysgame.bottle.screens.MainMenuScreen.(MainMenuScreen.java:63)
      at com.badlogicgames.corysgame.bottle.entry.corysgame.bottle.CorysGame.create(CorysGame.java:35)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
      at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)

  • thanks this software is amazying

  • Hi
    thanks for this post,
    I am using box2D on my new project, your app will help me a lot,
    but
    google blocked my ip address so I can’t download that from code.google.com
    can you give me a link to your app? or email it to me?
    Thanks

  • Same problem as Brian Chu. I have a mac and image is not showing on the right pane.

    • I have having the same issue with OSX. No image in right pane.

      • I amend my last to say, it seems to be a Java7 issue on OSX. I switch to java 6 and it works.

  • Whe you release upda 3.0?

  • When you release update 3.0?

  • I do not know if it’s just me or if everyone else experiencing
    issues with your website. It seems like some of the text on your posts are
    running off the screen. Can someone else please provide feedback and let me know
    if this is happening to them as well? This may be a issue with my
    internet browser because I’ve had this happen before.
    Thank you

  • We’re a group of volunteers and opening a new scheme in our community.
    Your site offered us with valuable info to work on. You have done an impressive job and our whole
    community will be thankful to you.

  • I don’t understand how to use the repair image paths option. I moved the folder where the images are stored and when I enter the new file path into the repair image paths window, nothing happens.

  • It’s going to be end of mine day, but before ending I am reading this enormous paragraph to
    improve my knowledge.

  • I loved as much as you’ll receive carried out right here.
    The sketch is attractive, your authored material stylish.
    nonetheless, you command get got an nervousness over that you wish be
    delivering the following. unwell unquestionably
    come further formerly again since exactly the same nearly very often inside case you shield this increase.

    Feel free to surf to my blog post – genital herpes cure breakthrough 2012

  • You really make it seem really easy with your presentation however I in finding
    this matter to be actually something which I think I would by no means understand.
    It sort of feels too complicated and very extensive for me.
    I am having a look forward in your subsequent put up, I’ll attempt
    to get the dangle of it!

  • What i do not understood is in reality how you are no longer
    actually a lot more smartly-appreciated than you may be right now.

    You’re very intelligent. You realize therefore
    significantly in relation to this subject, produced me in my opinion believe it
    from numerous numerous angles. Its like women and
    men aren’t interested unless it is one thing to accomplish with Lady gaga!

    Your own stuffs excellent. At all times handle it up!

  • I read this paragraph fully regarding the comparison of latest
    and earlier technologies, it’s awesome article.

  • I think this is one of the most vital information for me.

    And i’m glad reading your article. But should remark on few general things, The site
    style is perfect, the articles is really nice : D. Good job, cheers

    My blog :: can herpes be cured

  • Undeniably believe that which you said. Your favorite reason appeared to be at the internet the easiest factor to be mindful of.

    I say to you, I definitely get irked at the same time as folks consider worries that they just don’t recognise about.
    You controlled to hit the nail upon the top as well as defined out the
    whole thing without having side effect , other folks can take a signal.
    Will likely be again to get more. Thank you

  • I’m amazed, I have to admit. Seldom do I come across a blog
    that’s both equally educative and entertaining, and let me tell
    you, you’ve hit the nail on the head. The problem is something not enough people are speaking intelligently about.

    I’m very happy I found this during my search for
    something relating to this.

    Also visit my webpage: phen375 review (hikarino-ie.org)

  • You would no long in order to be stand near the terminal to
    approve voids and special. Are you currently thinking about tiling
    all of the home? Rather, today’s crowd wants collection a trend instead of following only.

  • Hi there colleagues, how is everything, and what you wish for to say on the topic of this piece of writing, in my
    view its really amazing in support of me.

  • Because of the book you will have to spend less time
    thinking on what to eat and which recipes to follow. If you rinse uncooked chicken sanitize sink and kitchen surfaces after rinsing.
    Instead, it’s a recipe for a bold bacon mayonnaise that’s Paleo-friendly and designed
    to fit into a seasonal approach to ancestral health diets.

  • In 1935, of what was known as the río piedras massacre.
    And based mostly largely on amusing research into the week’s media coverage.
    Of mud and plants) repleat with crops and frequently a number of feathers, and placed within a 50 percent-metre (18 in) on the side of a
    little fish-pond. This virus is associated with an episode of
    5 cases of vhf in september and august 2008.
    Hsu gifted a lasting undergraduate grant at.

  • [...] Physics Body Editor pre-3.0 update! | Aurelien Ribon’s Dev … – 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 …… [...]

  • use full tutorials

  • cvfh

Got anything to say? Go ahead and leave a comment!

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>