Tying updates to framerate

SFAOK

08-02-2007 15:54:41

I am using FRAPS to record my simulation in action.

Sometimes I simulate a single creature at 200fps, other times 1000 creatures at <1fps.

Before I added physics to my engine, I could run FRAPS (setting it at 60fps), and it would record these frames in non-realtime, i.e even if I left the simulation running for an hour where the frame updates every 5 seconds, I'd return and have a completely normal 12 second video running at 60fps.

How can I make OgreNewt behave in the same way? I've made a simple environment, where I just throw more and more cubes into a pile. Obviously the framerate steadily drops torwards 1fps eventually - but when I play the video back, the slower the engine runs, the faster the cubes seem to move.

Is there any way to make the physics engine update consistently with the frame rate? I guess what I'm looking for is to set my variables for 'proper' results at 60fps, where a framerate below that causes a slow motion effect, and higher frame rates causing speed-up.

EDIT : I've reduced the linear and angular dampening to 0.001 (so the simulation is more deterministic), and tried some of the other solutions found in this forum regarding frame-rate, but I simply can't get it to work).

walaber

09-02-2007 02:37:15

well, you can call update() on the world each frame with a value of 0.016667, which is 1/60th of a second. that way, if the program runs at 60fps everything will be normal, but if the program runs slower, the physics will appear to be in "slow motion" as well.

if you capture each frame then, and play them back at 60 fps, everything will be at the proper speed.

I'm nor sure if Fraps works this way though, you might want to dump each frame into a .bmp from inside your code, and then compile them into a video later.