3D models 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
models.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 models in SRB2's main directory, or inside a subfolder within the models folder. It is important both files must be located in the same place.
models.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
models.dat looks like this:
SONIC SONC.MD3 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. If the skin to be replaced has the same name as an existing sprite prefix, the line should be prefixed with "PLAYER", for example:
- The second parameter,
SONC.MD3, is the file name of the model, or the file location of the model inside the models folder. Normally models are expected to be directly within the models folder, but they can also be within subfolders of this folder. In this case, the file name written in models.dat should be
subfolder/SONC.MD3, subfolder being the name of the subfolder in the models folder. Note that this parameter is also used to locate the skin file for the model, swapping the file extension with ".png" or ".pcx" – it is expected that the skin file is in the same folder as the model 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 on the north/south axis. This does not affect the actual position of the object the model represents. 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
- Models used in SRB2 require vertex animations to work.
- For character skin replacement models, you simply need to name your animations accordingly in your model file to match the animations they're for, with the prefix "
SUPER". For example, Sonic's walking animation is dubbed "
WALK" so his model's walking animation need to be named "
SPR2_WALK" while his super form's would be "
- Additionally, you can dictate whether or not an animation interpolates in the Sometimes interpolation mode by adding a "
+i" to the animation name. So Sonic's walk would be named "
- For any models that do not replace characters, they simply use the animations present in the model, in the order they are presented. You can still name and divide them if you wish, and add "
+i" to their name for interpolation.
3D 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
SONC.md3 should have a base texture called
SONC.png and a blending texture of
SONC_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.