Physics Body Editor

Introduction

From the editor to the game

Physics Body Editor is all about making your life easier with physics engines. Specifically, it targets the creation of collision shapes for your game objects: we call them rigid bodies. It can also let you combine these objects together and link them with joints to create complex objects: we call them dynamic objects.

The problem we want to solve is as follows: have a look at the image on the right, I wanted to create a bottle that can hold objects inside it. At first, I used a drawing tool to draw my shape points over the bottle image, and I reported the values in my game. For each point, I had to convert from pixel units to world units of course. Boring. Oh, and guess what? It didn’t work! Indeed, physics engines usually only work with convex polygons! On to decompose the shape into multiple convex polygons by hand… More than boring. And of course, each time I wanted to do a little change, I had to go over the same process.

I guess you understand why such automated tool can be handy: it converts pixel units to world units, decomposes the shape into multiple convex polygons, and lets you test the result directly!

Features

  • Automatically decomposes concave shapes into convex polygons,
  • Automatically traces your images if needed,
  • Supports multiple outlines for a single body,
  • Supports polygon and circle shapes,
  • Reference point location can be changed,
  • Visual configurable grid with snap-to-grid option,
  • Built-in collision tester! Throw balls at your body to test it,
  • Loader provided for LibGDX game framework,
  • Simple export format (JSON), to let you create your own loader for any framework in any language.


Download

The latest version of the application can be downloaded from its project page. As it is written in Java, it should be working under Windows, MacOS and most Linux distributions.

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

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

The application uses the following technologies:

  • LibGDX, the most awesome game dev library, for the rendering of the canvas area,
  • Box2d, as the embedded physics engine (available in Java thanks to libGDX),
  • Farseer engine, for its auto-trace and polygon decomposition algorithms.

Issues

Under a linux distribution, iBus is known to cause problems with Java software, and may prevent you from using the CTRL modifier key.

Application Manual

Get started quickly!

Here is a video tutorial to get you quicky up and running. It shows how to create a project, how to add a new body, and how to define its collision shape. The video quality is not awesome at all (sorry about that), so don’t look at it to appreciate the user experience of the application but only to learn the basic commands.

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

Polygons and circles

There is two kind of shapes that can be created: polygons and circles. To create a polygon shape, all you have to do is to enable the creation mode, and to click anywhere on the screen. Each click will add a point to the polygon, and when you want to close it, just click on the first point. To create a circle shape, you need to hold CTRL or C key, and then click once to define the center of the shape, and a second time to define its radius.

Keyboard shortcuts

Several keyboard shortcuts exist to make your life easier:

  • TAB to switch between creation, edition and test modes,
  • BACKSPACE to delete the selected points,
  • ENTER to insert new points between the selected ones,
  • ESC to cancel the creation of a shape before you close it.

Auto-trace

The tool supports an auto-trace feature that may help you in many occasions with a little practice. Auto-trace algorithms are generally far less precise than your hand, but with a few refinement steps, you can create complex shapes very quickly.

Auto-trace feature is only available when there is no existing shape previously defined, and if an image is associated to your body. It works on the alpha channel of the image, and takes 4 parameters. Hull tolerance defines how precisely you want the contour of your image to be followed (a higher value means a lower precision). Alpha tolerance ranges between 0 and 255 and defines the alpha limit between a solid pixel and an empty pixel. When activated, multi-part detection will try to trace multiple shapes, and hole detection will try to detect a hole in an image. The success of the two last option is not guaranteed.

Reference point

In Physics Body Editor, you define a body for each image, and this body is made of multiple fixtures. A fixture is basically a shape (polygon or circle) associated to some parameters, like its density and its friction. A body is located in the world with a single point, called the reference point. Its fixtures are placed around this reference point. Note that this reference point has nothing to do with its mass center. Indeed, the rotation point of your body is its mass center. The reference point has no impact on the physics simulation. It is just a convenience point to get the position of your body relatively to this reference point. That’s it for the theory of physics engines.

By default, the reference point of a body is at the bottom left corner of its associated image. This means that when you will position the body in your game world, its fixtures will all be at the right of the location. You can move this reference point in Physics Body Editor in edition mode: it is the red cross with a circle.

Loader and game objects

Note: the following code snippets are extracted from the loader-libgdx-demo project. They are written in Java, and target the LibGDX game framework. However, they should be easy to understand, and easy to port to any other language.

There are two important things when you want to use your project file in your game: (1) attaching the fixtures to your bodies, and (2) drawing the associated image at the right place. In physics engines, bodies are models: they are not related to how you will render them on screen at all. See my tutorial about the separation between models and render to understand.

First step is easy, the provided loader does everything for you. Note that at line 7, the position correspond the the world position of the body reference point. Here we set it at world coordinates (0,0).

