Box2dJson loader fork now "working" with LibGDX

General discussion about the R.U.B.E editor
Post Reply
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Box2dJson loader fork now "working" with LibGDX

Post by rileyrg »

https://github.com/rileyrg/b2dJson

First pass at getting the b2d json loader working with libGDX b2d types.

A few things commented out where I couldnt see obvious libgdx structures to match but bodies and fixtures loading fine.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Box2dJson loader fork now "working" with LibGDX

Post by iforce2d »

This is excellent, thanks for sharing! :)
I've added it to the list of loader contributions.

Just a couple of points I noticed:
1. Since libgdx is using a more recent version of Box2D than JBox2d was ported from, it should be possible to get gear and wheel joints working (those sections are there but commented out).
2. It looks like some automatic text replacement was used to change the type "Vec2" used by JBox2d for the "Vector2" type used by libgdx. This has unfortunately also changed occurrences of the "vec2" type used in RUBE custom properties. For example, the "vec2" in places like this should remain unchanged:

Code: Select all

if (propValue.has("vec2"))
    setCustomVector(item, propertyName, this.jsonToVec("vec2", propValue));
As it is now, the following will never find any custom vector properties:

Code: Select all

if (propValue.has("Vector2"))
    setCustomVector(item, propertyName, this.jsonToVec("Vector2", propValue));
Ideally, variable names that refer to the RUBE vec2 type should also remain unchanged, (eg. m_customPropertyMap_vec2).
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Re: Box2dJson loader fork now "working" with LibGDX

Post by rileyrg »

Thanks for looking over. I'll address those things in the coming days.
sysex
Posts: 6
Joined: Sun Oct 25, 2015 1:20 am

Re: Box2dJson loader fork now "working" with LibGDX

Post by sysex »

hi! That's cool! I use libGdx and to load the scenes i use the
http://github.com/tescott/RubeLoader
and spend some time to get used to it.

I'm curious what is your loader doing specifically ? Sorry I'm new to Rube and confused which one I should take.

Thanks
Post Reply