ScalaBox2D is going to get an SVG scene importer soon. This will let you draw a scene in Inkscape and load it as a Box2D world in ScalaBox2D. I already pushed a very basic version of this to GitHub. It uses Slick‘s SVG parser and has many limitations as of now, but you can already draw a Scene like this:

And bring it to life in a ScalaBox2D application:

Currently every circle, box or polygon that has a red (#ff0000) fill will be turned into a dynamic body, the rest will be static bodies. There are also some limitations to the shapes, including: polygons must be convex, and have at most 8 vertices (or they’ll become static edges). Ellipses/arcs are not supported, only circles. You may get exceptions when loading some shapes.

The goal right now is to make this as robust as possible, so you can run the ScalaBox2D testbed and load (almost) any SVG file saved by Inkscape into it. After that, I’ll add support for loading scenes from game code and tying the physical bodies to game objects.

The code for the app looks like this:

import org.villane.box2d.svg._ import org.villane.box2d.draw.DrawFlags._ import org.villane.box2d.testbed.slick._ object SVGApp { val scale = 15 def main(args: Array[String]) { val loader = new SlickSVGSceneLoader("C:/drawing-1.svg", scale) val world = loader.create val flags = Shapes SlickDisplayWorld.runWithSimulation(world, false, flags) } }