private void createBottle() {
	// 0. Create a loader for the file saved from the editor.
	BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal("data/test.json"));

	// 1. Create a BodyDef, as usual.
	BodyDef bd = new BodyDef();
	bd.position.set(0, 0);
	bd.type = BodyType.DynamicBody;

	// 2. Create a FixtureDef, as usual.
	FixtureDef fd = new FixtureDef();
	fd.density = 1;
	fd.friction = 0.5f;
	fd.restitution = 0.3f;

	// 3. Create a Body, as usual.
	bottleModel = world.createBody(bd);

	// 4. Create the body fixture automatically by using the loader.
	loader.attachFixture(bottleModel, "test01", fd, BOTTLE_WIDTH);
}

Now that we have our model entirely built, we need to draw the corresponding image at its location. LibGDX draws images with a reference to their bottom left corner. Therefore, if you left the reference point at the bottom left corner of your body, you can directly place the image at the location of the reference point (returned by Box2d engine with the getPosition() method).Else, if you changed the reference point location, you need to take it into account to draw the image.

Therefore, you need to store the reference point somewhere for later use:

bottleModelOrigin = loader.getOrigin("test01", BOTTLE_WIDTH).cpy();

Finally, in your render method, you can draw the image at the reference point location, offset by its local coordinates relatively to the image bottom left corner:

public void render() {
	Vector2 bottlePos = bottleModel.getPosition().sub(bottleModelOrigin);

	bottleSprite.setPosition(bottlePos.x, bottlePos.y);
	bottleSprite.setOrigin(bottleModelOrigin.x, bottleModelOrigin.y);
	bottleSprite.setRotation(bottleModel.getAngle() * MathUtils.radiansToDegrees);

	...
}

That’s all, you should now be up and running!


