Networked Physics Demo

Post Reply
Guest

Networked Physics Demo

Post by Guest »

Glenn Fiedler has some information on networked physics on his weblog.

http://www.gaffer.org/archives/2004/12/


Glenn Fiedler wrote:
"December 28, 2004
Zen of Networked Physics
When i did my talk at AGDC this year, instead of using powerpoint i wrote my own presentation layer in OpenGL, then overlaid it on top of my networked physics demo program. 'How hard could it be?' i thought before i started. Oh if only i knew...

Crunch time aside, integrating my demo and presentation text allowed me to switch seamlessly between the two, which was absolutely fantastic because i had a load of visualizations already coded to help explain the main points in my talk. For example, i was able to show 'ghosts' of the cube so you could see the client, server and proxy (round trip) simulations simultaneously, showing how they always stayed perfectly in sync. I also had a nice visualization of the 'history buffer' of stored moves used for corrections with client side prediction, red and blue smoothed versions of the client and proxy, and was able to adjust latency and packet loss on the fly to show how the system behaved under varying conditions.

Now you too can play around with this demo program, and i'm releasing the source code too. You'll need to download the latest Visual C++ 2005 beta and platform SDK from MSDN if you want to build the source code yourself using my project files, but i've also included a binary for those who arent interested in such things.

So what does the demo do? Well effectively its a networked rigid body simulation of a cube, where the cube can strafe and jump like an fps character. The idea is that it is possible to generalize the techniques used in first person shooter netcode to network any physics simulation given that you keep the simulation deterministic, drive the physics from input and have strong ownership of objects by clients. Indeed you could easily apply the techniques presented in this talk to a racing game, flight simulator or anything else where each client controls a single object on the server.

The key techiques presented are 'client side prediction' (predicting physics ahead locally while applying corrections from the server in the past), which eliminates latency for the client, and 'important moves' which eliminate snapping due to packet loss. This demonstration implements both techniques perfectly, so it is possible to set 50% packet loss and 2 seconds latency and still have a perfectly smooth simulation on the client. I'm pretty proud of this achievement :)

To control the cube just use the arrow keys to move, and space to jump. Escape toggles presentation mode and pagedown goes to the next page in the talk. Various other keys exist to control the visualizations, the amount of latency and packet loss, and the important move system. See the 'readme.txt' in the zip file for details."

Cached copy of the demo is here:
http://www.erwincoumans.com/ftp/pub/tes ... hysics.zip
Post Reply