Difference between saving and exporting



R.U.B.E scene files (.rube) and exported 'raw info' (.json) files are both JSON format plain text. The overall structure of these files is quite similar too, but there are important differences in how some parts of the scene are stored. This topic is to explain the need for keeping two separate file types. The main difference is in their representation of fixtures.

When defining polygons for Box2D, they should be convex, with a maximum of 8 vertices and wound counter-clockwise. By contrast, R.U.B.E allows you to create polygons without worrying about any of these requirements. Additionally, R.U.B.E lets you switch the type of a fixture from polygon to line, loop etc at any time, and set a 'radius' for all shape types. See the first part of the editing fixtures topic for some examples.

To help explain the differences between R.U.B.E files and the raw info output they produce, let's look at a simple example polygon fixture, and the JSON each type of file uses to represent it.

In the R.U.B.E scene file (.rube) this is stored as six vertices, a type, and a radius (the value for radius is implicitly zero), while in the exported raw info it becomes three individual fixtures (properties such as friction, density etc have been omitted for clarity):

To change this to a loop shape only one property in R.U.B.E is altered, but the resulting output raw info is very different.




Future changes
As well as the important differences shown above, the R.U.B.E scene file may also undergo changes in the future to support storing other information about scenes, and other shape types such as splines. On the other hand the raw info file format, being intended as an interface to external programs for creating Box2D worlds, will be kept as stable as possible.