1. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  2. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  3. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  4. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  5. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  6. Shoot to thrill, play to kill. Sate your hunger with the 33rd Modeling Contest!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

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,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    Hmm, yeah, that does look weird. My best guess is that it is related to the scale of the armature, it currently has a scale of 0.025. When i applied its scale, the animation in Blender started looking the same as in the MDL file. If it's not too much hassle, try applying the scale (or create a new armature) and redo the animation like that.

    EDIT: Just pushed an update which adds support for armature scaling, and it does fix some of your issues. However, there is still an issue where the arms rotate inwards in the stand animation. I am not sure what causes this, though i will look closer into it tomorrow. At first i thought it was because your armature was rotated, but i tried applying its rotation with no effect.

    EDIT2: If anything though, now that i think of it: the exporter uses the pose at frame 0 as reference pose and converts all rotations to be relative to this. it is possible that this causes some problems since your animation starts, with his arms rotated and keyed, at frame 0. Can you try creating a rotation frame for each bone at frame 0, where the character is in his rest pose ("T-pose"), and then just start his regular animations at some other frame? Your sequences can start and end wherever you want. You can move keyframes easily in the action editor.

    Also btw, Euler rotations are supported now also, they are automatically converted to Quaternions, so you don't need to worry about that.
     
    Last edited: Jan 20, 2019
  2. GriMw0lf

    GriMw0lf

    Joined:
    Jan 17, 2019
    Messages:
    6
    Resources:
    0
    Resources:
    0
    @Fingolfin Thank you, it worked! That was pretty damn quick, I appreciate it.

    I looked through your code a bit and I noticed you've been working on this since at least April, that's a lot of dedication, so good job! You're a legend man, this plug-in is a real lifesaver.
     
  3. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    Thanks a lot! Initially, it was mostly for myself, and for the fun problem solving and programming. I swapped from 3ds Max to Blender a couple of years ago, and now that I've gotten used to the fast, hotkey-based workflow of Blender, i can't stand working in Max anymore... so i basically had to write a plugin for it (even though had never programmed in python before, haha). It's been a struggle, but seeing people make use of it makes it all worth it! Good luck, and just let me know if you have any more issues!
     
  4. GriMw0lf

    GriMw0lf

    Joined:
    Jan 17, 2019
    Messages:
    6
    Resources:
    0
    Resources:
    0
    Thankfully Python isn't too difficult to learn, would have been a lot worse if Blender had used C++ for its plugins.

    That being said, I don't know Python but if you ever need any help with C#, Go, or JS/TS (I work as a full-time dev) let me know and I'd be happy to help, it's the least I could do to repay you for this awesome plugin you've made!

    If I find any issues with the exporter, I'll make sure to let you know.
     
  5. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    Thanks for the offer, but I am a full-time C# dev myself, so I think I'll be fine on that front! Feel free to give a shoutout to this plugin if you ever upload a model made with it though, it would be much appreciated.
     
  6. Astrella

    Astrella

    Joined:
    Oct 3, 2008
    Messages:
    155
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Would it be feasible to make your model in Blender; export it and then animate it using Mdlvis?
     
  7. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    Yes! I like to think that the current animation support is at least as good as that of MDLVis, though.
     
  8. Astrella

    Astrella

    Joined:
    Oct 3, 2008
    Messages:
    155
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Alright; thank you. I'm not really sure what I'm going to do yet cause I'm new with this. Just wanted to know my options. I'm very grateful for you making this plugin though cause I feel Blender probably has wider use than the made-for-Warcraft tools handy as they might be so will definitely give both options a go. :)
     
  9. NightStalker

    NightStalker

    Joined:
    Apr 21, 2013
    Messages:
    1,193
    Resources:
    5
    Icons:
    4
    Spells:
    1
    Resources:
    5
    Hey Fingolfin, the plug in worked flawlessly for my model. Just a quick question though! It is from my lack of knowledge; I mapped each and every nook n cranny of my spaceship model, they show on the model as I want it to be. But I don't know how to export each texture separately with the UV layouts. When I select all and try to export the layout all I get is a blank background and many lines depicting my vertices.

    So question is; how can i export the layouts easily without re wrapping them one by one for each part, so that the Magos Model Editor can detect the textures as well? Right now Magos sees it as just a solid spaceship with no textures.
     
  10. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    Hey, glad it works for you! What you need to do with the textures is to assign a material for each part which you want to have a separate texture for. It is possible to have multiple materials on the same mesh and assign them to different faces by selecting them in edit mode and pressing "assign" with the material selected. Then, you need to set up the MDL data for each material in the bottom of the panel where it says "MDL Material Settings", as described in the manual. Make sure to set your texture paths correctly in the material layer. Finally, you need to use a BLP converter to convert your textures and place them in the same folder where you export your model. If you export it and open it in Magos, it should now display the textures.

    Also note that in the image/uv editor, you can go to UV>EXPORT UV LAYOUT to get an image with your uv layout to base your texture on - just remember to set opacity to 1. There is also a plugin called "texture atlas" which lets you unwrap multiple meshes at the same time.
     
    Last edited: Feb 14, 2019
  11. NightStalker

    NightStalker

    Joined:
    Apr 21, 2013
    Messages:
    1,193
    Resources:
    5
    Icons:
    4
    Spells:
    1
    Resources:
    5
    AWESOME! The textures now show correctly in Magos. I can't tell you the hype to see the result in the game haha :D
     
  12. Hetgrum

    Hetgrum

    Joined:
    Oct 29, 2017
    Messages:
    69
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I would appreciate help with exporting an animation. Exporting mesh works fine.

    Here I have a cube. It has bone "main". I animated it to scale. Enlarge on "Birth", stay still on "Stand" and shrink on "Death". Those are marked in Blender. In resulting *.mdl there are no keyframes. Previous attempts yielded something, however distorted.
    +
    Scaling is the specific feature I need to work for my actual model.
     

    Attached Files:

    Last edited: Feb 25, 2019
  13. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    The problem is that you have animated the armature, and not the bone itself. The armature is just a container for a set of bones - right now, the exporter doesn't support animating the armature itself, but this is being added soon.

    To fix this, press your armature and enter "Pose Mode". Select the main bone and animate it in the same way as you did before. Also remove your old animation. If you only need a single bone though, it can be easier to just replace the armature with an empty object with a name which starts with "Bone_", and parent the mesh to it.
     
  14. Hetgrum

    Hetgrum

    Joined:
    Oct 29, 2017
    Messages:
    69
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Alright, I think it worked now. Thank you.

    Just a few more questions, if you will.

    I think animating distorted the mesh in the resulting MDL. What is the best way to bypass that? Namely, the mesh or the object in the MDL is the scale of the first frame of the Birth animation. Which is tiny. If I just make the first frame different, will that change the outcome?

    Another question. How does it map Blender timeline to WC3 one? For example, I need to ensure that Birth and Death animations take exactly 1 second, which is 1000 frames normally in MDL.
     
  15. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    Yes - the first frame is used as the "reference pose", i.e. it becomes the neutral state of your model. I really should make it so that it somehow inverse transforms all animations used in this frame, but it is easier said than done. It is easy to fix this though by just adding a frame with the scale of 1 at frame 1, and moving the start of your birth animation to another frame. Overall, whenever you want to animate something, make sure to add a keyframe to frame 1 first so as to preserve your reference pose. I should probably make a tutorial on how to animate with this tool.

    The number of frames per second in the timeline can be set manually in the render tab of the properties menu, under "Dimensions". It defaults to 24fps, but you can set whatever value you want there.
     
  16. Hetgrum

    Hetgrum

    Joined:
    Oct 29, 2017
    Messages:
    69
    Resources:
    1
    Maps:
    1
    Resources:
    1
    How does the fact that bones have their own direction influence the animation? It seems to me that it conflicts with how WarCraft 3 does it. For example, I need to make sure that bones "up" is Z axis to make sure that scaling mesh works properly. Unfortunately it skews billboarding. That is, I need to rotate objects to compensate for the rotated bones. Am I doing something wrong?
     
  17. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    You shouldn't have to do that, though I can have a look when I get home. It is possible that non-uniform scaling can turn out weird, I will have to check. Billboards should work as long as they are facing forward at frame 1. This is the same as in art tools.
     
  18. Hetgrum

    Hetgrum

    Joined:
    Oct 29, 2017
    Messages:
    69
    Resources:
    1
    Maps:
    1
    Resources:
    1
    When I scaled bone in Blender, it scaled along the Z axis of the world and along the Y axis of the bone itself. However, in War3ME it just scaled along Y axis. That is, instead of scaling up and down it scaled sideways. If I interchanged the modification in Blender, the result in War3ME would change accordingly.

    I encountered people having similar problems with exporting to Unity. Their answer was to rotate the bones.

    I no longer have the model in question, that exact version anyway. If I will reliably reproduce the issue, I will share it here.
    +
    As to billboards I have the same issue that was already discussed in this thread. I will figure it out.
     
  19. SadAlexey

    SadAlexey

    Joined:
    Jul 20, 2019
    Messages:
    1
    Resources:
    0
    Resources:
    0
    Good day and thanks for creating a great tool.
    I've only one little problem with this addon.
    it seems to produce double vertex for each triangle/face the vertex relates to.
    Which enlarge an overall filesize of a model.
    Is there any way to fix that?
    I currently merge double vertexes in Mdlvis manually.
     
  20. Fingolfin

    Fingolfin

    Joined:
    Jan 11, 2009
    Messages:
    3,247
    Resources:
    154
    Models:
    144
    Icons:
    1
    Packs:
    4
    Skins:
    2
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    154
    This is because you are exporting with flat shading. Set shading to "smooth" and the vertices will be merged. You can also turn on "auto smooth" to get hard edges in appropriate places. Note though that hard edges are achieved by splitting the normals, so by definition this will duplicate the vertices along those edges.

    Suzanne.PNG

    In other news, i added a new way of exporting vertex color. The regular workflow is to change or animate the "object color" field to get a vertex color "tint", but now you can also add vertex color per material by adding a node called "VertexColor" to the graph. The exporter will use the color from the node's first input socket, so the node needs to have a color there, otherwise you will probably get an error. Examples of nodes you can use include Emissive BSDF, Diffuse BSDF, Mix Color - anything which has a color input. Now that i think of it, i should probably change it so that you'd use an RGB input node instead, for less ambiguity... maybe i'll do that in the future. Also: this feature is somewhat hackishly implemented and will not work if the mesh has multiple material slots. It uses the active material slot of the object.
     
    Last edited: Jul 20, 2019