Using a RUBE scene as a body/fixture library

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

Using a RUBE scene as a body/fixture library

Post by rileyrg »

Looking for advice/pointers/war stories about the best way to utilise RUBE to hold body, fixture information where I can then duplicate that in my run time. I guess one obvious way is to create a body and mark it as inactive so its not part of the world. I can retrieve all information with getNamed() etc But how best and most efficiently to then duplicate it for use with multiple in game characters which have the same box2d characteristics? is there already a built in or recommended approach used in the b2d world? (I'm using libGDX if that alters anything).
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Using a RUBE scene as a body/fixture library

Post by iforce2d »

Using the b2dJson loader as documented below you can replicate objects, which is probably the most straightforward way:
http://www.iforce2d.net/b2djson/#replicating

For the 'RubeLoader' integrated into libgdx though, I don' t really know if there is an equivalent solution.
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Re: Using a RUBE scene as a body/fixture library

Post by rileyrg »

The libgdx guys recommened I stayed away from that but I'm not sure why. I guess I'll have to try and integrate the b2djson loader into intellij. Oh .. I think its because your loader uses jbox2d whereas libgdx does its own box2d wrapper and so the types clash. Anyone reading this used this loader successfully in a libGDX environment?
Last edited by rileyrg on Fri Jul 24, 2015 4:35 pm, edited 1 time in total.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Using a RUBE scene as a body/fixture library

Post by iforce2d »

It could be because it does no image loading for you. You would have to handle the loading of images yourself. If they have a better reason, it might be helpful for me to hear about it.
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Re: Using a RUBE scene as a body/fixture library

Post by rileyrg »

I handle images myself using texture packer and sprites which I map back to the b2d bodies and fixtures so thats not an issue. I re-edited my response above - it's a type issue I think. I'll have another crack at using it though but I'm no Java maven and soon come unstuck when different libraries start type clashing.
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Re: Using a RUBE scene as a body/fixture library

Post by rileyrg »

Well, I tried but it ended up fruitless. The JBox2d types are incompatible with the libgdx wrapper classes. So using this b2djson loader is a no go. Unless someone with more experience than I have can point me in a better direction. :( So this means I'll have to try and implement my own replication at a later date I guess.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Using a RUBE scene as a body/fixture library

Post by iforce2d »

True, the 'RubeLoader' and the b2dJson types and loading method are not interchangeable, you'd need to use one or the other.
rileyrg
Posts: 54
Joined: Sun Jul 19, 2015 11:42 am

Re: Using a RUBE scene as a body/fixture library

Post by rileyrg »

No. Take the rubeloader out of the equation. The LibGDX classes are not compatible with the JBox2d ones used in the B2DJson loader.
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Using a RUBE scene as a body/fixture library

Post by iforce2d »

ah of course, right :D
Post Reply