A recent project led me to R.U.B.E (Real Useful Box2d Editor). This editor is any box2d developer’s ultimate dream-come-true. I am currently testing out a JSON/Processing pipeline that enables me to build the world in R.U.B.E and bring it to live in Processing, excited! I stumbled on this post and thought it is a good starting point for me regardless it was made for Flash. I used the JSON file in this tutorial as a base for my experiment.
Early experiment: jsonPbox2d.zip
[CAUTIONS]
1.This experiment doesn’t read images and joints.
2.When you create new body with fixture in R.U.B.E, make sure to give fixture/restitution a value other than 0.
3.After creating it, move the body away from (0,0).
R.U.B.E JSON file format: here
Logs:
12/03/13 When export, the restitution attribute is left out in the JSON file if the initial value is set to 0. This is problematic for me to write a JSON parser for it. I just found out a similar issue is also happening to position, if a body is created and stayed on (0,0), the position data will be just a float 0, not a JSONObject. linearVolecity has to same issue. [SOLVED] this can be solve by using .has function, but Processing 2.1’s JSON Library is missing this function right now…
12/12/13 Current Processing 2.1’s native JSON library is missing all the opt- functions, that makes the parsing even more difficult since some of the data in R.U.B.E’s json file switch between datatypes. I would have format the data on R.U.B.E side more carefully to avoid loading errors caused by JSONExceptions.
12/14/13 Now the parser can read joints too, PROGRESS!