1. The Melee Mapping Contest #4: 2v2 - Results are out! Step by to congratulate the winners!
    Dismiss Notice
  2. We're hosting the 15th Mini-Mapping Contest with YouTuber Abelhawk! The contestants are to create a custom map that uses the hidden content within Warcraft 3 or is inspired by any of the many secrets within the game.
    Dismiss Notice
  3. The 20th iteration of the Terraining Contest is upon us! Join and create exquisite Water Structures for it.
    Dismiss Notice
  4. Check out the Staff job openings thread.
    Dismiss Notice

Exporting models from Blender using the MDL exporter plugin

Discussion in '3D Modeling Tutorials' started by Fingolfin, Aug 20, 2018.

  1. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,170
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Creating and Exporting Warcraft MDL models with Blender
    By Fingolfin

    Have you ever wanted to create your own awesome 3D models for Warcraft 3? Up until now, the only officially supported tool has been 3ds Max5 with Blizzard's Art Tools plugin, which is problematic considering that this version of 3ds Max is over 15 years old and very hard to get your hands on. Another awesome plugin - NeoDex - has been made by @BlinkBoy to support newer versions of 3ds Max, but this has also been limited to users who are either willing to pay upwards to 3000€ a year, have a student license, or are unscrupulous enough to download it illegally. Other tools like MDLVis and Vertex Modify have helped produce a lot of appreciated content over the years, but creating models in these is tedious since they can't leverage the great variety of tools provided by proper 3D-modeling software.

    For this reason, i started developing an MDL exporter plugin for Blender, which although still a work in progress, is now ready to see some use. Blender is an amazing, free, open-source 3D art program with great capabilities, and learning it can be useful for more purposes than just Warcraft modding. I this tutorial i aim to teach you how it works and how you can use it to export cool 3D models for Warcraft 3.

    For this tutorial, you will need the following programs:


    1. Getting Started


    Once you have installed Blender, visit the github page for the MDL exporter. The readme contains most of the instructions covered in this tutorial and is good for quick reference. For now, just click the button that says "Download or Clone" and press "Download Zip".

    1_Download.jpg

    Next, unzip it, and enter the folder so that you see the three files shown above. Right-click the folder called "export_mdl" and go to Send To>Compressed Folder. Open up Blender, go to File>User Preferences and press "Install Add-On from File..." in the bottom bar.

    2_Install.jpg

    Select your newly created zip folder and restart Blender. If you go to File>Export, you should now see "Warcraft MDL" as an option. Note that the first time you install the plugin, you will need to activate it from the import/export plugins list by ckecking the box next to it.

    By default, Blender uses right click for selection and left click for moving the 3D cursor. Since this is completely counter-intuitive to what you know from any other software, you might want to go to File>User Preferences, hit the "Input" tab, and set "Select With" to "Left Click".

    2. Creating your model

    Teaching all the aspects of creating a model in Blender is beyond the scope of this tutorial, but my recommendation is to check out BlenderGuru on youtube and start from there:


    My plan is to later create a tutorial on 3D modeling techniques as well. For this tutorial, I'll make a simple wine glass without going too much in details on how to use the Blender UI - therefore i recommend that you at least watch the first two episodes of the series i linked before you start. If you already have a model which you want to export, you can skip this part.

    To start off, press the A key to select everything, then press X for delete, and click to confirm. This leaves us with an empty scene. Next, hit Shift+A to open the "Create" menu, go into "Mesh" and select "Cylinder". Our cylinder will appear at the current location of the 3D cursor, which unless you have accidentally misclicked should be at the center. In the bottom left corner of your screen, there's now a small window where you can configure the parameters of our cylinder. Here, I'll set it to have 8 segments, a radius of 0.05 and a height of 0.2. Set "Cap Fill Type" to "Nothing" to get an empty tube. It can be helpful to configure Blender to use real-world units, you can find instructions on how to do so here.

    3_Cylinder.jpg

    To make it easier to create smooth shapes, we will be using a Subdivision Surface modifier, which essentially smooths the mesh while adding more polygons. Press the tab which looks like a wrench in the menu to the right, press "Add Modifier", and select "Subdivision Surface". You can also just press CTRL+1 to add it automatically. You will notice how the cylinder looks more smooth. To make it even smoother, you can press the little button which says "Smooth" in the middle of the left toolbar, under "Shading" - this makes the model look smooth by averaging the normals without actually adding any more geometry. You can also set an angle threshold for the smoothing by pressing "Auto Smooth" in the "Object Data" tab (which looks like a triangle).

    With our cylinder selected, hit TAB to toggle edit mode. Press A to deselect everything, and then CTRL+R to enter "loop cut" mode. If you hold your cursor over the cylinder, you will now see a purple line dividing it. As you press, this line will become yellow and follow your cursor as you slide up and down. Move it to where you want and click again to place it. With the vertices selected, you can now scale them by pressing the S key and moving your cursor around. If you ever want to select the same loop again, you can hold the Alt key while clicking one of the edges to select the whole loop. Remember that the A key deselects everything (or selects everything, if nothing is selected). Put down some loops and scale them until you have something which looks like a glass. You can also press G (for "Grab") to move vertices around, and also press X, Y or Z to lock movement to that axis. Notice how the Subdivision Surface modifier smooths out the shape - if this creates smoothing where you don't want it, try adding an extra cut close to the edge you wish to preserve.

    • CTRL+RMB+DRAG: Paint a selection loop with your cursor. This is great for precision.
    • C: Circle select. Use the scroll wheel to shrink/grow the circle, and drag with LMB to "paint" selection with it. Press RMB to stop selecting.
    • B: Box select, lets you drag a box.
    • SHIFT+LMB: Add to selection.
    • ALT+LMB: Select loop.

    4_Model.jpg

    And now we are pretty much done! If you want to create an inside for the glass, you can select the top loop (again, by ALT+clicking it) and press E and S to extrude it and scale inwards. Pressing F while a loop is selected will seal it off with a polygon, so you can use this to fill the bottom. Another final thing we might want to do is to move the model so that the base is at the origin point - do this by pressing G followed by Z (to lock to Z axis), move it up, and then click to place.

    3. Unwrapping

    Next, we need to map how the texture should be applied to the model in 2D space - think of it as unraveling a paper model and flattening it to fit onto a piece of paper. This process is called "Unwrapping".

    Similar to how clothes have seams where the fabric is cut, we can add seams to define where to cut up our model when unwrapping it. In our case, this is as simple as ALT-clicking along one of the vertical lines of our glass and press CTRL+E (E is for Edge Options), and select "Mark as Seam" from the menu. If you have sealed off the inside and added a bottom cap in the previous step, you will also need to mark the loop around the polygon as a seam. Seams are marked with red.

    5_Unwrap.jpg

    Next, press A two times so that you have your entire mesh selected. Now press U and select Unwrap. It may not look as if anything has happened - but that's just because what we need to see is in a different UI screen. Notice the little cube icon at the bottom left of your window? Click it to open a drop-down menu with different screens, and select "UV/Image Editor" (hotkey for this is Shift+F10). Now you see how it looks when the model is unfolded! To get more overview, you can pull the little corner at the top left of the window to split it into two and have one as the UV editor and one as the model (you can press T and N in the UV editor window to toggle off both the toolbars if it gets cluttered). In the image editor, you can press the button which says "Open" to select an image to use as background - this way we can move the vertices around to match the texture we want to use. In this case, we will be using a plain white texture, so we won't go into the details of this.

    Finally, hit TAB again to toggle back into object mode.

    5_ImageEditor.jpg

    L - Select Linked
    G - Grab
    S - Scale
    R - Rotate
    Y - Separate


    3. Material setup

    In order to export properly, our model needs a material. Go to the Material tab in the properties window and press the button which says "New". At the bottom of the panel, some settings will appear labeled "MDL Material Settings". MDL Materials consist of one or several texture layers, which can be blended together for different effects. To create one, click on the "+" button next to the empty box which says "Layers". The property inspector below displays the properties of the currently selected layer - here, we want to enter "Textures\white.blp" as the path, "Additive" as filter mode, and make sure that "Two Sided" is checked. That's all we need for our basic glass material!

    When you make your own models, you'll probably want to use other textures than "white.blp" - you can then use Magos Model Editor's MPQ browser to browse through and preview all the textures which exist in the game files. When right-clicking on a texture in the list, you can choose to "copy path to clipboard" and paste the path into the texture field in Blender.

    You might notice that there's an option called "Texture Type" for the material - here you can choose whether to use an image as texture, a team color, or a replaceable texture (such as a cliff or tree texture). To add team color to a unit model, you create two layers - one bottom layer set to "Team Color", and one top layer with filter mode set to "Blend" and a texture path of your choice - the team color will then shine through where the texture is transparent (determined by its alpha channel). Note that the layer list goes from bottom to top, so layers at the top of the list are rendered under those below them in the list.


    6_Material_Editor.jpg

    Some models, such as the Water Elemental, use texture animations to make it seem as if the water is moving across its body. The exporter allows you to make texture animations by adding a Mapping node to the node graph, naming it the same as your layer, and then animating its values. This way you can preview the animation by feeding it into the texture slot of your actual material (MDL materials are just data containers and won't affect how the mesh is rendered in blender). To edit the shader graph, open the graph editor in a window (hotkey: Shift+F3) and press the button which says "Use Nodes" in the material panel. You can create nodes by pressing Shift+A. You can rename nodes by selecting them and typing in a name in the panel to the left of the graph viewport.


    4. Animated color tint

    Warcraft 3 materials can have a tint which is applied as a vertex color to the whole mesh. In Blender, we can get the same effect by animating the "Object Color" of our glass. Our color won't actually be changing anything during the animation - but for the exporter to recognize it as a color tint, we need to apply it as an animation. First of all, in order to export animations, we need to define their start and end times. To do this, we mouse over the timeline at the bottom, and right click in it (or left, depending on your mouse settings) to move the cursor. Set it to frame 1 (or 0, whichever you prefer) and press M to place a timeline marker. Next, press CTRL+M to rename it - let's just name it "Stand". To mark the end of this animation, we move the timeline cursor to frame 100 and repeat the same process again - making sure to also name this one "Stand" (each animation NEEDS a start and end frame or the exporter will report an error). If you ever want to have multiple sequences, you can just place another pair of frames somewhere else in the timeline and name them something else - as long as they don't overlap with each other. Note that although the exporter will also export rotation, scale, and translation animations, this is currently buggy and might not always present the correct result. Most other properties can be animated, though - see the readme for more info.

    The next step is to make our actual animation. To do this, go to the "Object" tab in the right toolbar (the icon looks like an orange box) and find a field which says "Object Color". We will change this field to be a light blue color. Then, with the timeline cursor at frame 1, mouse over the color field and hit I on your keyboard to insert a keyframe. You will notice that the color field now gets a yellow border - this means that its values are keyed at this frame. Move the timeline cursor to frame 100 (or whatever your end frame is) and repeat the process. Note that ALL animations need to have start and end frames to display properly - however, the exporter currently won't notify you of these are missing, so it's your responsibility to remember to add these.

    8_Animation.jpg

    On the topic of animations - if you ever need to animate whether you want to show or hide an object, you can easily do this by animating the render visibility. You do this by mousing over the little camera icon you see next to the object in the outliner (top right corner) - click the camera to toggle on/off, and press I while mousing over it to set a keyframe. It is also possible to create a custom property called "visibility" and render its value.

    NOTE: As of the current version, animating render visibility is bugged, in the sense that the values are inverted. In other words, keying render visibility to "on" will result in the geoset being hidden, and vice versa. This will be fixed soon.

    9_Animate_Visibility.jpg

    5. Exporting

    When you feel done with the model, go to File>Export>Warcraft MDL and save it. Note that you have some options in the left panel:

    Selected objects: if this box is checked, only selected objects will be exported.

    Forward/Up: This is used to rotate the model as it is exported to correct for the different conventions of Warcraft 3 and Blender. By default, it should make it so that the forward view in Blender corresponds to the forward direction of Warcraft 3 (you can set the viewport to view "Forward" perspective by pressing 1 on your num pad).

    Scale: This is used to apply a global scale to all objects in the scene. In Blender, one unit corresponds to one meter, while in Warcraft, it is a much smaller distance. To correct for this, the default value is set to 60, which is roughly half the height of Jaina (my reference), so this means that if you model a character to be 2 meters tall in Blender it will become about as tall as her (which is probably not her real height, but it's a nice round number).

    Normally, there's no need to change these values, and it should be safe to simply export. If you encounter any errors in this process, please write them in the comments and i will try to address them. Finally, convert your model to MDX using MDLX for a smaller file size. Now you can admire your model in a MDL/X viewing software such as Magos Model Editor!

    So... that's it! Have fun! I will update this tutorial further on as i update the plugin, make sure to keep the exported updated - you do this simply by checking if there's recent activity on the github page, and if so, just install it again using the steps described. Don't hesitate to ask questions in the comments or by PM.
     
    Last edited: Dec 19, 2018
  2. dtnmang

    dtnmang

    Joined:
    Apr 20, 2010
    Messages:
    394
    Resources:
    6
    Models:
    2
    Tutorials:
    4
    Resources:
    6
    Hmm... I am not at home right now but I will try this out when I am home. But I assume the exporting plugin can only export mesh data? Or can it export bone data and vertex groups?
     
  3. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,170
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    It can export literally everything supported by the format, though animations are currently a bit dodgy. You should still be able to export a rigged model though and transfer animations to it. I recently successfully did some animating on a battleship model, so it works for basic hierarchies. Bezier interpolation is buggy though.
     
  4. dtnmang

    dtnmang

    Joined:
    Apr 20, 2010
    Messages:
    394
    Resources:
    6
    Models:
    2
    Tutorials:
    4
    Resources:
    6
    Well then, I've absolutely no idea why this wasn't more known! There's also a fairly recent MDX importer plugin for Blender somewhere on github. Finally, modeling on Blender for WC3 can be a possibility.
     
  5. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,420
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Super duper awesome!

    Approved!
     
  6. DerekX

    DerekX

    Joined:
    Jul 3, 2010
    Messages:
    147
    Resources:
    3
    StarCraft II Resources:
    2
    Tutorials:
    1
    Resources:
    3
    About the materials setup, if it's of plain color, would we check "Unshaded"?
     
  7. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,170
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Unshaded is used when you want your material to appear glowing or self-illuminated. It prevents surfaces directed away from the light from appearing darker. For a glass I would not recommend using it. For particles, glows, or UI stuff (like the "silence" overhead buff) it is useful.
     
  8. NightStalker

    NightStalker

    Joined:
    Apr 21, 2013
    Messages:
    1,151
    Resources:
    5
    Icons:
    4
    Spells:
    1
    Resources:
    5
    I might start learning modelling for WC3, I loved this tutorial and thanks for working on such a project.

    May I ask what the difference between MDL and MDX is. Can I use my MDL model in the game as a MDX model?

    And as another question; let's say I made a MDL model rigged it and exported it with no animations, since you mentioned animations can be buggy with rotations and such, and create all animations on MDLVIS, and saved it. Will it be working as intended in the game?


    EDIT: oh ignore the first question, I just saw the MDX MDL converter app!

    NEW EDIT: Even when I follow the installment steps, the MDL export won't show up.

    ANOTHER NEW EDIT: I had to find and enable it manually. Let's test with a simple model now!
     
    Last edited: Dec 19, 2018
  9. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,170
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Hey! Glad you liked it! To answer your questions:

    • MDL is a text-based format, while MDX is a binary format. Because of this, MDX files have much lower file size. As you found though, it is easy to convert between the formats using tools like MDLX.
    • Yes, you can export MDL files from Blender and animate them using MDLVis. For mechanical objects, you can typically use empties for bones, but for organic stuff you want to use an armature and skin the mesh to it. You can do this by selecting first your mesh, then shift-select the armature, and hit "CTRL+P>Armature deform with automatic weights". Now the vertices will correctly follow their bones when you pose them.
     
  10. NightStalker

    NightStalker

    Joined:
    Apr 21, 2013
    Messages:
    1,151
    Resources:
    5
    Icons:
    4
    Spells:
    1
    Resources:
    5

    Thanks a lot! I am so very new to modelling so I understood like only half of what you said, but I will be first trying to create a mechanical building which will be able to move. So in this case, my building will need a few moving parts, but not like arms or legs which can collide and cause deformations for the texture.
     
  11. DerekX

    DerekX

    Joined:
    Jul 3, 2010
    Messages:
    147
    Resources:
    3
    StarCraft II Resources:
    2
    Tutorials:
    1
    Resources:
    3
    Well that answers another question. :) I've also been trying to make glowing lightsabers.
     
  12. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
    Will it support a option to choose export full bones or optimized?
     
  13. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
    And it’ll be a tool for rendering animated animation from importing?
     
  14. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,170
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    I have a plan for this, yes, optionally i will just remove the optimization since it is a bit hard to maintain that feature.

    As for your other post, i don't know what you're trying to ask?
     
  15. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
    U should google this word “dota2 model ripping”
    We save a animation into a max file then render it
    Idk how describe it exactly
     
  16. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
  17. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
    more clear right?
     
  18. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,170
    Resources:
    152
    Models:
    142
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    152
    Please don't double post, much less TRIPLE post. Press the edit button and add to your first post instead.

    I am just confused with your wording. Do you mean importing wc3 models into Blender?
    "Rendering" means generating a 2D image from a 3D model. Do you want to create cool 3D-rendered images of Wc3 models?
     
  19. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
    yeah,importing
     
  20. sonphamthe11H

    sonphamthe11H

    Joined:
    Mar 6, 2017
    Messages:
    87
    Resources:
    0
    Resources:
    0
    why your exporter only export the translation but not the rotation and scaling which is messed up my model see the attachment
    i'll prefer a option to export only the "rotation"
     

    Attached Files: