Kekouan

Q2Model, Part 1

2022-11-28

Quake 2 Models

I should start by explaining what a Quake 2 model is.

In Quake 2 there are two sources of "geometries" that the game engine cares about.

There is the level itself which is a different topic entirely.

Screenshot from the first level of Quake 2

Then there are the occupants of the level:

Quake 2 Multiplayer Character Select

The enemies and other players (in multiplayer) are represented with a 3D Model.

Polygonal modelling – Points in 3D space, called vertices, are connected by line segments to form a polygon mesh. The vast majority of 3D models today are built as textured polygonal models, because they are flexible, because computers can render them so quickly. However, polygons are planar and can only approximate curved surfaces using many polygons. 1

Everything the game requires is contained within a couple of files.

MD2 Files

The above links go into far more detail than I will. The MD2 file contains everything required to generate an un-textured 3D Model. This is done by storing the model geometry (triangles), animations, and information about the texture mapping, and vertex normals.

The basic object used in mesh modelling is a vertex, a point in three-dimensional space. Two vertices connected by a straight line become an edge. Three vertices, connected to each other by three edges, define a triangle, which is the simplest polygon in Euclidean space. More complex polygons can be created out of multiple triangles, or as a single object with more than 3 vertices. Four sided polygons (generally referred to as quads) and triangles are the most common shapes used in polygonal modelling. 2

The important take-away here is that it's triangles, and how the graphics system draws a triangle matters greatly. The triangles are stored as 3 points in a 3-dimensional space (x,y,z coordinates).

Triangle Winding

The direction in which you unwind the points matters. This is used to determine which side of the triangle is "inside" or "outside". This applies to more complicated polygons as well, but we're going to be dealing with triangles for the most part.

Additionally there's a "header" at the start of the file that tells you information required to process it.

PCX Files

The other file required to actually display the model is the texture.

Imagine, if you will, a cube:

Cube with the primary colours on each side

If you flattened that cube out, you might end up with something like this:

A flattened cube, showing six sides, each with a primary colour

That is a crude version of how you can imagine a 2D image being applied to a 3D model.

UV mapping is the 3D modelling process of projecting a 3D model's surface to a 2D image for texture mapping. The letters "U" and "V" denote the axes of the 2D texture because "X", "Y", and "Z" are already used to denote the axes of the 3D object in model space, while "W" (in addition to XYZ) is used in calculating quaternion rotations, a common operation in computer graphics. 3

Great!

Each model will typically include several textures or variations on textures.

Grunt Texture Nightops Texture Sniper Texture

All of the textures for a Quake 2 model are stored in a format called PCX. It's a format originally from 1985.

That should be everything you need to know going into this.