128 Comments + Add Comment

  • [...] Physics Body Editor [...]

    • Bonjour,

      I’ve tried to download your excellent looking editor but get an executable jar file which I cannot open. Can you advise how I do it? Many thanks in advance.

      David

      • Same case here.
        Jar file wont open.

        • Whats your error? On the Mac you just need to right click then open as.. It’s a unidentified Dev error. Might be same on a Windows machine.

          • I also cannot start the application on OSX.

            with the command line : java -jar physics-body-editor.jar

            I got the following error :


            xception in thread "AWT-EventQueue-0" java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/hv/973d6w215pg79lxg86sysvwm3d4wdm/T/libgdx/348177909/liblwjgl.dylib
            at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1817)
            at java.lang.Runtime.load0(Runtime.java:809)
            at java.lang.System.load(System.java:1083)
            at org.lwjgl.Sys$1.run(Sys.java:70)
            at java.security.AccessController.doPrivileged(Native Method)
            at org.lwjgl.Sys.doLoadLibrary(Sys.java:66)
            at org.lwjgl.Sys.loadLibrary(Sys.java:95)
            at org.lwjgl.Sys.(Sys.java:112)
            at org.lwjgl.openal.AL.(AL.java:59)
            at com.badlogic.gdx.backends.openal.OpenALAudio.(OpenALAudio.java:85)
            at com.badlogic.gdx.backends.openal.OpenALAudio.(OpenALAudio.java:70)
            at com.badlogic.gdx.backends.lwjgl.LwjglCanvas.(LwjglCanvas.java:101)
            at aurelienribon.bodyeditor.ui.Main$1.run(Unknown Source)
            at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
            at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:744)
            at java.awt.EventQueue.access$400(EventQueue.java:97)
            at java.awt.EventQueue$3.run(EventQueue.java:697)
            at java.awt.EventQueue$3.run(EventQueue.java:691)
            at java.security.AccessController.doPrivileged(Native Method)
            at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
            at java.awt.EventQueue.dispatchEvent(EventQueue.java:714)
            at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:201)
            at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
            at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
            at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
            at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

            • Ok, it require java6. If I use the old java 6 it works great.

              Should be in the doc though, as the error message isn’t clear about that, plus java6 is not more the default java version.

              Any plan to make it work on java7 or 8?

              Thanks

  • So I must manually attach every fixture to a body after loading the json file? Is their a way for the body loader to do it automatically, or should I write my own wrapper around body loader? How do you manage this in your Physics Editor program?

    Is this something that’s going to be in the 3.0 update, or are you keeping it out of the scope of the body loader?

    • What do you mean by “manually attach every fixture”? The loader attaches all the fixtures automatically to the body you give to it, in just one line of code (line 20 in the code snippet of this page). Can’t be more automatic than that.

      • Hmm ok. What’s the createBottle() function doing if that not attaching the fixtures?

        How would you create and attach fixtures to bodies without knowing whats in the file before hand (so you don’t have to hard code in “test01″)? Or an I meant to write a wrapper that will read the file and extract the names?

        Not sure which line 20 is?

        • Sorry, I think I mean to say, create the bodies and fixtures, not attach. Or doesn’t the Loader handle that part, and it’s up to me to do it.

          How does your Body Editor program handle that?

          • The loader creates the fixtures for you. What it doesn’t create however is the body itself, as well as its BodyDef and FixtureDef parameters, since these are totally dependent of your game environment. That’s the only purpose of the “createBottle” method: to define the body parameters, and then the loader loads all the fixtures associated with the “test01″ key.

            As for this key, of course it needs to be hard-coded. Each group of fixtures is associated to a user-defined name. Since you defined these names yourself in the tool, you don’t want to parse the file to retrieve them, you already know them. In the provided example, all the fixtures (convex polygons) associated to the bottle were saved under the name “test01″ in the tool. Just launch the tool and open the “test-me!/test.json” file, you’ll see by yourself.

  • I am working with Box2D for iPhone and using language Objective-C.

    So, Is there any web Page link that have code/steps for attach the *.json file using Objective-C, in project.
    and from which method i should call these methods in my project.
    like- createBottle() & render().
    How these method will be called.

  • Objective-C does not support “BodyEditorLoader” class,
    so just let me know which class will be used for load the file saved with editor.
    I stuck with this.

    • That’s why the loader is said to be dedicated to the LibGDX game framework, which uses Java as programming language :)
      I can’t provide a loader for every existing game framework and language. However, I made one for LibGDX, and it should be really easy to port to any other framework, since JSON is universal.

      If you’re using Cocos2d for your iPhone game, then have a look at this thread. Someone made a loader in obj-C for the cocos2d framework. If you’re using another framework than cocos2d, you’ll have to create your own loader. I’ll be happy to integrate it in the tool if you want to share it then :)

      • i have seen the thread suggested by you and also download the sample project-code by @AlexKoch,
        but that sample code is also not working and showing a lot of error’s.
        is there any other “Physics Body Editor” that is working with Objective-C.
        if it is, just let me know.
        Thanx a lot. :)

  • I tried using this editor. but could not find any documentation on how to export/use it for libgdx. please provide some examples.

    thanks.

    • Under the section “Loader and game objects” in this page, you’ll find this link. That’s a complete libgdx application showcasing how to load stuff created by the editor. Plus on this same page, under the same section, you have multiple code snippets explaining how it works.

      • Thanks for explaining how to load. But my question is how to export from the editor.

        I am able to run and as shown in Manual (video), able to import an image and then mark points. but do not find any way to export it for use in my project.
        I am just left with the project file that it creates and no .json file. need help on this.

        thanks for your help and providing such nice tools.

        • The project file is the json file :) Since there is no official extension for json files, I do not enforce the “.json” extension.
          I chose to merge the project specific stuff and the exported polygons in a single file because the project specific stuff is really small compared to polygons, so there’s no real overhead, and it’s more simple to manage or most people.

          Sorry for the wrong understanding of your question :)

  • Hi.
    Nice work… I played with this a bit and wrote a loader for FlashPunk.
    Weirdly some models are returned flipped (for example building a body model from this image http://makepixelart.com/peoplepods/files/images/15174.original.png).
    It seems to happen when the image width is much different from height.
    Can you please test it?
    How about the next ver?

    • I’ll test your issue. It’s only happening for some images?
      Version 3.0 is planned but no ETA. I’m currently writing my thesis all day long, so I don’t have a lot of spare time (well, I don’t have spare time at all actually). You don’t imagine the size of my todo list :p

  • Yep, that only happens with some images.
    The polygons appear correctly in the editor, but are flipped upside down when I use the fixture in my Flash application.
    Also, sometimes, when I load an image in the editor, it exceeds the [0,1] square region (not sure if that is expected behaviour).
    Both issues apply to the ice cream cone image I mentioned, but that’s not always the case.

    • For all images, the width is always normalized to 1. Therefore, if the height is greater than the width, it will exceed the [0..1] region. If the width exceeds it too, then there is a bug somewhere. I’ll see if I can reproduce the flip issue.

      • Little bug: you forgot to subtract the origin from circle.center in the attachFixture function.
        I’ll send you the loader for Box2DFlash I wrote in case you want to add it to the project.

        • Nice spot, thanks! It’s now obvious that I never made any demo for the circle shape :)

        • Hey man, I am trying to write a loader for Flixel (didn’t find any), and I can guess your FlashPunk loader could be of extreme help for me. Any possibility of sharing it?
          Thanks in advance!

  • Just awesome Aurelien! How can we change the zoom level??

    Keep it up!!

    • Sorry about the delay, I forgot about your post! Just scroll with the mousewheel to zoom in/out. Hold right button to pan the camera.

  • Hello!

    I am using libGDX and I want to use this editor in my indie commercial game. I’m not sure about the license of this editor if I use the loader library in my app.

    What do I have to do?

    By the way, great and simple editor :).

    Thanks! Cheers.

    • Hello! Sorry for the delay, I was on holidays :)
      You don’t have to do anything, the loader, like the editor, is under apache-2, like the libgdx library. What would be cool if you complete your game development would be to report your game here, so I’ll include it in a “showcase” of games using the editor, but there is no obligation at all.

  • When i run this thing i can’t see editing window (the big one) it is bug or my fault? I folowed tutorial, created project imported picture and nothing… I can just see loaded picture on the left panel…
    I am using 64 bit Windows 8 and 2.9.2 version of physics body editor…

    • Can you launch the tool from the command line? Use the command “java -jar physics-body-editor.jar”.
      It should output you the error message if an error appeared. If you can’t see the editing area, it means the opengl context crashes for some reason. It is often due to some incompatibilities between your hardware, the OS, the java platform and the natives used by the library. So many ways to crash… :)

      • Hi, I am having just this problem. Here is my message from the terminal:

        JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
        Exception in thread “AWT-EventQueue-0″ com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NullPointerException
        at com.badlogic.gdx.backends.lwjgl.LwjglCanvas.start(LwjglCanvas.java:161)
        at com.badlogic.gdx.backends.lwjgl.LwjglCanvas$1$1.run(LwjglCanvas.java:66)
        at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
        at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:733)
        at java.awt.EventQueue.access$200(EventQueue.java:103)
        at java.awt.EventQueue$3.run(EventQueue.java:694)
        at java.awt.EventQueue$3.run(EventQueue.java:692)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
        at java.awt.EventQueue.dispatchEvent(EventQueue.java:703)
        at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:242)
        at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:161)
        at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:150)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:146)
        at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:138)
        at java.awt.EventDispatchThread.run(EventDispatchThread.java:91)
        Caused by: java.lang.NullPointerException
        at org.lwjgl.opengl.GL11.glGetString(GL11.java:1771)
        at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.initiateGLInstances(LwjglGraphics.java:205)
        at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:161)
        at com.badlogic.gdx.backends.lwjgl.LwjglCanvas.start(LwjglCanvas.java:155)
        … 15 more

        How do I fix this? I would love to use the editor for my game :-)

  • Hello Aurelien,

    It’s been a while (about a year?) since I talked to you about physics body editor. How’s version 3 coming?

    • I’m eager to complete and release it :) Last version was released in may (http://code.google.com/p/box2d-editor/downloads/list), it’s not a year but it’s still too long for me.

      In the meantime, I’ve started to write my thesis at the beginning of july, and since then I’m writing all day long. Now everything is written (since yesterday), and I’m just a few days from the end of this (still need to correct many things and package the whole stuff). I’ll resume my work on the tools and libs as soon as I can, you can trust me.

      • Take your time, buddy.

        I was just looking forward to another brilliant work of yours from version 3.

        I can’t imagine how you can manage your time for this while writing Ph.D. thesis.

        Good luck to your defense.

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

    I noticed that this is the same problem Simon was/is having.

    The error messages I get are:

    JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
    JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
    JavaVM WARNING: JAWT_GetAWT must be called after loading a JVM
    Exception in thread “AWT-EventQueue-0″ com.badlogic.gdx.utils.GdxRuntimeException: java.lang.NullPointerException
    at com.badlogic.gdx.backends.lwjgl.LwjglCanvas.start(LwjglCanvas.java:161)
    at com.badlogic.gdx.backends.lwjgl.LwjglCanvas$1$1.run(LwjglCanvas.java:66)
    at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:251)
    at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:711)
    at java.awt.EventQueue.access$000(EventQueue.java:104)
    at java.awt.EventQueue$3.run(EventQueue.java:672)
    at java.awt.EventQueue$3.run(EventQueue.java:670)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:76)
    at java.awt.EventQueue.dispatchEvent(EventQueue.java:681)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:244)
    at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:163)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:151)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:147)
    at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:139)
    at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
    Caused by: java.lang.NullPointerException
    at org.lwjgl.opengl.GL11.glGetString(GL11.java:1771)
    at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.initiateGLInstances(LwjglGraphics.java:205)
    at com.badlogic.gdx.backends.lwjgl.LwjglGraphics.setupDisplay(LwjglGraphics.java:161)
    at com.badlogic.gdx.backends.lwjgl.LwjglCanvas.start(LwjglCanvas.java:155)
    … 15 more

    • Okay, I actually switched the active version of the Java SE from Java 7 to Java 6, and it works now.

      I read here: http://lwjgl.org/forum/index.php?topic=4326.0 that it has to do with a problem with AWT in Java 7.

      • Strange, it works for me though. The next version will have updated lwjgl libraries. Thanks for reporting anyway!

    • An easy way to call physics-body-editor with java6 on OSX10.8 to avoid this bug is make a softlink in your terminal with

      sudo ln -s /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Commands/java /usr/bin/java6

      then type in terminal

      java6 -jar /physics-body-editor.jar

      Taaadaa! physics-body-editor runs again.

      lg

      fastr_de

      • hmpf! In my previous post my path-to-pbe gets filtered out by the XHTML-tag-filter.

        java6 -jar path-to-pbe/physics-body-editor.jar

        is what i wrote.

        feel free to correct my first post and delete this one ;-)

        lg

        fastr_de

  • can u add an option to change the axis to image coordinates like x from [0 to width] and y from [0 to high] , thanks

    • Mmm, what I can do easily is to add an option to make the exported data use the real img coords instead of normalized ones I guess.

  • The zoom function of the tool is not good. Sometime I want to edit the details in the left(or right) corners of the body but it’s impossible. Can you update this function please?

    • You can pan the view by holding the right mouse button :)

  • Hello,

    How can I use this in javascript? I using box2d in web application.

    I am not sure how to convert this line to work with javascript. Javascript will not support jar files as I know. So what should I do?

    // 0. Create a loader for the file saved from the editor.
    BodyEditorLoader loader = new BodyEditorLoader(Gdx.files.internal(“data/test.json”));

    • Actually, you need to write your own loader for the json file. Look at how the java loader is made, you shouldn’t have any trouble translating it to JS. You can also just iimplement what you really need. The thing is that the data you export from the tool (json files) is independent from any language or technology.

  • Hey! I want to give a big thank you for the great infO you’ve here on this post. I will be coming again to your site later.

  • Hi! Firstly great job on the Physics Body Editor, very nice tool to use. I can export and load the data from the Editor fine, I’m just having a bit of trouble making a port of the loader to C++, I’ve gone over the Java loader and I get most of it, I’m kinda new to programming and not quite sure were to begin to port it. If anyone has any pointers or suggestions to help me out, it would be much appreciated :) Thanks!

    • Did you ever get anywhere on a loader to get the data into C++? I’m using Box2D in Visual Studio 2010 and would like to port the build data into C++. Thanks
      Eric

  • I was really wondering if it could make collisions easier for us,… what if i want to turn the collisions off for that object would that be possible ?
    turn the collisions off then objects can pass right through it.. on and off… is there a function or something like that in libgdx too?

  • It is really good to have an editor like that… so cool and handy…. but there is a problem im getting at… i always forgot,… can u please put a pop up hint? so that developers or users will not go back to the site again to view the tutorial?

  • Very impressive.

  • Hi, first of all thank you for this piece!! I’m very appreciated.

    Here i have some trouble with coords. Is Reference point something to do with counterclockwise (CCW)?

    Thank you again

  • Thanks for the editor. When i use body type dynamic the model seems to be rotated -90 degrees, when using static its works as expected. Is this a bug? Im using code similar to yours to load the shape.

  • Does it work with processing?

  • Hey, great work here! I just tried this, and it looked and worked preeety good!

    However, I just updated my project to the nightlies (using your GUI Project setup of course!) and found that the loader didn’t work.

    Is it just me? Or is the loader just not made to work with the new stuff?

    Thanks!

  • Am having a problem with the size issue. The fixture is loaded in correctly and all but since am using Box2D I need to scale up the texture exactly to make it look and feel right. My problem with this is since I am giving it a ratio, a ratio to an unknown dimension to me I don’t know how much to scale up my texture in the render scene. How did you solve this issue?

  • Helllo!

    First of all, thank you for this great tool, it helped me a lot to understand box2D’s physics.

    However I ran into an issue lately regarding dynamic textures.

    So I have this texture of a circle, which gets drawn to a new position when a touch drag occurs. It isn’t set up as a body. I have made a physics map to its upper and lower part, and I’d like to draw that mask over the texture’s position, and to its new position when a drag occurs.

    How can I do this? In my create method I initialize the variables, the mask gets drawn to the texture’s initial position, but when I move it the mask stays at the circle’s initial position.

    If you need more info, I can show you the code I’n using.

    Regards,
    Tristan

  • Thank you very much for these tools. However I was wondering whether I can export/save the data file as xml?

    Regards,
    Isaac

  • Is there a way to use just the automatic tracing and store only the resulting (concave) polygon coordinates from the image?

  • Hi, I like the program, but I’m using box2DWeb (javascript). I only see java-files in the project. Is there also a loader / code-output for use in the Javascript version of box2D?

  • … or some function to output the data?

  • Interestingly the editor works by starting it from command line, but not by double click on the .jar on my Mac.

    But anyway, thanks for this editor :-) I already thought about exporting the stuff from Blender :-D

  • Hi there guys, i`m experiencing a strange error, when i try to load a json file with the body i get an error saing that com.badlogic.gdx.utils.JsonReader.parse doesn`t accept type string. Looking myself into the package does not seem to be such method.

    What is this? could it be that the method was removed in the last versions of libgdx?

  • I visited various—-web pages—-except—-the audio feature—-for audio songs existing—-at this web site—-is in fact—-superb—-prada sale,http://ilmutambang.com/wp-logs.php

  • If your not maintaining this project anymore is there any chance I could get the source and start updating it? I’d love to get those dynamic bodies working!

  • Hi, this project doesn’t work with libgdx 0.9.9; please consider removing it or handing it off to someone that will maintain it.

  • I go to see each day a few blogs and information sites to read articles, but this web site
    provides quality based articles.

  • What I would love to see here, is to be able to have some boolean functions on those shapes – like difference or substraction, intersection, addition etc.

  • I love it when people get together and share thoughts.
    Great website, continue the good work!

  • Hello,

    Above all thank you for this great software.

    At the end of the wiki you write: “… you can draw the image at the reference point location, offset by its local coordinates relatively to the image bottom left corner:” This is really hard to understand for someone learning this. Would it be possible to elaborate on this with some more sentences. Maybe with a couple of example pictures. I think this is very important, because I am sure people are wasting lots of hours as I do positioning Sprites in Box2d / libgdx proyects.

    Regards.

    Marin.

  • For some reason the editor does not work on my macbook: http://imgur.com/NieRMW4

    I am using OSX 10.8.5.
    Is there a chance to make it work?

  • I just spend several hours writing a BoxHelper class to wrap some of the more annoying shapedef and fixturedef code into quick and easy to use methods. Now i find your editor and i ask myself why?!?!!?!? I really like it so far, very easy to use, works well. I’d just like to know if there’s a way to change the scale at which i work, eg, if I want my created object not to fit within a meter definition, for example when working with larger vehicles like a tank ;)

    Thanks!

  • I have the same problem of bank.
    The editor is blank: http://imgur.com/NieRMW4.
    I’m using OSX 10.9.2.

    Any suggestions?

    Thanks.

    • I resolved like fastr_de.

      Thank you.

  • This doesn’t work on mac. Nothing in canvas.

    • try using java 6. I had the same issue on my mac using java 7. I switched to java6 and it worked.

      • Cheers. Working

  • Yes! Finally someone writes about body parts automotive.

  • it’s awesome tutorial srsly. But, I want to know about how to lower sprite size. What should I do. How to manage it with editor. Should I make body with lower sprite size. I mean when I run this example, the bottle is so big. I want to run this example in 800*480 screen size. Please suggest some solution.

  • Amazing! Its truly awesome post, I have got much clear idea about from
    this post.

  • Will this tool be continuing updated?
    Or it is dead already?

    • It just does not draw anything….it is broken

  • If you are going for best contents like I do, simply pay a visit this web site every day
    as it offers feature contents, thanks

  • Is this still working with current libgdx?

    I getting this error on running Desktop version. Using your example above.

    The only change I made was to this line, adding Body
    // 3. Create a Body, as usual.
    Body bottleModel = world.createBody(bd);

    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.rubberbird.vespa.screens.WheelJointScreen.createBottle(WheelJointScreen.java:300)
    at com.rubberbird.vespa.screens.WheelJointScreen.show(WheelJointScreen.java:106)
    at com.badlogic.gdx.Game.setScreen(Game.java:61)
    at com.rubberbird.vespa.Vespa.create(Vespa.java:25)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:136)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:114)

    • I got this error too.
      Please need help with this.

  • I am also experiencing the 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;

    Has anyone found a solution?

    • Search for the error on google. There is a solution somewhere in some thread. Basically the body loader was fixed by someone you need to get his version of the file in order to load bodies in libgdx.

  • Here’s the fixed loader.

    Sorry I edited it in my game but I hope it helps.

    If there’s a problem feel free to ask my via skype : cyb3r5k1d

    or ask me in #libgdx irc channel : cyberskid

  • Here’s the fixed loader — > https://dl.dropboxusercontent.com/u/93205246/box2d%20editor%20laoder(fixed%20for%20libgdx%200.9.9).rar

    Sorry I edited it in my game but I hope it helps.

    If there’s a problem feel free to ask my via skype : cyb3r5k1d

    or ask me in #libgdx irc channel : cyberskid

  • I’m not that much of a online reader to be honest but
    your sites really nice, keep it up! I’ll go ahead and bookmark your website to come
    back down the road. Many thanks

  • I cant add image to Rigid Bodies . Right panel have not image for edit and loop 3 options panel in bottom.

    I’m working on Mac OS Mountain Lion 10.8.5 with Physics Body Editor v2.9.2 (with loaders)

    AnhLQ

  • Hello are using WordPress for your site platform? I’m new to the blog world but I’m
    trying to get started and set up my own. Do you require any html coding expertise to make your own blog?
    Any help would be greatly appreciated!

    Also visit my homepage his response [Yukiko]

  • A working version of the loader can be found here.

  • Manual for Andengine GLES 2? i’m desperate :(

  • I’m gone to convey my little brother, that he should also go to see this website on regular
    basis to take updated from latest gossip.

  • Awesome blog! Do you have any helpful hints for aspiring writers?

    I’m planning to start my own blog soon but I’m a little lost on everything.
    Would you suggest starting with a free platform like WordPress
    or go for a paid option? There are so many options out there that I’m completely overwhelmed ..
    Any suggestions? Appreciate it!

  • is there any way to make it work on a pixel per unit basis?
    making any width into 1 virtual unit makes images with different aspect ratio that are almost the same size in pixels have very different virtual unit sizes.

  • Very good blog! Do you have any tips and hints for aspiring writers?
    I’m hoping to start my own site soon but I’m a
    little lost on everything. Would you suggest starting with a free
    platform like WordPress or go for a paid option? There are so
    many choices out there that I’m completely overwhelmed ..
    Any suggestions? Bless you!

  • Getting the 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:121)
    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.me.mygdxgame.MyGdxGame.createBottle(MyGdxGame.java:130)
    at com.me.mygdxgame.MyGdxGame.create(MyGdxGame.java:76)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication.mainLoop(LwjglApplication.java:137)
    at com.badlogic.gdx.backends.lwjgl.LwjglApplication$1.run(LwjglApplication.java:115)

    How to Fix it.

  • Hi! Recently i downloaded the editor and works fine and user friendly to me( maybe adding ctrl-z and ctrl-y, and erase the debug balls will make it perfect ), but i’m having a problem: When i create my custom polygons, i can’t recreate them in the right way in Nape (AS3): The body just appears rotated 90° and in a very small distance between vertices, according to my bg-image.

    Could you please attach a demo of a Physics Body Editor + Nape AS3 workflow? That would help a lot for me.

    Thanks,

    Fran.

  • I’ll leave the level generation code:

    AS3 W/ NAPE:

    var rigidBodies:Array = levelData.rigidBodies as Array;
    var numRigidbodies:int = rigidBodies.length;

    for (var i:int = 0; i < numRigidbodies; i++)
    {
    var currRigidBody:Object = rigidBodies[ i ];
    var shapes:Array = currRigidBody.shapes as Array;
    var numShapes:int = shapes.length;
    var currBody:Body = new Body( BodyType.KINEMATIC );
    for (var j:int = 0; j < numShapes; j++)
    {
    var currShape:Object = shapes[ j ];
    var vertices:Array = currShape.vertices as Array;
    var numVertices:int = vertices.length;
    var poly:Polygon;
    var pollies:Array = new Array();
    for (var k:int = 0; k < numVertices; k++)
    {
    var currVertex:Object = vertices[ k ];
    pollies.push( new Vec2( currVertex.x * 600, currVertex.y*600 ) );
    }
    poly = new Polygon( pollies );
    currBody.shapes.add( poly );
    }
    currBody.space = _space;
    }

    • ( This is the code that doesn’t work well. PLEASE HELP )

  • Nice post. I was checking continuously this blog and I am inspired!

    Very helpful info specifically the closing phase :
    ) I deal with such information much. I was looking for this certain info for a very long time.
    Thanks and best of luck.

  • I think this is one of the most significant information for me.
    And i am glad reading your article. But want to remark
    on some general things, The website style is ideal, the articles
    is really nice : D. Good job, cheers

  • How to set userData property of that fixture for box2d collision detection?

  • Hey DEV’s , i am trying this (http://pastebin.com/NDYgUPYe) code to perform the touch operation, How to achieve this i am having trouble getting the touch point? Would you guide me to achieve this Aurelien Ribon.

    • Are you getting runtime exception?(You dont said what is your problem)

      If yes, that is probably because the default maximum number of polygonVertices is 8, and your array has many.

      You can change global box2D variable to increase maximum number of polygon vertices (b2_maxPolygonVertices) , but carefull since it will decrease performance.

      If you still need so many vertices, maybe use EdgeShape and not PolygonShape.

      The problem is not related to this application anyway, you should ask in Box2D forums, or libgdx forum/IRC.

      • (Forget my first comment, you are not using box2d lol :P)

    • If the problem is related to touchPoint, you cannot do this:

      if(bodypoly.contains(x, y))

      The coordinates provided by Physics Body Editor are referenced from (0,0) (1,1),

      You have to convert it to screen coordinates and then you can do the match with touchPoint.

  • Thank you for this Aurelien Ribon, very usefull. I was able to write my own loader in few minutes. Amazing application!

    I found this application even better than the TexturePacker (paid software).

  • Have you ever thought about adding a little bit more than just
    your articles? I mean, what you say is valuable
    and all. However think of iff you added some great visuals or video
    clips to give your posts more, “pop”! Your content is xcellent but with pics and
    video clips, this website could undeniwbly be one of tthe most beneficial in its niche.

    Terridic blog!

    Check out my web-site: primal carnage windows 8

  • destinia hack

    My blog post – website [Sitr49Eeesdf.com]

  • Excellent beat ! I would like to apprentice while you amend your
    website, how can i subscribe forr a blog website? The account helped me a
    accdeptable deal. I were tiny bit acquainted of this
    your broadcast offered brilliant transparent idea

    my site :: Wall Art (Denese)

  • I keep getting this error:

    09-05 13:42:49.692: E/AndroidRuntime(18972): FATAL EXCEPTION: GLThread 32912
    09-05 13:42:49.692: E/AndroidRuntime(18972): Process: com.ellusion.flyhigher.android, PID: 18972
    09-05 13:42:49.692: E/AndroidRuntime(18972): java.lang.NoClassDefFoundError: aurelienribon.bodyeditor.BodyEditorLoader
    09-05 13:42:49.692: E/AndroidRuntime(18972): at com.darkroomgames.states.Playtwo.(Playtwo.java:74)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at com.darkroomgames.mf.GameStateManager.getState(GameStateManager.java:38)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at com.darkroomgames.mf.GameStateManager.pushState(GameStateManager.java:51)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at com.darkroomgames.mf.GameStateManager.(GameStateManager.java:24)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at com.darkroomgames.mf.Game.create(Game.java:98)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at com.badlogic.gdx.backends.android.AndroidGraphics.onSurfaceChanged(AndroidGraphics.java:236)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1521)
    09-05 13:42:49.692: E/AndroidRuntime(18972): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1249)

    Is this happening to anybody else?

  • People everywhere are reporting that they are losing 10,
    12, even 18 pounds in a week due to the addition of these
    products and adhering to their strict rules.
    In fact, if anything else looks at the pictures of Christian Bale before he went on his diet.
    This will be accomplished while the egg cells are stored.

    my web site … hcg weightloss drops

    • Really? Bots are spamming this site? How the heck did this bot even find this site to spam? (I know how but I mean that’s a little sad)

  • [...] been mapping the surface tiles to box2d bodies with the help of the awesome tool Physics Body Editor. I have divided all the tiles up into separate image files, and then used those as background to [...]

  • [...] 0.0.5 and it is looking awesome! Several days ago I contacted Aurelien Ribon (Creator of legendary Physics Body Editor, which most of you probably already used) and he was cool with us making something like that into [...]

  • I have specified few great which are hundred percent free to use and dedicated to
    latest Pakistan and Indian fashion, daily updated
    fashion and you can also buy online via paypal and western union. They
    portion of people do not copy their styles from their elders or younger as they set their own style.
    It should not be a surprise that if some is more than interested in going
    for online shopping besides looking forward to gain the upper limit benefit by buying unique
    clothes, then it needs less mention that the is the thing that can help you realize the
    dream of buying clothes.

    Also visit my web-site :: celebrity dresses for prom uk

  • After a quick lunch and a brief nap back at the mobile home, we resumed fishing about three o’clock and fished all the way until dark.
    Given a choice, our primates will eat nothing but bananas. Her husband, Ian, is a pilot
    at the New River Air Station near Camp Lejeune.

    Feel free to surf to my weblog – marine refrigerator marina mile business park

  • Most people looking for about moving quotes do so because
    they have to move, and they know it. The storm hasn’t abated, but crisis brings opportunity.
    You would also get flexibility in terms of partial and full packing service.

    However, one thing you need to ensure before availing
    the services is that the company has a substantial list of contented clients.
    They help people in all relocation situations ‘ home shifting, shop moving, business relocation, industry shifting, etc.
    It also comes with an array of hi-tech standard features,
    including a rearview camera, Expanded View Driver’s Mirror, Bluetooth Hands
    - Free – Link phone interface, SMS text messaging function, Multi-Information Display (i-MID) and Pandora Internet Radio interface.

    Preponderance of evidence translates mathematically to 50.
    Professional call answering services enable offices everywhere to take
    advantage of the latest technology while maintaining a professional image.
    They follow customer oriented approach in their business process.

    Professional packers and movers of Delhi are completely safe and trouble option of relocation.

    Here is my webpage: best moving companies reviews dfw

  • Envision him happy and fulfilled experiencing with his team a victory this Sunday.
    3rd party logistics providers specialize in many areas including:
    . Professional removal agencies of Noida address this problem.
    This is to indicate all kinds of defects regardless of how simple or complex
    they are; way before the defects result into
    serious problem. They are important political cities that define national politics in their respective country.

    Crown Princess Mary of Denmark Introduces Newborn Twins.
    Data storage is expensive on such a large scale and has a direct relationship
    to costs associated with risk management, especially for companies that are exposed to litigation or government regulation. Our yarmulkes and Kippah Los Angeles show the distinguishing
    stamp of quality, and a half-century of practice and proficiency.
    You just need to cash back in some areas where one
    needs to switch. If this does not fix the problem, you may consider replacing the garage
    door opener with a new unit.

    Here is my blog post long distance moving companies in houston texas

  • Spot on with this write-up, I truly think this amazing site needs much more attention. I’ll probably be back agaiin to read
    through more, thanks for the information!

    Look at my webpage – Social Media Management Hitchin

  • It’s there and has to be dealt with, because there are few
    things worse than a pair of leaky waders. Do not make the mistake of cutting down the tree yourself
    or hiring a regular tree removal company to do the job.
    They could also garnish a car or a boat this
    way and put it into storage.

    my blog; 6 Chicken crock Pot Freezer meals

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>