[TUT] Animated mapmodels
#1
[ORIGINAL TUTORIAL]

In this short tutorial I will show you how to create a simple *.md3 animated mapmodel for AssaultCube!

1. Stuff needed:
- Milkshape 3D
- Any GFX program (Photoshop, GIMP, etc...) or a ready-to-use texture
- Patience and willing


2. Introduction
First of all, get Milkshape 3D. It's free, but there's also a registered version, which can be obtained with a small fee, or in "other ways". It is for Windows platform, not sure about Linux or Mac.
Now, once opened, there will be four viewports, that by default (from the left top to the right bottom) are front, left, top and 3D, which means that your model will be visible from any useful perspective.

On the right you can find four tabs, which are model tools, groups, materials (skins), and joints.

This tiny introduction was to show you the GUI and the main items, now let's get into the zone.

3. Model and texture
To show you a simple animation to start with, I will make a sphere (planet Mars in this case), that spins around itself, so here it is.

Now, here comes an important thing: the default model will automatically be called Sphere01. Rename it to something else, this will be important later. In this case we are going to call it mars_model.


We are next to the texture part. As I mentioned before, I am making a sphere that represents planet Mars, so I am using a premade texture, that in this case was found on the web, and that fortunately perfectly fits my mapmodel. Get in the Materials tab and follow:
Step 1 (to create a new material skin)
Step 2 (to select the skin, that must be in .jpg and called "skin.jpg")
Step 3 to "wrap" the whole texture onto the mapmodel. For this step, be sure the mapmodel group is selected (highlighted in red).


This is what we get (at least in this case) if everything was done correctly so far. The next stage is the final tricky part, the animation itself.


4. Animation
Now here comes the hot zone. Get back in the model tab, and create a Joint, that in this case will be put in the exact origin of the sphere (the whole model will spin around this joint, let's say it's like a planet's core).


It will look like this, as seen in the 3D viewport.


A brief explanation: joints are the heart of animations, at least in Milkshape. Basicly, every vertex attached to a joint will totally depend on it, so if that joint will be rotated, attached vertex will do the same. So what we have to do now is attaching every vertex of our mapmodel (or the whole group) to the joint itself. To do so, make sure the joint is selected (select it from the Joints tab, it will be highlighted in red), and by holding Shift, select the whole model. If both of them are highlighted, then hit Assign button, to attach the model on it.


To make sure every vertex joined the joint, hit SelAssigned. If so, attached vertex will be highlighted in red.
It's time to animate! Hit the Anim button on the bottom. It will enable a frames controller (previous frame, keyframe, play, etc...) and a frames bar, that will let you control the animation frame by frame, and keyframes themselves.


Head on Selection tool, and then select Joints.


Let's select the only joint we created so far. It will move the whole model, since every vertex of it is attached onto it. Then we start to handle the frames bar. Once we are in the first frame, hit CTRL + K to set a keyframe. A keyframe can be described as a checkpoint. Let's say for example, that animation goes from 0 to 1. When it is on 0, the model is on cube 0, when it is on 1, the model will reach the cube 1. Everything that stands between 0 and 1 is called interpolation, so basicly, the program will automatically "fill" the holes going from 0,1 to 0,9 with the animation. And this is exactly what we are about to do. The point of the tutorial is to make Mars spin around itself, so let's set the first keyframe on frame 1,0 out of 30,0. Now head on frame 6,0 by using the frame bar


And be sure the joint is selected. Now rotate it a bit, and then again hit CTRL + K. If you move the frames bar from 1,0 to 6,0, you can already see the animation on the viewports. Now repeat this step from 6,0 to 12,0, from 12,0 to 18,0 and so on. The more frames there are, the smoother and more precise the animation will be.
After reaching the last frame (in this case 30,0), you can hit Play forward on the animation controller to see the whole model animated. If you are unsure about some steps, you can delete that keyframe by hitting CTRL + Shift + K and remake that part. If you are happy with your animation, disable the animation mode by hitting Anim again, and then you are ready to export and see it ingame.

5. Export and ingame test
The first step for exporting your animated mapmodel is generating a .*qc file (a control file containing meta information). This is not needed by AC itself, but since it is a Quake III model, you have to make it, otherwise you are unable to export. In order to do so, head to Animate > Quake III Arena > Generate Control File...


Save the file as tris.qc. Once you are sure that Animation mode is disabled, you are ready to export the actual model: File > Export > Quake III Arena MD3... Yet again, save the file as tris.md3. You can get rid of tris.qc, you don't need it anymore.


You should have these files in your mapmodel folder (hence they are already in packages/models/mapmodels). You also probably have noticed that md3.cfg file. Well, that's the missing link that makes your animated model work in AC. It is similar to tris.qc, but with a much more simple architecture, as it follows:

md3load model.md3
md3skin model_group_name skin.jpg
md3anim mapmodel <frame#1> <lastframe> <framepersecond>

In our case, it will be:

md3load tris.md3 // load the actual mapmodel file
md3skin mars_model skin.jpg // remember mars_model? Well, here it is
md3anim mapmodel 1 29 10 // 1 = first frame; 29 = lastframe - 1; 10 = ?

Save this information as md3.cfg, and then you are done! Add the mapmodel data in a map .cfg in the classic way and see the result yourself ingame!

HTH :D
Thanks given by:
#2
Just for clearing up that last parameter on the md3-config part:
md3anim mapmodel <startframe> <endframe> <framespersecond>

Let's take your mars example and pretend it had a 30 frames animation, rotating the whole thing around itselve one time. Played at 30 FPS the whole turn will take on second 30 frames/30 frames per second.
md3anim mapmodel 0 29 30
Thanks given by: