Nape importer

General discussion about the R.U.B.E editor
Post Reply
[zeh]
Posts: 2
Joined: Mon Aug 12, 2013 5:20 pm

Nape importer

Post by [zeh] »

Not sure if it's ok to post this here, but I guess it'd be helpful for other people:

A while ago I started using R.U.B.E. to create levels for an (ActionScript 3) game prototype I'm building (thanks so much for this tool!). At the time, I was using Box2D for the game prototype, and I build a R.U.B.E. json loader just for that. However, for several reasons, I ended up moving the game to using Nape. I didn't want to lose my original workflow though, so I ended up porting my R.U.B.E. loader to support Nape. What it does is that it not only loads the R.U.B.E. scene, but it also tries to "translate" the data to what Nape supports as well as possible (creating shapes for the original fixtures, inverting the y axis, creating the specific kinds of joints, creating polygons in place of lines, etc).

It's not 100% done, and I'm still adding features (some joints are still unsupported, and some physics properties are lost), but I figured it's already quite useful.

The (AS3) source code is here:
https://github.com/zeh/as3/blob/master/ ... romRUBE.as

This post has more information:
http://zehfernando.com/2013/loading-and ... -nape-as3/

A R.U.B.E. reference scene:
Image

And how it currently looks like once loaded in Nape:
Image

Criticism and knowledge/code contributions are welcomed too.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Nape importer

Post by iforce2d »

Thankyou Zeh, this is pretty big. I only had Chipmunk on my radar as another physics engine to target, so it's nice to see something quite unexpected show up like this, and it seems quite complete too. Good job!
[zeh]
Posts: 2
Joined: Mon Aug 12, 2013 5:20 pm

Re: Nape importer

Post by [zeh] »

Thanks man! Yeah, in a way Nape is not very popular - it only runs in AS3 and Haxe after all - but it's definitely the most important/popular physics engine in Flash right now (it's also very fast). Luckily most of the Box2d paradigms translate pretty well to Nape, and of course your JSON format is really easy to use, so "porting" that was a snap even if I don't have a huge experience in Box2d or Flash. Your tutorials helped immensely of course so thanks for that too.

My game prototype his working pretty well with it and I've already done some updates to the class (to support prismatic joints). I'm glad I can still use R.U.B.E. with it. I feel like I'm doing Quake levels again (a lot of the game's custom behavior is determined by user properties in random bodies). It's really a nice editor.
Post Reply