Output to Java or ObjC / C++

General discussion about the R.U.B.E editor
Eddy8555
Posts: 42
Joined: Sat Apr 27, 2013 3:01 pm

Output to Java or ObjC / C++

Post by Eddy8555 »

I'm looking at Rube and it seems like a great tool. The only thing I'm not seeing is a way to parse the generated JSON to an actual Box2D language, such as Java or Objective-C.

Can this be done in Rube, or using an external tool, or do I have to write the code myself?
Eddy8555
Posts: 42
Joined: Sat Apr 27, 2013 3:01 pm

Re: Output to Java or ObjC / C++

Post by Eddy8555 »

OK, I apologize for not doing my research thoroughly. I'm seeing that it's possible to output to C++. But no Java. Is there a Java export planned?

Even with just C++ this is an amazing tool. Thank you.
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: Output to Java or ObjC / C++

Post by tescott »

You can export it to a JSON file and read that using Java. That's what I do.

See this as an example:

https://github.com/tescott/RubeLoader

--tim
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Output to Java or ObjC / C++

Post by iforce2d »

Did you see this page? https://www.iforce2d.net/rube/?panel=loaders

There is not much advantage to exporting to source code, because it locks you into a single use case in a VERY rigid manner, and requires you to recompile the program every time in order to have your changes reflected. The only reason the C++ export exists in RUBE is because it's part of Box2D already (b2World::Dump).
Eddy8555
Posts: 42
Joined: Sat Apr 27, 2013 3:01 pm

Re: Output to Java or ObjC / C++

Post by Eddy8555 »

Yes, I get that, iforce2d, thanks. I was going over it in my head and realizing it would create a mess to export to Java (or any other source code) unless I was able to develop the entire game with Rube, and export a final version. Which probably isn't possible.

tescott, what is the loader doing, exactly? And which of the loaders are you using? My intended platform at this point is Android, but I'm guessing it doesn't really matter because the loader wouldn't create the cocos2d integration anyway, right?

So I guess there are four possible workflows?

1. Export to source code directly from Rube.
2. Create the source code myself, using the Rube json as a guideline.
3. Using the loader -- which I'm not sure yet how.
4. Write a program to parse the json to Java / C++ objects. (or is that what the loader is doing?)

Do I understand this correctly?

Thanks for helping!
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: Output to Java or ObjC / C++

Post by tescott »

From the README.md on GitHub:
This is a RUBE scene JSON loader for libGdx. It reads JSON data output by RUBE and creates and populates a Box2D world with the bodies, joints, and fixtures defined therein. It includes support for custom properties and images.

This repo contains a fully self-contained Libgdx test for reference.
--tim
iforce2d
Site Admin
Posts: 861
Joined: Sat Dec 22, 2012 7:20 pm

Re: Output to Java or ObjC / C++

Post by iforce2d »

If you're using C++, Java or Javascript then workflow 4 has been done for you (that's what the page I linked to is all about) so all you need to do is workflow 3. To see how loading is done you can take a look at the examples on that page, and the info on the b2dJson loader here: http://www.iforce2d.net/b2djson/

Watch the first 3 minutes of this video to get an overview of what output the editor produces and what you would do with it: http://www.youtube.com/watch?v=WqLR4dFn1qE

There is a cocos2d (iPhone) sample available on the page I linked to, and you can see example usages of this in detail here: http://www.youtube.com/watch?v=0UsKnXuZ2nQ
Eddy8555
Posts: 42
Joined: Sat Apr 27, 2013 3:01 pm

Re: Output to Java or ObjC / C++

Post by Eddy8555 »

Thanks, Tim and iforce. I think I'm going to take it slowly, since I'm learning the framework and at this point I don't mind doing a bit of dumb work.

So I bought Rube, created an image, run around it with the vertices mode, exported the code to C++, and translated to Java (my project is for Android.)

Then I did the necessary setups, run the application -- and the image is there, but not moving. I'll start a different topic for that question.

Thanks again.
tescott
Posts: 68
Joined: Wed Feb 06, 2013 6:32 pm

Re: Output to Java or ObjC / C++

Post by tescott »

Eddy8555 wrote:
So I bought Rube, created an image, run around it with the vertices mode, exported the code to C++, and translated to Java (my project is for Android.)
What framework are you using for Android? The game I'm currently working on that uses RUBE is targeting Android also. I'm using libgdx for development, which means I could also target the desktop, HTML5, and iOS if I wanted to. Who knows, if the game is good enough, I'll probably do just that.

I assume you are converting the C++ code to a Java class. I'm curious why you would want to take this approach, unless you only plan to have a minimal set of levels and no expandability. Getting the JSON loader to work requires a little effort, but it will pay for itself with the flexibility you will have.

Cheers,
--tim
Eddy8555
Posts: 42
Joined: Sat Apr 27, 2013 3:01 pm

Re: Output to Java or ObjC / C++

Post by Eddy8555 »

Hi Tim,

Well, I stopped with the loader for two reasons. One, because I'm learning the framework and it's probably better for me to write code, over getting it written for me. Just for this initial, learning stage.

The immediate reason is that I'm not using libgdx. I looked at it, but wasn't sure which advantages does it have on the straight jBox2D, with its simpler, more straightforward API. So actually, why use libgdx?

Thanks!

Eddy
Post Reply