Planet
navi homeaboutscreenshotsdownloaddevelopmentforum

How to create a md2-Model for Orxonox

Well, to find out, how you manage to create those models was a pain in the ass, I hope that there is a better way in the near future.

Introduction

For a complete md2-model I need at least 3 programs. Unfortunately they're not all open source software: Maya (or Blender (opensource)) to create an object file (*.obj), Milkshape 3D (I'm using version 1.7.8 in this tutorial) to create the animations and export it into the md2-fileformat and Photoshop or anything else to generate good textures. Most of the time Misfit helps to edit animations on existing md2-models.

The problem with the md2-models is, that they save the animation into vertex-movement. This is a problem, because Milkshape doesn't get that and so we are only capabale of editing bone-animations with this particulary program. So we have to save our animation into another fileformat: ms3d.

Be also aware that md2-models only work with moved vertex. You cannot recombinate models during an animation.

Problems with Milkshape

Before doing anything big, you would rather like to check if Milkshape crashes if you try to safe anything into the *.ms3d file format. If it crashes download these two dll-files and put them into the Milkshape directory, this should help you out.

I want to start from scratch

Okay, so you have something in mind which should be animated. Cool, first you will have to model your object or person in Maya or Blender and save it as an object file (*.obj). Do not care about texturing yet, we will have to do this later.

I do have a model now

Start Milkshape and import the object file. Now we want to add animation. With persons or things with joints we're going to need a skeleton. A skeleton is a set of points connected to each other with bones in a child/parent-relationship. We know this with Parent-Nodes? in Orxonox. Be aware that every new joint you add, will be a child of the joint which is selected when you place the joint.
When your skeleton matches your model you will have to assign the model's vertex to the bones. Make sure you have chosen the selection tool and that you're able to select vertexes (Be sure you deselect "Ignore Backface").
Change now to the joint-tab (at the right side of the screen) where you can see a list of all the joints you've created. If you want you can change their names (arm, leg, hand…) so you dan't mix them up. Select a joint in this list and then select the vertex which should be part of this limb. Then press "Assign". To check if it worked, use the button called "Sel. Assigned" to see which vertex are part of which joint. Here there is also this child/parent relationship: A vertex which is part of a joint is automatically part of any parent or grandparent of his joint.
Important: Every single vertex must be part of a bone, otherwise the md2-model won't be exported by Milkshape.

I have the model and the skeleton

Animations with skeletons are a lot easier than pure vertex animation. Fortunately Milkshape will convert skeleton animation into vertex animation when we export it, so we don't need to worry about this. Press now the "Anim" Button at the lower edge of your screen. And put in the numbers of frames you want to use in your animation into the box at the right. Let's take something between 15 and 25. It depends how complicated the movement will be. The more complicate the more frames you gonna need.
Be sure you have selected the first frame with the drawer on the lower edge. Now press Ctrl+K or choose "Animate→Set key frame". We will probably only need 5 or 10 key frames in our animation since Milkshape will smooth the animation in the frames between the key frames. To those guys using flash for 2D animations: Milkshape connects all your key frames with motion tweens! Now you go to frame 3 or 4 and start moving and rotating joints. When you think this animation step is finished, press Ctrl+K again and go further to the 6th or 7th frame and move your joints further.
Congratulatons: You just finished your first key frame to key frame 3D-animation.

What's about the texture

Right, almost forgot: In Milkshape it is really easy to add a texture. There are some drawbacks though: While maya and other more professional programs are able to project the texture from every angle on the surface of the model, Milkshape can only project the texture from 6 sides (front, back, left, bottom etc.). It's still possible to create some descent models.
First you have to load the texture. I'd say we only use one material (the one which is already there) and put a texture on it. Click the small button and choose the texture you like.
Now we have to put the texture on the model the right way. Select the faces (attention: faces are all triangles, a cube contains of 12 triangles) so that you can project the texture on them properly, meaning only from one side. For example: If you want to texture a cube. Take the front and the back face and texture them together (if you want the same part of the texture on the front and the back). Left, Right and Top, Bottom can also be textured together because the projection from these sides are the same. So with a cube we have at least 3 steps to texture it, with more complicated models a lot more.
After you selected the faces you want to texture, regroup them into a new group. Then press "Ctrl + T" to open the texture editor. Be sure you still have the group selected. If you don't press "select" when you have selected the group in the list.
In the texture editor you choose the new group and the direction of the projection of the texture. Then press "Remap" and the faces are shown on the texture how they look like from the direction you've chosen. You can now move, rotate and scale the faces on top of the textures. A click into the 3D-view shows how the texture looks like on the model. If you're happy with it you deselect the faces and select other faces and regroup them again etc..
When working with really complicated models it helps you a lot to just hide the groups you've already put a texture on. Go to the group list and select the older groups and hide them with the button beneath.

My animation is finished and the model's got its texture

Now we have to export this thing. You will first have to create a file called md2.qc ("Tools→Quake III Arena→Generate Control File") then you should be able to export your animation into the md2 file format ("File→Export→Quake 2 (MD2)"). Important: You cannot edit a md2-file with Milkshape. If you want to edit your animation ever again, save it in the Milkshape file format (*.ms3d).

I have a md2-model I want to edit

Well you're doomed, Milkshape does not allow this.
Just kidding: You will need "Misfit" (opensource) to open, watch and edit the md2-model and all its animations. Here you won't be able to use a skeleton, but you can alter some vertex (frame by frame).

I have a md2-model but I want do my own animations with it

Well, all animations will be deleted if you import the md2-model into Milkshape, but if you don't care, no problem. Import the model with "File→Import…" and build a skeleton. If you're lucky and you want to make animations with a model of a human shape you can us predefined skeletons which are coming with Milkshape. Import them as well if you need them.
Well the rest is told earlier.

I hope the tutorial helped you to create md2-models for orxonox… or for yourselve :)

Last modified 11 years ago Last modified on Jun 28, 2006, 11:51:08 PM