Ive created two classes: PhysicsRecorder and PhysicsRecordPlayer. Their purpose is to record the force and torque of the bodies at any given time (with a time interval) and store them in a file somewhere. Then using the PhysicsRecordPlayer, you can replay that back. Useful for things like ghost cars…
The usage is pretty easy:
PhysicsRecorder recorder = new PhysicsRecorder(dynamicPhyObj, 0.1f);
The parameters for the recorder are the object to get the forces from and the time interval in which to record. In this example, every 0.1 seconds, a recording will be taken. Saving the record is a simple matter of:
PhysicsRecordPlayer player = new PhysicsRecordPlayer(InputStream, obj);
This will apply the forces and torques recorded onto the object given which doesnt' have to be the same object as the one recorded.
Note: Only the force and torques are recorded, the linear and angular velocity are not recorded. If you consider a difference in the two initial startup conditions, setting the linear/angular velocity will make the simulation unstable and it wont look pretty :)
Anyways, its in CVS now, Enjoy!