Creating a COLLADA physics snapshot

From Physics Simulation Wiki

Jump to: navigation, search

Creating a COLLADA Physics snapshot

It is often useful to be able to export a snapshot of an existing Bullet simulation. This is possible and very easy using the BulletColladaConverter. It includes collision objects, rigid bodies and some constraints.

1) Add the following folders to your include search path:

Bullet/Extras/BulletColladaConverter
Bullet/Extras/COLLADA_DOM/include
Bullet/Extras/COLLADA_DOM/include/1.4
Bullet/Extras/LibXML
Bullet/Extras/LibXML/include

2) Add libxml,libcolladadom, libBulletColladaConverter to your project. Visual Studio developers can add the

Bullet/msvc/x/libBulletColladaConverter.vcproj,
Bullet/msvc/x/liblibxml.vcproj and 
Bullet/msvc/x/libcolladadom.vcproj

projects, and add those to the project dependencies.

3) At the top of your file, include this header file, from Bullet/Extras/BulletColladaConverter.

#include "ColladaConverter.h"

Just before your stepSimulation, or after stepSimulation, insert this code snippet:

static bool justOnce = true;
	if (justOnce)
	{
		justOnce = false;
		ColladaConverter converter(m_physicsWorld);
		converter.save("snapshot.dae"); //store it in the current working directory
	}

That is all. If you want to save the file to the root of c:\ under Windowss, use

converter.save("file:///c:/test.dae");

If you have an issue, you can zip the .dae file and attach it in a forum issue.

Personal tools