Currently the json file is always an entire world. It sounds like you want to have your player ragdoll defined separately to the level file so that you can load it at any time later, or load the same ragdoll into different levels without having to actually save it as part of each level?
The concept of having a group of bodies and joints as a coherent and instantiable object is something that will hopefully be added in a future version of RUBE. For now, what could be done is to slightly re-arrange the loading function in b2dJson, to take an already existing world and put the loaded bodies and joints into it. So instead of the current:
Code: Select all
b2World* b2dJson::readFromFile(const char* filename, std::string& errorMsg)
...you would have something like this:
Code: Select all
bool b2dJson::loadIntoExistingWorld(b2World* world, const char* filename, std::string& errorMsg)
You would load your level as normal to get a b2World* to work with, and then pass that to this new function to add the ragdoll from another file. I think you could use the same b2dJson instance, as long as the names did not collide it should work out ok. Bear in mind that you would probably have to move the ragdoll bodies to the right place after loading.
The full function is attached - I checked that it compiles, but I did not check that it works

Let me know if there are any problems and I will check it out properly. Or, if I have completely misunderstood what you're trying to do, let me know about that too
