Game physics

The game physics project was two-fold.

First we implemented basic physics in an existing framework based on the graphics engine Ogre3D1 and the physics engine ODE2, encompassing collisions based on physical properties of objects and contacts, such as bounciness and slipperiness.

Wind, air friction and spin effects were all simulated as follows. Wind is represented by applying a force on all objects in the scene according to a vector defining the wind direction and speed. Air friction on the other hand is implemented by considering both laminar flow for slow-moving objects and turbulent flow for fast-moving objects as per 3. Finally, we simulated spin effects by implementing the Magnus effect, a phenomenon which causes spinning objects in a fluid to experience a force perpendicular to linear motion. This can create a lift force.3

In the second part of this project, we implemented client-server model in the same framework. By letting a server perform the computationally heavy physics simulation, we only send update packages to the client at set times. To fill the gap between packages, we perform dead reckoning on the client, i.e., we attempt to predict the motion of objects based on their current speed and acceleration. This prediction can be linear (first-order), taking into account linear and angular velocities, or even second-order, which also uses the acceleration for predicting object movements. Furthermore, wind and spin effects were also predicted using simple physics.

To prevent snapping - i.e. jerky object movement - every time an update package is sent, we use convergence, which interpolates between predictions made on previous and current update package information to smoothly perform this transition.

It turned out that the amount of data the server had to sent could be significantly reduced using the prediction algorithms, while still maintaining acceptably accurate physics simulation. This approach is therefore especially well-suited for online games, where servers need to send large amounts of data to the clients. The number of updates regarding the physics simulation can this way be drastically reduced.

This project was implemented using C++ and OpenGL.

[1] OGRE - Open Source 3D Graphics Engine (2012). ogre3d.org.

[2] Open Dynamics Engine (ode.org, 2007). R Smith.

[3] Physics for Game Developers (2002). I Matthews, S Baker.

This project was finished on the 29th of June, 2012