3. Quake engine
3.1
Entities
In Quake everything consists of entities.
Every different part of the environment is an entity. These different parts
are structural systems, items,
mosters, the player self etc.
There are static and dynamic entities.
The static entities can't change after they have been created. Most often
they only provide the Quake environment with extra visual or audio effects.
The dynamic entities can change after being created. There is a defined
behaviour, or there are rules for the behaviour of these dynamic entities.
There is always one dynamic entity called
the world. (Actually it is static but a dynamic entity is used.) This entity
is the largest part of the Quake environment (the map layout). It defines
the visual representation of rooms where the other entities will move around.
Besides this world entity there are a number of other dynamic entities
like enemies, structural systems, items, players etc. All entities used
by Quake have been listed here.
Most of the entities have a visual representation
in the Quake environment. There are three different visual representations
used in Quake. The first is the BSP (Binary Space Partitioned) model. This
model can move around in Quake but can't change shape. The second is the
alias model (MDL). This model can move around and can also change shape.
Objects that are too complex or detailed to create a model for are represented
by sprites. The sprite (bitmap) is the third type of visual representation
used in Quake. A sprite can move around and has a specific orientation.
The entity called the world doesn't move or
change and uses a BSP model. The doors, elevators and other structural
systems also use BSP models. The monsters and players use alias models.
Together with such an alias model a set of animation frames is defined.
For a player there are several sequences of animation frames representing
for example a walking player, a standing player, a player shooting with
the shotgun etc. Air bubbles and explosions are quite detailed and use
sprites for a visual representation.
In the Quake environment the entities can
produce sounds. Most dynamic entities only make sounds when certain events
take place. Some of the entities continuously make noises. For instance
a teleporter producing sounds, or other
entities which provide the environment with the noise of the wind.
Besides the visual and audio aspects of
entities there is also a volume representation. These volume representations
are used by the Quake engine to calculate collisions between entities.
The entities using BSP models have the same volume representation as visually
would be expected. Because of their changing shape and their greater complexity
the entities using alias models don't have a volume representation as one
would expect from the visual one. Entities using an alias model have an
axial bounding box which is used for collision detection. Such a bounding
box consists of six bounding planes each parallel to one of the axis planes
from the right handed coordinate system used by Quake.
3.2
Quake engine
Quake uses a client - server model. The server
deals with the behaviour of entities. The greater part of the behaviour
or a set of rules for the behaviour of the entities is defined in a separated
game library. One of the things not calculated
by the code in this game library but by the server is the detection of
collision between entities. The behaviour of the entities results in visual
and audible changes. These changes of the entities are sent to the clients
by the server.
Every player runs a client process. The
visual and audible changes received from the server are processed by the
client process. This process provides the player with a 3D view of the
Quake world and the audible changes respectively. To create the visual
output the client process uses a combination of binary space partitioning,
visibility lists, z-buffering and texture mapping. The client process also
records the player input and sends it to the server. This player input
is used by the server to change the behaviour of the player entity.
model of the server with one client
3.3
Game library
Quake uses a separated game library which
defines or sets rules for most of the behaviour of entities. This library
is stored in a separate file (progs.dat). The code in this library is not
directly executed by the operating system but interpreted by the Quake
server process. This is done because of portability reasons. The same "progs.dat"
can be used for every computer system that runs Quake. The code stored
in the "progs.dat" is derived from a language called QuakeC. This language
is a variant of the well known language C.
Beside that the code of the game library
is interpreted by the server process there is a two way communication between
the library and the server. There is only one way the communication can
be initiated from the game library:
-
The communication initiated from the game
library is done with "built-in" functions. These functions can be called
from within the QuakeC code. The "built-in" functions are used to get information
from or activate parts of the Quake server process.
For the other direction of the communication
the server is able to activate several things in the game library. This
is done regularly or when certain events take place. There are several
different ways the server can do this:
-
The game library must contain a set of functions
with predefined names which the server can call at any time. Some of these
functions are called regularly, others are called when certain events take
place, for instance a new player enters the game in multiplayer mode.
-
The game library may contain so called "spawn"
functions. These functions are called by the server process to spawn entities
when the game is started.
-
In the game library the entities can have
a "think" function and a field to set the next time to call this "think"
function. When the local Quake time reaches the point of the next think
time of a certain entity the server activates the "think" function of the
entity. Mostly the time between two activations of the 'think' function
is 0.1 seconds.
-
Entities can also have a "touch" function.
A 'touch' function is activated by the server when an entity collides with
another entity. When an entity has a "blocked" function it is activated
when the entity is blocked in movement.
-
Beside the server's ability to activate certain
things it can also change several things. When an entity has velocity or
angle velocity the server regularly changes the position and/or angles
of the 3D representation of the entity according to the time elapsed since
the previous change. There are also several global variables (called system
globals) in the game library the server can change at any time. One such
a global variable stores the time.
A more detailed documentation of the QuakeC
language can be found in the QuakeC manual
1.0 and the QuakeC specs 3.4.