MDL Editing: The Basics

General talk about editing, cheating, and deprotecting maps.

Moderator: Cheaters

User avatar
qweasd011
Forum Addict
Posts: 451
Joined: November 21st, 2008, 9:36 am
Title: Coleen!

MDL Editing: The Basics

Post by qweasd011 »

Introduction

Frequently people ask me how to make models. Making models from scratch is hard, and you will need various tools for this or the expensive program called 3D Studio Max. This tutorial will therefore focus on editing existing models.

Warcraft III handles two formats of models: mdx (the compressed version) and mdl (the uncompressed version). All models stored in Warcraft III are in mdx format, and therefore you need to import models into your map in this format. Mdx files however, are not editable with notepad, mdl’s are. Therefore we must be able to convert models of mdx format to mdl and back.


Tools needed

The actual tool we will work with is notepad (or any other basic text editor). This comes with windows so that is easy.

Another tool we need, is one that can convert mdx to mdl and back. I know two tools able to do this: Yobguls’ File Converter and Warcraft Model Editor By Magos
Last a tool to extract models from the MPQ. Wc3viewer by Prophet will do, as will any other mpq editor. (You can download them at the end of my post but read the instructions how to use them! ok?)

How do models work

Models are made by alot of points with 3 dimensional placement and directions, also called vertexes. Between each 3 vertexes there can be a so called “face”. This is the part of the model that is textured and visible in game. So when looking at a model you are actually looking at alot of tiny triangles. The model has a track in the time to animate. By setting movement/rotation/scaling values it will animate by the time. So actually the model will do all its animations if you would “watch it” like it was a movie. When playing an animation you watch a small portion of the entire animated model.


Basic notions

So, now we can get started. First, extract a model from the MPQ. I use the rat (its a simple model of a unit to start with), the path: “Units\Critters\Rat\Rat.mdx”. Convert the model from mdx to mdl using your converter and open the mdl with a text editor. On top of the model you will see something similar to this:

Code: Select all

// MDLFile version   Jun 27 2002 20:34:57
// Exported on Mon Dec 12 21:10:46 2005
Version {
   FormatVersion 800,
}
Model "Rat" {
   NumGeosets 2,
   NumGeosetAnims 2,
   NumHelpers 14,
   NumBones 11,
   NumAttachments 11,
   NumEvents 4,
   BlendTime 150,
   MinimumExtent { -62.0313, -16.2074, -30.2564 },
   MaximumExtent { 34.7856, 65.9125, 49.5211 },
}

The first 5 lines are of no interest to the model, neither is the name. After this we see how many geosets, geosetanims, helpers, bones, attachmentpoints and events it has. These will be explained below. Also present is the blend time of the model, and the min/max extents.

Blendtime: This is the time in milliseconds the model will take to blend from one animation to the other. It is used to smoothen abrupt changes. It will most likely always have a value of 150 and this value can also be edited in the object editor of World Editor.

Min/Max Extents: These have 3 values. One for the X, one for the Y, and one for the Z direction. It tells warcraft when to render the model and when to stop rendering it (it will stop rendering outside the camera + the min/max extents).
Now that the header of the model is cleared we will move on. Under this you will find something like this:

Code: Select all

Sequences 8 {
   Anim "Stand" {
      Interval { 5000, 7000 },
      MinimumExtent { -56.8896, -9.66866, -5.54965 },
      MaximumExtent { 22.4475, 14.711, 25.599 },
      BoundsRadius 40.8942,
   }
   Anim "Walk" {
      Interval { 7500, 8000 },
      MoveSpeed 360,
      MinimumExtent { -53.7116, -9.7495, 1.37076 },
      MaximumExtent { 25.8239, 13.541, 49.5211 },
      BoundsRadius 43.8341,
   }
   ...
   Anim "Attack" {
      Interval { 31000, 32000 },
      NonLooping,
      MinimumExtent { -60.4865, -15.4885, -10.1442 },
      MaximumExtent { 34.7856, 18.7263, 36.0843 },
      BoundsRadius 52.9707,
   }
   ...
}

As you might have thought, yes, these values resemble the animations the model plays. The Interval is the time interval the model will play of its own keyframes on this animation. Other tokens are:
MoveSpeed: This demonstrates the distance which is walked in 1 animation length, this can be changed in the object editor.
NonLooping: As it says, this will make the animation not loop, like on attack or death animations.
BoundsRadius: This has to do with the radius on which the model is selectable.

Under this we see the Textures section, it all speaks for itself I think. Under that is the Materials section

Code: Select all

Materials 2 {
   Material {
      Layer {
         FilterMode None,
         static TextureID 0,
      }
   }
   Material {
      Layer {
         FilterMode Transparent,
         static TextureID 1,
         Alpha 7 {
            Linear,
            40000: 1,
            42133: 1,
            100000: 0.998023,
            103333: 1,
            105467: 1,
            154567: 0.998023,
            163333: 0.75,
         }
      }
   }
}

The Filtermode describes how the texture will behave when the texture has an alpha channel, most common values are None, or Blend (Blend will make the texture become transparent by the alpha channel). We also see the TextureID. This will tell the material which texture to use (starting count at 0). We also see a token Alpha there and in it a few numbers ordered like this: 40000: 1. This describes a variable alphachannel for the model. The first number is the time on which to take action, the second is the alphavalue. 1 is completely visible, 0 is completely invisible.

Under this come the geosets. A geoset is the core of a model. It holds all the vertexes and triangles. Do not try editing this without tools, it is nearly impossible. All the way at the bottom you see what material the geoset will use by MaterialID (counts from 0 also).
The visibility of geosets (not only their textures) is controlled by GeosetAnims. The Alpha token works the same way as it does on materials. The GeosetID tells the geosetanim which geoset to use.

Under this come the Bones, the core of animation:

Code: Select all

Bone "Mesh21" {
   ObjectId 3,
   Parent 14,   // "Bone Tail 2"
   GeosetId 0,
   GeosetAnimId 0,
   Translation 17 {
      Bezier,
      5000: { 0, 0, 0 },
         InTan { 0, 0, 0 },
         OutTan { 0, 0, 0 },
      ...
   }
   Rotation 14 {
      Hermite,
      5000: { 0, 0, 0, 1 },
         InTan { 0.0250946, 0.0346695, -0.0503677, 0.997813 },
         OutTan { 0.0250946, 0.0346695, -0.0503677, 0.997813 },
      ...
   }
}


The ObjectID is essential for each object from now on, and they should line up without having gaps between them. The Parent is the object to which the bone is linked, as it parent will animate, so will the child.
The Translation, Rotation and Scale (scaling is not seen on this model) are the actual animation factors. Translation means movement trough space, trough the X, Y and Z axis. Rotation is about rotation the model again around 3 axis, Scaling works the same. The Bezier or Hermite token represents the Motion controller it will use, changing this will have close to no effect on the models animation.
The first number on the actual values again represents the time where to take action, and after this are the values.
InTan & OutTan have something to do with how quickly the animation will go between two frames, these values will be used by Bezier and Hermite animations.

Helpers “help” to do the animation. They behave just like bones, but don’t have geosets linked on them.

After this we see the attachment points. Needless to say, these are the points where you can place special effects on. One new tokes we see here is Visibility. But not to worry, it is exactly the same as Alpha. Each attachment point has “ Ref” behind its name, thats just the way it is.

Almost last we see the Pivotpoints. These are VERY important to the model. They give each Object a center point. The first one is for the object with ObjectID 0 etc. When removing Objects ALWAYS remember to change the pivotpoints. Objects will rotated around, will move to and scale from the pivotpoint.

Events. These nifty little things take care of any external model behaviour. From sounds to bloodspatter and footsteps. What they will do lies in they name “SNDxBLA” will make a sound with the 3 lettercode BLA (I dont think this one exists ;-) ). I’m sure there is a list which holds all event objects somewhere. Have fun looking for it if you ever need these things, I dont. The EventTrack token will say when to play the external event.

CollisionShape. They will make the model clickable. Clicking on the collision shape will tell Warcraft that the model is being clicked on.

Other objects:
Most other models will also have ParticleEmitters and OmniLights. Tho these are in my eyes most powerfull for mdl editing I will not explain them in this tutorial, since there is a whole lot to say about them.


Starting the Edit

Most edits are hard and deserve a tutorial of their own. Therefore I will only explain a tiny bit of what is possible: Removing stuff from the model (like hero glow).
Like you would maybe think, removing a part of a model is not as easy as just deleting a part out of the the mdl. There are alot of things to fix afterwards.
Lets say you are removing a geoset. Once you have deleted it totally, there will still be alot pointing to something that does not exist. Therefore you must find all objects/geosetanims that point to that geoset and remove them too. If they have childs, you will have to also remove those. Hold in mind that by removing them you are screwing up the ObjectID’s and you must align them again. You will have to remember which parent is pointing to which childs and also correct all pointers. Last to do (or actually this is the first you should do!) is to remove the pivotpoints corresponding to the objects you removed.


Final Words

All together, mdl editing is powerfull, but hard to master. When learning it, you will find great pleasure in seeing your models actually working ingame, or disappointment in seeing them not work, or even crash the game. Do not worry, this is the normal process it takes to mdl edit, since it is so hard to keep track of everything.

Hope you understood this all and you now can hopefully try and change things in the model and learn what they do

How to use Yobguls Warcraft III File Converter
Converts mdx to mdl and mdl to mdx, also blp to jpg (although there are some tools that would be better for that)

It will always crash when you close it, don't worry about it.

Once you used it to convert a mdx into mdl, it will always crash if you try to convert a mdl into a mdx (or viceversa) so just close it and open it again.

Full credit to YobGuls, Unzip the file anywhere as long as it is not your warcraft III folder.

Then COPY these files from your Warcraft III folder : ijl15.dll and mss32.dll to the folder where yobgul's file converter is located

How to use Wc3viewer
Overview: This program allows you to view units, buildings, textures, and all other 3D/2D objects from Warcraft 3 (and TFT) as well as make file conversions.

Includes:
Can display MDX and BLP files
Can export MDX or BLP files from the MPQ.
Can convert BMP, JPG, TGA to BLP
Can convert BLP to BMP, JPG, TGA
Allows quality and depth settings during conversions
Allows you to choose to view different .MPQ files (Such as War3.mpq and War3x.mpq)

Installation and usage:

When launching the application, the first thing is to choose the War3.MPQ (or the War3x.MPQ for the extension of Warcraft 3) file (but theoretically, it should be found automatically). In the window Contents of War3.MPQ, you expand some items to browse War3.mpq, and you just have to click on the item you want to see. You can rotate the current object by keeping the left mouse button pushed while moving the cursor (and maintain the CONTROL key pressed if you want to rotate it around the X axis, you translate it with the right mouse button, and you scale it with both left and right buttons, middle button pushed, or mouse wheel. This application will not display non MDX or BLP files (Such as TGA or WAV files) that are also included in the MPQ.

Author: TheProphet
You do not have the required permissions to view the files attached to this post.
Image