Incoming application: Box2D Editor

Jul 11, 2011 by     20 Comments    Posted under: Desktop applications, Physics Body Editor


I’m currently working on an open-source tool that will allow developers to easily create complex body shapes to use in the Box2D engine (well, actually the output format can let it be used for any physics engine).

I made it because of my own needs, but I’m sure it can help many people around here.

Available soon, stay tuned ;-)


20 Comments + Add Comment

  • Impressive work! Seems very easy to use. Please include some kind of instructions along with the release :-)

  • Thanks. Of course, the release will be accompanied with some extensive documentation, including a video tutorial.
    Currently, I’m polishing the java library that will be used to easily import shape definitions into people games and applications.

  • Very nice stuff. Tested it with a couple of my images, worked flawlessly. You mentioned that it would be open-source? I was just curious as to how you merged the ear-clipping algorithm with box2d polygons/fixtures.

    I have a pixel map, made in Paint.NET, that I read in with libgdx’s pixmap and through some annoying math determine the shape’s parts (like is this a cap or a t-joint or a 1-edged piece) and then end up with a list of vertices which I intended to use with box2d. However, I failed to notice that box2d only accepts concex polygons and was interested in seeing your implementation. Appreciate the help.


  • Actually it will be part of the libgdx extensions, so you will be able to easily grab its source. I use the tesselation algorithm made by ewjordan from the official box2d forums. He made a processing applet and release the source:

    I just get the shape drawn by the user as an array of Vector2 and throw it to this algorithm to get a Vector2[][], representing the convex polygons.
    Then, all you have to do is to create a box2d Body and to iterate over those polygons. For each one, you create a new FixtureDef and call body.createFixture().

    Therefore, each set of convex polygon is a set of fixtures for a body. Thus the name of the importer: FixtureAtlas ;-)

  • Whoops. I looked into ewjordan’s code and it looks good. I’ll probably use that. It specifies that the vertices must be given in a CCW fashion. What would be the best way of ordering the vertices so that they are counterclockwise order?

    Appreciate the help

  • Have a look at the following Polygon implementation, it contains a “isCCW()” method:

    I’ll implement that for the editor as well. Currently, the shape has to be defined in CCW order.

    • It's a bloody BRIALLNT thing, the two of you coming together at last and making a new life! I'm so thrilled for you!And, I'm wearing my Karina frock today,and have been thinking lovingly of ALL DAXXXX!XXXXXXYXXXXXXXXXXX Rock ON!

    • Hola Yolanda:Aquí la respueta de nuestros profesionales:“No, con la cuota que pagas no tienes cubiertas las contingencias profesionales ni el cese de actividad ó coloquialmente denominado “paro de autónomos”.”Si tienes alguna duda más, pásate por nuestras oficinas y te atenderemos con mucho gusto.Gracias por visitar nuestro blog.Saludos,

    • Very interesting location, looked fairly challenging to get good shots. I wanted to know, if you had been using you 40D or a camera which had a pop up flash built in, would you have used it to help illumination?

    • have not come across bulgur here at my place but looks like this is a kind of healthy stuff. There are so many different kind of grains out there, at times i just got mixed up which is which if i dont look at the labels. i just like the mangos that you put in for the salad here!

    • Cmq se fosse così la società deve prendere dei seri provvedimenti, perchè se vuole avere un futuro deve necessariamente pensare al presente….. e il presente dice che quest’anno dobbiamo assolutamente centrare un posto in champion’s league.Forza presidente “fatti coraggio” e investi bene a gennaio!(mi illudo e sogno..)

    • I admit that I am not consistent with my training. Especially when I see something new, I program hop. How would you know if the program you’re in is the right one for you? How long should you persevere to see the results?

    • he is passing on something. 'For I received from the Lord what I also passed on to you…'When Pauyl says he received something from the Lord, does he mean that he received something from the Lord?Why does he not tell us from whom he received this?

  • Unfortunately I do not have the luxury of putting my vertices in order :/ However I was hoping for something like this except for concave polygons

  • If you cannot order your vertices, then you can only define a convex polygon from these vertices, with the methodology given in your article, and Box2D gladly accepts any convex polygon (with up to 8 vertices).

    You cannot get a unique concave polygon from an unordered vertex list, since there are multiple solutions. If you want anything concave, your only chance is to start with an ordered list.

    That’s why I made this tool :)

  • That’s unfortunate. Well, it would be possible though if I managed to my vertices via a better method? Say if I made my import algorithm had a strong preference for right turns and kept making those until it had no other choice. This way I should have all my box2d vertices in order from start to finish. Or would this not work as well?

  • edit: the game I’m creating atm is sort of like Assembler. That is, it is very blocky and all my shapes are essentially tiles glued together which certainly makes my job easier. I would like to combine these tiles into larger boxes so that I have the minimum number of boxes.

    Appreciate the help

  • Thank you for sharing very good information. Your web site is extremely cool. I am impressed by the info that you’ve on this site. It reveals how nicely you realize this subject. Bookmarked this internet site page, will come back for additional articles.

  • I would like of know how can i work with box2d editor into of andEngine?

  • hello ,
    also works with andengine ?

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>