It is recommended that you don't use the serializeSingleObject but use the btDynamicsWorld::serialize instead:
Code: Select all
//create a large enough buffer. There is no method to pre-calculate the buffer size yet.
int maxSerializeBufferSize = 1024*1024*5;
btDefaultSerializer* serializer = new btDefaultSerializer(maxSerializeBufferSize);
dynamicsWorld->serialize(serializer);
FILE* file = fopen("testFile.bullet","wb");
fwrite(serializer->getBufferPointer(),serializer->getCurrentBufferSize(),1, file);
fclose(file);
Note that while running most of the (unmodified) Bullet demos, you can press '=' key to serialize to a .bullet file, named "test.bullet". It will serialize all objects and constraints in the dynamics world. Some collision shapes are not supported yet (btHeightfieldTerrainShape for example).
Thanks,
Erwin