MD3
==

There are two different ways to use an md3 model in Sauerbraten:


1.  md3 without configuration    

Go this way if your md3 has no animations (static) and takes only one texture.
   
Your md3 files must be located in a directory in packages/models/.

You must provide a skin (either skin.jpg or skin.png) and the md3 itself (tris.md3).
Optionally you may provide a masks.jpg that holds a specmap in the R channel, a glowmap in the G channel, and a black B channel (future use). The engine will apply it automatically.

If either of these files is not found, Sauerbraten will search the parent directory for them. For example, if for the flags/red model, the tris.md3 is not found in packages/models/flags/red/, then it will look for tris.md3 in packages/models/flags/. This allows the sharing of skins and geometry.


2.  md3 with configuration

You need to set up your md3 this way if it has animations, multiple skins, or if you want to make use of other configuration possibilities.

You must place a md3.cfg text-file in a directory in packages/models/. This file specifies which models should be loaded, linked, etc.

The following commands may be used in the md3.cfg:


md3load model_path
    
    This command loads the first part of your model. As example, this could be the head.md3 of a playermodel.
    "name_path" is the path to the md3 file to load, its recursive to the location of the md3.cfg.


md3skin mesh skin_path masks_path

    This loads a texture and assigns it to a mesh of the last loaded model (md3load).
    "mesh" is the name of the mesh you want to assign the texture to.
    "skin_path" is the path to the texture, its recursive to the location of the md3.cfg.
    The optional "masks_path" sets a texture for spec/glow maps as above.


md3anim anim frame numframes speed

    This assigns a new animation to the last loaded model (md3load).

    "anim" is the name of the animation to define. 
    Any of the following names may be used:
        dying
        dead
        pain
        idle
        idle attack
        run
        run attack
        edit
        lag
        jump
        jump attack
        gun shoot
        gun idle
        mapmodel
        trigger

    "frame" is the frame number the animation starts at.
    "numframes" is the number of frames in the animation.
    "speed" is the relative speed to run the animation at. This is optional and defaults to 100.

    Example: md3anim "jump attack" 131 6 15
        Defines a "jump attack" animation starting at frame 131 with 6 frames and running at 15% speed.


md3link parent child tag

    This links two models together.
    Every model you load with md3load has an ID. The first model you load has the ID 0, the second has the ID 1, and so on, those ID's are now used to identify the models and link them together.
    "parent" the ID of the parent model.
    "child" to ID of the child model.
    "tag" name of the tag that specifies at which vertex the models should be linked.

    Hint: Make sure you understand the difference between the parent and child model. Rendering starts at model 0 (first loaded model) and then continues with model 0's children, etc. Imagine a tree, model 0 is the root if it.
   
mdlcollide N
    If N is 0, collisions with the model are disabled. Default = 1.

mdlbb RAD H
mdlbb RAD H EYE
    Sets the model's bounding box to radius RAD and height H. If this is not set, or RAD and H are 0, 
    a bounding box is automatically generated from the model's geometry. EYE is fraction of the model's height
    to be used as the eyeheight (default 0.9).

mdlcullface N
    If N is 0, backface culling is disabled for this model. Otherwise, backface culling is enabled. Default = 1.

mdlspec SI
    SI is the specular intensity (not given or 0 gives the default of 100, good for metal/plastics and anything shiny, use
    lower values like 50 for wood etc, -1 means off entirely)

mdlshader SH
    SH is the name of the shader to use for rendering the model. Default is "stdmodel".

mdlambient A
    A is the percent of the ambient light that should be used for shading. Not given or 0 gives the default of 30%, -1 means
    no ambient.

mdlscale S
    Scale the model's size to be S percent of its default size.

mdltrans X Y Z
    Translate the model's center by (X, Y, Z), where X/Y/Z are in model units (may use floating point).


----

Sample md3.cfg file, used for a playermodel:

md3load lower.md3 // model no. 0
md3skin l_lower ./default_l.png

md3anim dying           0   30  0   20
md3anim dead            30  1   0   25
md3anim run             114 10  0   18
md3anim "run attack"    114 10  0   18
md3anim idle            164 30  30  30
md3anim "idle attack"   164 30  30  30
md3anim jump            147	8	0	15
md3anim "jump attack"   147	8	0	15


md3load upper.md3 // model no. 1
md3skin u_torso ./default.png

md3anim dying           0   30  0   20
md3anim dead            30  1   0   25
md3anim lag             91  40  0   18
md3anim edit             91  40  0   18
md3anim "idle attack"   131 6   0   15
md3anim "run attack"    131 6   0   15
md3anim "jump attack"   131 6   0   15
md3anim jump            143 5   0   20
md3anim idle            152 1   0   15
md3anim run             152 1   0   15
md3anim pain            152 1   0   15


md3load head.md3 // model no. 2
md3skin h_head ./default_h.png


md3link 0 1 tag_torso
md3link 1 2 tag_head

mdlspec 50
mdlscale 20         // 20 percent of the original size
mdltrans 0 0 -1.5   // lower the model a bit

----


