Convert Quake family model formats to JSON and vice versa.
I made this mainly to better understand the model formats themselves, and by chance also write C++ parsers and loaders for them, so they can be used as a basis for other programs.
As for the practical uses, the user has the ability to directly edit the model without fear of damaging the integrity of file, like with a hex editor. The program is best suited for small edits like skin paths or flags.
The reason why the JSON format script is in Python instead of C++ is because it uses RegEx to accomplish its task, and Python is simply much more efficient at doing so.
- Quake 1's MDL files (IDPO ident)
- Hexen 2: Portal of Praevus's MDL files (RAPO ident)
- Quake 2's MD2 files (IDP2 ident)
- Heretic 2's FlexModel files (.fm extension and original structure)
- Kingpin: Life of Crime's MDX files (IPDX ident)
- Daikatana's DKM files, both versions (DKMD ident)
- Quake 3's MD3 files (IDP3 ident)
- Serious Sam 1's MDL files (MDAT ident)
Drag and drop a model file to create a JSON file, and vice versa. If using the command line, you can just pass the path of the file you want to convert as an argument.
After you have a JSON file, you can use format_json.py to remove the unnecessary spaces and newlines from the file; this decreases the file size significantly. Doing this is optional though.
The resulting files should be identical to the original model files, with the following exceptions:
- Char arrays will often have trailing garbage data after the null terminator in the original file, while this program outputs a clean array of null bytes instead.
- Kingpin's MDX models have an offsetDummyEnd value, that should be identical to the regular end offset. In some official models though, they have a bogus value, and they can get lost during conversion, as the program calculates all the offsets from the data size.
- Some Serious Sam 1 models were originally exported with little regard to some of the data fields, and thus they often contain NaN floats and extreme values. The JSON serialiser turns NaN into null values, which the MDL exporter turns back into NaN floats, albeit with a likely different exact hex value.
None of the above have any functional effects on the models themselves, and the games will load them like their normal counterparts.
If using MSVS, open the SLN. If on Linux, you can use the included shell script. Otherwise:
g++ main.cpp Q1MDL.cpp H2PoPMDL.cpp Q2MD2.cpp H2FM.cpp KPMDX.cpp DKM.cpp Q3MD3.cpp SS1MDL.cpp -o QMDL-JSON-Tool_linux -I.
This program was made by Jakub Majewski.
JSON parsing library was made by Niels Lohmann.
Quake was originally made by iD Software; its engine and model format was mostly devised by John Carmack. Most formats here are derivatives of it.
RAPO and FlexModel formats are by Raven Software.
MDX format is by Xatrix Entertainment, aka Gray Matter Interactive.
DKM format is by Ion Storm.
Serious Sam 1 and its model format is by Croteam.
The information on how to parse the model files was loosely based on the following sources:
- http://tfc.duke.free.fr/coding/mdl-specs-en.html
- https://formats.kaitai.io/quake_mdl/
- https://github.com/amroibrahim/DIYQuake/blob/main/Quake/Notes005/notes/README.md
- The official Quake 1 source code release.
- The source code of Hammer of Thyrion, a Hexen 2 source port.
- http://tfc.duke.free.fr/coding/md2-specs-en.html
- https://icculus.org/~phaethon/q3a/formats/md2-schoenblum.html
- The official Quake 2 source code release.
- https://github.com/cholleme/DaikatanaTools/blob/main/DaiMdlV2/models.pas
- https://www.moddb.com/downloads/daikatana-to-quake-2-model-converter
- https://github.com/TrenchBroom/TrenchBroom/blob/c2ae5a5b48c345d06e315571cd4da30ef04748e5/lib/TbMdlLib/src/LoadDkmModel.cpp
- Assistance from the Beta 1.3 patch team.