File structure of id Tech 4 engine
After quick introduction to id Tech 4 and its important details, we will focus first on how game content is stored and used by engine. If you have any experience with previous engines (Quake 2 and higher) from id Software, here will come handy. The principle is very similar. The entire game (executable file, libraries, config files etc.) is stored by default Windows install on the following path.
C:Program FilesDoom 3
In this directory you can find executable file “Doom3.exe” and subdirectory named “base”. Maybe you can find there more other files or subdirectories, but they are not significant for us. If you open subdirectory “base”, you will find different types of files. Below is description of these types.
.cfg – Configuration ASCII files aka “configs”. These files contain engine settings (video resolution setting, graphical quality, sound setup, settings of input devices etc.). Config files can be edited in a text editor.
.pk4 – Files containing the game data - there are two kinds these files. Ones are named like “game##.pk4” and other “pak###.pk4”, where # symbol represents any digit. Files that start with “game” in name contain game libraries, other with “pak” in name contain compressed game content.
Note: In the “base” directory there is also another ASCII file named “doomkey”. This file contains your game license (so-called CD-KEY) for Doom 3.
Further, we will look on “pk4” files containing game content with greater detail. These files are nothing “special”; they are just Zip format archives with changed extension. If we rename them back – change extension from pk4 to zip – we can open them.
Tip: For opening and extracting content of pk4 files we can use any Zip-compatible utility. I recommend free open source program 7-Zip.
When for example file “pak000.pk4” is opened, we can see that within this archive is lot of files and directories. There is directory called “maps” which contains maps, there is directory “textures” that stores textures and so on. As you can see names of files and directories speak for themselves.
Also it is good to know, that if several pak-files contain a file with same name, the engine will use that file which is located in the pak-file with the highest number. So if we have two identically named textures – one blue texture in “pak007.pk4” and other red texture in “pak008.pk4” – engine will use just the red texture.
Related article: Tutorial 02 - Tools and Editors
Chapters: