☰ Menu

An introduction to the Tokamak physics engine

As 3d games advance in complexity, it is commonly becoming a requirement to model realistic interaction between objects in the game world as they move, touch and collide with one another. The mathematical calculation required to perform these tasks is significant however and it is not a task that many game developers would wish to undertake themselves.

For example, think of the simple act of dropping a cube above a flat surface. The cube does not simply fall on to the surface and then stop moving, it bounces on the surface, perhaps at an odd angle that sends it spinning unpredictably back into the air. This is the type of movement that a physics engine attempts to model.

Examples of physics engines in games can be seen in many recent releases. One in particular that I found impressive was that of Grand Theft Auto 3/Vice City. The physics simulates many aspects of how the cars move in the game: how they react to jumps and falls, how they react when they collide with one another and even down to details like the car door bouncing on its hinges as the car accelerates before it has been closed. All of these are examples of how a physics engine can be applied to a game.

The Tokamak physics engine is a pre-built library that can be plugged in to any Microsoft Visual C++ application in order to perform the calculation required to simulate these object interactions. It has recently been released with a completely free licensing agreement, regardless of whether it's being used for amateur or professional development. There are some conditions that applications using the code must conform to but they are fairly minor compared to the power of the engine on offer.

You can read all about the engine and its license at the Tokamak physics web site, http://www.tokamakphysics.com. The SDK can also be downloaded from this site.

One thing that is fairly lacking from the SDK is the documentation. There is a brief document describing the API of the library and a number of rather complex-looking samples, but it can be quite impenetrable to begin with. For this reason I have decided to put this series of tutorials together.

The tutorials start with a simple DirectX frame work and build on that to explore some of the features of the engine. Although I am using DirectX for these tutorials, I've tried to keep the interaction between Tokamak and DirectX to a minimum. It should be very straightfoward to lift the Tokamak parts of the code out into, for example, an OpenGL framework with a minimum of changes to the code.

>>Tutorial 1, the DirectX framework>>


If you have any comments or suggestions regarding this article, please don't hesitate to contact me.

This article is copyright © Adam Dawes, 2003.
It may not be copied or redistributed without my express written permission.