cpSpaceSerializer (C++, XML)

Official forum for the Chipmunk2D Physics Library.
Post Reply
mobilebros
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am
Contact:

cpSpaceSerializer (C++, XML)

Post by mobilebros »

Hello, I just finished a rough draft of a C++ class that'll take a chipmunk space object and serialize/deserialize it using XML. The interface is simple, there is a load method and a save method. You pass the space to save. You receive a space from load (you can pass load a space as well). You can specify a delegate, if you want, to receive specific events like reading/writing a shape; this concept should allow you to synchronize your saving/loading efforts together. Every object in the XML receives an id (except the space), this is needed so constraints and shapes sharing bodies can identify their needed parts; the delegate can also be asked to create these ids (optional). Id's are of type long, perhaps at some point there should be the option of making them strings.

I've attached a modified chipmunk demo that demonstrates these capabilities along with some xml test files in the Debug and Release folder (so don't clean!). The modified demos are the Pyramid Stack and Joints tests, letter 'c' and 'r' respectively.

It's only a rough draft, it's very touchy and will crash if it does not find the fields it needs (probably). Just wanted to get some input on the matter, feel free to suggest anything. Oh.... I've only attached an OSX example, sorry!

[Edit] It appears I can't attach this, its too big (by just a tad) I'm hosting it here: http://www.mobile-bros.com/source/cpSpa ... -5.2.0.zip

p.s. I use a few STL objects and TinyXML to get the job done.
mobilebros
Posts: 90
Joined: Tue Aug 04, 2009 9:53 am
Contact:

Re: cpSpaceSerializer (C++, XML)

Post by mobilebros »

Does anyone have any opinion about saving/restoring the jAcc/jnAcc properties in the relevant joints, it seems like they make no noticeable difference, but perhaps there are certain cases......?
Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests