Technical Director Kicks Off Game Physics Diary
In case you missed it, Black Prophecy Art Director Nick Ebenhoch recently wrapped up his Art Direction Developer Diary series. Reakktor Media has decided to keep the dev diaries coming with a mechanical series by Technical Director Cyrus Preuss. You can read his first Game Physics entry after the jump.
Preuss' first post is mainly an introduction to the basics of physics programming. While the entry doesn't discuss Black Prophecy in detail, it does set the stage for Preuss to go behind the scenes of the game's development process in future posts.
Hi, my name is Cyrus Preuss and I am the Technical Director at Reakktor Media. Before taking that position, I was responsible for the integration of game physics into the game engine. Basically I am still responsible for this area as physics programmer although the main part of the work is already done.
In my developer diary I would like to outline the "mechanical side" of our game and give you a rough overview about how the single areas work hand in hand in order to create a whole picture. Some of the used terms will sound very technical but I will try to explain them as best as possible.
But one thing at a time. Where does everything begin?
Game Physics
A well known game producer once said “Hey, what’s so difficult at integrating physics into a game? It’s completely easy. For example: I clap my hands – collision – and it works…”. As far as I know he raised some uncomprehending and puzzled glances from the present programmers. If it would be that easy then some programmers would be redundant. Actually physics do work very simple at the first glance, but to deduce how easy or difficult it is to integrate physics into a game from that is of course simply wrong.
Physical objects
To understand what game physics are about it is necessary to explain some concepts first.
Rigid Bodies
A rigid body describes the physical model of a not deformable body. The essential characteristics are specified by its mass centre, its mass, as well as its mass distribution. Ideally the mass distribution is deduced from the so called collision geometry. Simplifications of the mass distribution happen as approximation by simple primitives, for example spheres or boxes. A single rigid body is neither limited in its movement direction nor in its rotation axis. On one hand the movement of a rigid body is determined by collisions with other Rigid Bodies. On the other hand it is possible for the programmer to attach forces and torques with different characteristics. Rigid bodies in relation to Black Prophecy are, for example, player ships or projectiles.
Constraints
Rigid bodies can be correlated with each other by constraints. These constraints are limiting the involved rigid bodies in their freedom of movement. The simplest example is a fixed constraint, which firmly interconnects two rigid bodies. Thus both bodies cannot rotate separately or change their relative position to each other anymore. As constraints do not play a role for Black Prophecy at the current time we can set them aside in the further course. Ragdolls and their articulated joints are a popular example for the use of different kinds of constraints.Geometries
Rigid Bodies can be assigned to different kind of geometries. Here we have primitives like boxes, spheres or cylinder but also general convex and concave geometries. Special forms are “summarizing” geometry objects that allow assigning several primitives to a rigid body to form complex objects of every imaginable structure. The complexity of the collision geometry has direct impact on performance, therefore the following assertions apply for the setup of collision geometries:
- As simple as possible
- As few as possible primitives
- Use of primitives with the preference: Sphere -> box - > cylinder -> convex geometry
The collision geometry creation process can theoretically be completely automated.
However, due to restrictions with regards to the computing capacity during the runtime of the game, there’s no way around manually preparing and optimising the collision geometries during their creation. This means that the process of collision geometry creation happens semi-automatically in a 3D modeling application, whereby the artist puts the collision geometries in place based on predefined rules. As different factors, especially the intended performance and gameplay functionality have to be considered, it is not possible to define these rules coherently.
That’s it for the first part and introduction to the basics of the game physic. In the upcoming parts of my developer diary I will point out and explain further important components. But you don’t need to be afraid that I will confront you with highly complex equations or formulas. With this diary I also want to provide a look behind the scenes to those who didn’t take the advanced physics or mathematics courses in school.
Stay tuned!