MD2 models are 3D models that can replace sprites in OpenGL. In SRB2, to use a model, three things are needed: the model itself, a skin for the model (usually in PNG format, but PCX is also supported if no PNGs are available), and a file named
md2.dat that determines which sprites are replaced with what models. Apart from the file extension, the names for the model file and the skin file must be identical. Both files must be placed inside a folder named md2 in SRB2's main directory, or inside a subfolder within the md2 folder. It is important both files must be located in the same place.
md2.dat is a user-created configuration file that assigns the models to sprites. It must be placed in the main SRB2 directory. Only one such file is needed, regardless of how many models are loaded. For each model, one line of code must be added to the file.
A typical line of code in
md2.dat looks like this:
Sonic PLAY.MD2 3.0 0.0
The line contains four parameters:
- The first parameter is the name of the sprite set or skin that the model replaces – in the example above the skin
Sonicis being replaced. When replacing a sprite set, the four-character sprite prefix must be entered here, e.g.
SPR_THOK. Note that
SPR_PLAY, the base sprite set for all player sprites, cannot be replaced with a model – the sprites for each individual character skin used by the player have to be replaced instead. When replacing a skin, the skin name set in name for the
S_SKINmust be used here.
- The second parameter,
PLAY.MD2, is the file name of the MD2, or the file location of the MD2 inside the md2 folder. Normally MD2 models are expected to be directly within the md2 folder, but they can also be within subfolders of this folder. In this case, the file name written in md2.dat should be
subfolder/PLAY.MD2, subfolder being the name of the subfolder in the md2 folder. Note that this parameter is also used to locate the skin file for the MD2, swapping ".MD2" with ".PNG" or ".PCX" – it is expected that the skin file is in the same folder as the MD2 itself.
- The third parameter,
3.0, is the overall size of the model displayed in-game.
- The fourth parameter,
0.0, is the offset of the model. Most models display correctly at 0.0, but some need an offset to display in the right place.
Authors usually provide the correct parameters and all that needs to be done to use them is to enter the parameters into
MD2 models that replace sprites for objects that have the ability to change color can be made to change color by including an additional blending texture. This texture should have the same name as the normal texture, but should end with
_blend.png. For example, a model called
PLAY.md2 should have a base texture called
PLAY.png and a blending texture of
PLAY_blend.png. This texture should be a grayscale texture; lighter areas of the texture are closer to white, while darker areas of the texture are closer to black. Any transparency in the texture makes the model use the colors from the base texture instead of the blending texture. If the object does not have a skin color currently set, the model will use the base texture only and no blending will be performed.
- Misfit Model 3D – One of the most used 3D modeling tools in the SRB2 community.