Implementing MD2's

GCS has the ability to put MD2's ( solid objects ) in place of windowed or
symmetrical walls , in this tutorial I will describe how to implement static and
animated MD2's .

Static MD2's

For this tutorial we will assume that you have an MD2 of a laptop to implement in
your game .

The first thing to do is put the laptop.md2 in your model folder which should be
inside your project folder .
Now the fun bit , making an .mdi file , all MD2's have an associated .mdi file that
controls the way the engine handles the model , the .mdi file should have the same
name as the model so our mdi would be called laptop.mdi , it also goes into the
models folder inside your project folder , below is a typical .mdi file .


for levels 0 3 4 9 10 11

md2name laptop.md2
scale 100
anglebias 0
floorhand laptop.vga
frame 1 hlaptop.vgr
zoffset 0



Now we will look at each line individually

The top line defines which levels the MD2 will be in , each time you want to put it in
a new level you must add the level number to the line .

The second line defines the MD2 that we are using

The third line is the scale of the model in you game , the number is a percentage so if
you wanted the model half size you would change the number to 50

The fourth line is the angle that the model will appear at in your game , 0 is as it
appears in the model editor when it was made but if you want it at an angle you
would modify the number on this line , this number is hard to define because it is not
in degrees , I don't know why , so if you want a different angle you will have to
experiment .

The fifth line defines the skin that will cover the MD2 model , this skin must be in
your extra.txt for any level you want to use the model in .

The sixth line is the line that tells the engine which wall the MD2 is going to override
in your level , what you must do is make a .vgr called laptop.vgr and import it as a
windowed or symmetrical wall , you will notice the line in the .mdi has an h before
the name of the .vgr , this tells the engine that it is a windowed wall , if you wanted
to use a symmetrical object you would change the h to an s so the line would be
slaptop.vgr . Once you have made the .vgr you must put at least one in each of the
levels defined in line 1 .

The seventh line sets the height from the ground when you place a model in your
game , this is not to be confused with the z offset when placing an object in the
editor , this is for models that don't seem to touch the ground when you place them
in your game , for example if you placed a model in your level and it seemed to
hover about 20 above the surface you placed the model on you would change this
line to zoffset -20 .

Animated MD2's

There are two ways to animate MD2's , first there is the type that cycle through
skins and then there are the types that cycle through frames .


Skin cycle

This example uses a two frame MD2 and the skin is cycled , the two MD2 frames
are exactly the same as each other . In my game I have a TV that cycles through
two skins and appears like it has been left on or is out of tune , for this tutorial we
will deal with that one , as with the static MD2 you would put the tvstat.md2 in
your models folder then make an .mdi file called tvstat.mdi like the one below .

for levels 9

md2name tvstat.md2
scale 100
anglebias 0
floorhand tvsksk2.vga
frame 1 htvstat.vgr
frame 2 ktvsksk3.vga
zoffset -10
cycle 2


The lines we are interested in are lines 5,6,7 and 9 , the others are explained in the
static MD2 section .

Line 5 is the first skin name , this must be in your extra.txt as before .
Line 6 is the override object as before
Line 7 is the second frame of the MD2 , this frame is exactly the same as the first
one but the .mdi tells the engine to change the skin , the named skin must have a k
before it in the .mdi and must also be in your extra.txt for the levels you want to use
it in .
Line 9 is the line that tells the engine to cycle through the frames , as there are only
two the number is 2 , if you wanted more you would add and define more skins and
add to the cycle number .


Frame cycle

This method is for a model that is animated and uses the same skin , for this example
I will use the .mdi for a barrel I have that has an animated fire in it , the MD2 has 6
frames which are the movement of the flames .

for levels 10 11

md2name barfire.md2
scale 90
anglebias 0
floorhand barfire.vga
frame 1 hbarfire.vgr
zoffset 0
cycle 6


This time you will notice that the .mdi is very similar to the static .mdi , that is
because it is the same apart from the cycle line which tells the engine to cycle
through the MD2's frames , it is that simple , just add a cycle line with the number of
frames you want to cycle through .