New Flash to Box2D Layout Tool

I've been picking away at a layout engine for Box2D for some games we are working on. I recently had to document it for internal use, so I figured I might as well release it too. Coming here I see there is already an excellent tool that does this, oops : (. I'm not sure how similar or different this one is, but here it is anyway...

http://debreuil.com/v2d

This is based on a swf parsing engine I wrote a while back, so it works at the file format level to get the info out. That mostly means it is very extensible, but probably a bit complex for casual use. The code that converts things is fairly straight forward though, written in C#, so that is probably pretty hackable.

The Flex project there is still a work in progress (though fully functional). I will be upgrading it to allow creating and destroying defs at runtime, refactor it a bit, and adding runtime drawing of the movieclips (so they are mallable at runtime). I will also be generating a file format for this (rather than generated code) so it is portable to other runtimes -- first up will probably be XNA.

All the source (for swf parsing and this engine) is available at http://www.codeplex.com/swf.

Must be said, Box2D is totally awesome, so thanks for it Erin. And thanks skatehead the great conversion job. Flash is fun again : ).
the first link is broken
actually the server is down there atm, sorry

I've added the docs to the downloads section
http://www.codeplex.com/swf/Release/ProjectReleases.aspx?ReleaseId=16426
I just had a play around with this and it's pretty powerful. Compared to other existing kits, there are more steps involved in order to get a working world, but it have some features that the other kits don't - such as pulley joints.

I'll have another play around when I have some time.

Good work.
So you are accessing the shape-data in the .swf file directly (shapes with red-1px-outlines become Box2D shapes)? I wish there was a way to do that with actionscript.
yeah, I'm parsing the swf file directly, which allows getting shape data like that.

There sort of is a way to do that in actionscript. You can get the vector data either with a swf parser or jsfl. Then you can recreate it at runtime using the drawing api. I did a few things like this a long time ago [1], they are a bit dated and clunky though. I am planning on adding support for that with this box2D tool though. Then you could define a group with a number of bodies, and your visible shape could envelope/deform based on the bodies.

The drawingAPI is actually quite fast, if you minimize the changes per frame it works fairly well for this kind of thing.

Cheers,
Robin

[1]
http://debreuil.com/ASDraw -- converts swfs to drawing api code (not practical to use atm, upgrading into current tool)
http://debreuil.com/ASDraw/selectionToDrawingAPI.zip -- converts a selection (in Flash) to drawingAPI code (using jsfl)
Ah i see, I have never used JSFL, but it's used while developing, right? So you could turn a SWF file with shapes into vectors right before compiling or something like that?
yeah, it can be a compile step too. Essentially you need to generate data for things like "setLineColor(0xFF0000), moveTo(0,0), lineTo(100,100)...". That data is only accessible before you compile (unless you have a swf that parses a swf - though there is a fairly time consuming conversion that has to happen there as swf data is flat, where drawingAPI is layered).

Then everything else is just optimizing that data into something smaller, more portable, more dynamically accessible etc, depending on your needs.

It isn't a super normal way of doing things, but can be handy when you need it. I think the 'enveloping' would work great with Box2D.

Original thread: https://box2d.org/forum/viewtopic.php?t=1295