Two questions - freezing the physics world / rewinding

nathanwilliams6

03-04-2006 10:54:27

I got two semi related questions, but first i will lay a little ground work and let you know what i have so far.

I have created a class to represent a physics component manager, which handles the creation of all physics components (including visual side and ogrenewt/newton side), it deals with all teh tidying up and keeps everything in a organised fasion which is easily accessable to myself.

i want to add a function to freeze the world, while i could loop through each element i have created and call freeze on them, i was wondering if there was already a freeze world command hidden in there somewhere ? (if not, is looping through the elements and freezing them the way to go about it ?)

secondly, i was thinking of implementing a rewind function in the near future to my manager. Whats the best way to do this ?

anyhelp and suggestions is greatly appreciated
thanx
nathan williams

praetor

03-04-2006 21:35:35

1) You could easily freeze the world by... stop update newton. Just get rid of whatever is calling NewtonUpdate, and when the freeze stops put it back in place.

2) The way I've seen in the past is to turn off physics during rewind. While playing you can keep a list of animation nodes. These nodes basically hold position and orientation info. They should be "recorded" at regular intervals. When you rewind, you go to the end of the list and consume it, reseting the held info (position & orientation) at regular intervals linearly interpolating between the recorded data. This technique lets you rewind and play back, and with small enough time-steps the linear interpolation should be good. More accuracy can be had by recording velocity as well (and, of course, even more by recording acceleration!)