Sonntag, 12. August 2012

First steps into iodoom3 & dhewm3

I got it!

I got enough files together to start iodoom3 and dhewm3, load a map and do some editing.
Here they are:

[[!! This file contains bigchars.tga from the Doom3 demo. Check the Doom3 demo licensing for how to handle that thing. !!]]

So what is this all about and how did I get to that point?

For university I'm doing a project that I described here:

Short version:
I try to build up a little SDK pack for iodoom3 and especially dhewm3.

The base engine is "id tech 4" and powers games like Doom 3 and Quake 4.
Both games had SDKs which could be used to create e.g. mods.
Now (late last year) the engine code is open sourced as iodoom3 ( Some people already improved it ( ( But still an easy ready to start pack to get into the engine and create e.g. a game with it is missing.

If you are on Windows and have Doom3 you have a quite good starting point. But without that you are alone in the dark.

Let's get started!

Where to start?
I started on Linux with the dhewm3 code base. Cloned it to me harddrive, run cmake, run make and I was ready to start.
Staring dhewm3 …
… missing file "default.cfg"
OK. Just an empty file called that way doesn't work. There must be at least one line inside. Mine says: "unbindall".
The next missing thing was "_default" material followed by doom_main.script and doom_defs.script.
Here is this base package:
dhewm3 is starting up to something where you can open the console with that " ` " thing. As I started dhewm3 from a terminal I could follow the output of the things I typed on the console. But that is not that much awesome. I works but it would be nice to see those stuff also inside. For that a bigchars.tga is needed. I grabbed mine from the Doom3 demo. You might use the one from e.g. OpenArena ( or build it by yourself. For that you would need to know how the original looks like. Later more on that.

You can also do a step and use the assets from here:
(Be prepared to have to change some code.)

Creating a map

Just hopping inside the console is not enough as you might guessed already.
The problem is:
How to create a map and what is needed for that?

To create a map I needed a map editor.
There are about two (2) for this engine out there. One is DoomEdit which is internally inside id tech 4. The other is DarkRadiant. I can't use DarkRadiant on my Linux version. The prepacked Ubuntu version has some dependencies my system doesn't meet and the version I compiled by my own crashes on startup. I did a bug report but don't see any patches or things like that. ( I also look inside the code where it crashes but currently don't know what happens around there and what should be expected.)
DoomEdit would be the next with one big problem: mfc
Because of that this editor is bound to Microsoft Windows. I got it running with wine but that wasn't a pleasant experience (same with DarkRadiant).

So on that point I was kind of forced to start my Windows partition.
I'm not quite shure if the dhewm3 version still has the editor inside for the Windows version.
From Alexander Zubov I got the tip to use the doom3.gpl verion:

So I took that. There are some things that makes it a bit less easy. But a long description can be found here:

Being a student helped this time. Instead of doing fancy stuff with the express version I took the professional version from MSDNAA.

Running iodoom3 on Windows

Setting iodoom3 up and getting it compiled was not that much of a problem. Still not as easy as I used to have it on Linux.
Running doom3.exe brought up the same things I had to add on Linux. So I reused those files.
Inside the console I started the editor by typing "editor" <return>. That was the easy part.
Because every time I clicked  somewhere the editor crashed. Debugging showed some weird accesses to brushes. Nothing that really helps on how to make it stop crashing.
Somehow I found out that the editor likes a file called "doom.qe4". This is how it looks like:

Thanks to that the editor didn't crash anymore (or at least just in some strange ways…).

(PS: There is also DarkRadiant on Windows. It works. They are nearly the same, but still different. )


Now that the editor was running I could build my first little room. Saving as map and … ERROR.
As I clone "doom3.gpl" I got that " . " in my path which wasn't liked much by the editor. Fixing that dot by removing it made that error disappear. (Bear in mind: no special characters inside the path.)
To create proc and cm files from the map 'dmap' is the best choice. It's called like this: "dmap"
Any errors and warnings will be reported. My first was a missing "_tracemodel" material. Also some warning about leaks showed up. Why? I guess it was because no player start point was set. But still I could try loading the map be calling: "map"
Again errors showed up.
Missing classnames, script objects, variables, functions…
Problematic are always crashes. On that way I got two crashes: one because of missing weapon definitions and the other because of missing gui. At the end I got one remaining crash (or better application shutdown because of a memory leak) that appears when a map is loaded and a "reloadEngine" is initiated. But that one is just with the iodoom3 version on Windows.
As mentioned before the player start point is important. For that a definition was needed. After creating that it could be used as an entity inside the editor.

On Windows I already had the little patch coming with the minimum assets applied. It just converts some error messages to warnings. That way joints for the player and ammo_type isn't needed. So I could get my map running.
Everything was black. By selecting the walls inside the editor and then the bigchars.tga from the textures panel those got that texture applied. Ingame I could see around.

Awesome. Right?

Back to Linux: Joints

Yes and no.
I took all those files I had created on Windows and put them on my Linux machine. Because the patch wasn't applied there I needed more to do.
Fiddling around I found out: I needed a model with bones.
And what do I need for that? md5mesh and md5anim files.
Blender can do it. Thanks do some fine people the exporter is ready to use:

The forum is full with stuff, also with a hint to read the readme that comes with the plugin. It helps. Just like the entries on the forum.
[Short hints:
→ you need three (3) bones
→ you need some keyframes
→ you need a mesh with material
→ on export select first the mesh and shift selecting second the bones
→ be prepared that files will be replaced without re-questioning]

That is how it can be done:

The bones must have names that correspond to the names in the definition.
And then it also run on Linux:

And all the additional files are just those:

Some of those will be created from the executable itself (like doomkey, xpkey, config.spec, dhewm.cfg, DoomConfig.cfg, editor.cfg, warnings.txt). Again those files can be found here:

[[!! This file contains bigchars.tga from the Doom3 demo. Check the Doom3 demo licensing for how to handle that thing. !!]]

The End

Clicking through I also found some stuff to export Blender to ASE which then can be used in id tech 4 and there are also tutorials in how to build maps using Blender and export them to map. (You still need to do things like entity placement inside a Radiant like DoomEditor.)

In the end I also tried opening the map inside DarkRadiant and it worked:

On my way through that all I took some notes on what missing thing I'm stuck next. Maybe it helps someone else when starting. Here it is:
// Wichtig!
// keine Sonderzeichen (z.B. '.') im Pfad

default.cfg [mindestens eine Zeile]
materials/ [_default material]

aus Demo:
textures/bigchars.tga [zum Anzeigen von Text in z.B. Konsole]
doom.qe4 [*.prj] [looks like:]
[benötigt, um Editor ohne Crashes zum Laufen zu bekommen]
dmap [zum "Erstellen" der map-Erweiterungen aus der .map]

// Hinweis:
// Player und Weapon sind bearbeitet, sodass bestimmte Dinge (Joints/Bones, Ammo_Types) weggelassen werden können

_tracemodel [Material, materials/]

classname worldspawn [def/default.def]
classname player_doommarine [def/default.def]
script object player [script/player.script]
for player: AI_* [script/player.script]
info_player_start [def/default.def :: def/info.def]
crash because of missin def_weapon[0-n] [def/default.def]
script object weapon_fists [script/weapon_fists.script]
def object def/weapon_fists.def
weapon_scriptobject for weapon_fists [script/weapon_fists.script]
for weapon_base: WEAPON_* [script/weapon_base.script]
fkt: RaiseWeapon in player [script/player.script]
!!( loading map second time → CRASH)
crash@GUI: needs guis/mainmenu.gui & msg.guis
shutdown because of memleak: map loaded & reloadEngine

Joint '' for bone_hips:
→ create a model with at least 3 bones
→ hip, chest, head

// Hinweis:
// Map muss (mehr oder weniger) mit DoomEdit || DarRadiant erstellt werden
// "kann" mit z.B. Blender erstellt werden (siehe KatBits)
// aber Entities etc. müssen über Radiant gesetzt werden

What's next?

I still have time left for this part of this project.
Creating a better overview would be nice. (
Where do I need to edit what to do something.

How to use the assets from the demos of Doom3 and Quake4 with this pack?
What is connected to what?
To start creating e.g. a game with an engine is always easier if there is already something. As the demos are free to get I guess it should not be to problematic to reuse them for that purpose.