• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

MDL Exporter for Blender3D!

Level 1
Joined
Feb 21, 2019
Messages
6
thanks for this, sorry if this has been asked before, but can you make a mdl importer aswell ? i tried some mdl importers for models but none of them work and set properly as i want them to.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
I just realized you asked a question and I never replied.

1.5 years later, yes there models with animated helpers.

Just as an example of when such a thing is needed, imagine if you want to have a mesh that moves in a circle around the model's center, but also rotates/scales around itself (afaik this is a pretty common effect?)

I don't have the WC3 resources right now, but just opening the first arbitrary custom model I have in my pc with helpers gave me helpers with rotation animations.

At the end of the day, the node tree in WC3 models isn't a skeleton, it's more akin to a scene.

Did you figure out how to convert between the visual and numerical representations of tangents?
 
Level 6
Joined
Jul 15, 2020
Messages
21
@Fingolfin I've been using your MDL Exporter to make my first Warcraft 3 model. It's been very helpful!

I've been having trouble doing texture animations. I made a Mapping Node with the same name as the layer that I want to animate, and I've added some keyframes to the Location of the Mapping Node. My resulting .mdl file doesn't have a TextureAnims section, and there is no texture animation. I'm not sure where I went wrong. Can you attach a screenshot showing how to do it correctly?

I'm using the 2.8.0 branch of your MDL exporter. I'm also using Blender 2.83

EDIT: I did a bit of debugging myself by adding some logs to your script.

EDIT 3: I made the logging a bit easier to read by removing some redundant lines. The code and log output have been editted for clarity

I modified the get() function of your War3AnimationCurve() class to give some logs:
@staticmethod
def get(anim_data, data_path, num_indices, sequences, scale=1):
curves = {}

logging.debug('data_path = %s' % data_path)
if anim_data and anim_data.action:
logging.debug('anim_data.action.fcurves = %s' % anim_data.action.fcurves)
for index in range(num_indices):
logging.debug('anim_data.action.fcurves[%d].data_path = %s' % (index, anim_data.action.fcurves[index].data_path))
curve = anim_data.action.fcurves.find(data_path, index=index)
if curve is not None:
logging.debug('curve = %s' % curve)
curves[(data_path.split('.')[-1], index)] = curve # For now, i'm just interested in the type, not the whole data path. Hence, the split returns the name after the last dot.

logging.debug('curves = %s' % curves)
if len(curves):
return War3AnimationCurve(curves, data_path, sequences, scale)
return None

I get log messages like this:

DEBUG:root:data_path = nodes["Colours"].inputs["Location"].default_value
DEBUG:root:anim_data.action.fcurves = <bpy_collection[3], ActionFCurves>
DEBUG:root:anim_data.action.fcurves[0].data_path = nodes["Colours"].inputs[1].default_value
DEBUG:root:anim_data.action.fcurves[1].data_path = nodes["Colours"].inputs[1].default_value
DEBUG:root:anim_data.action.fcurves[2].data_path = nodes["Colours"].inputs[1].default_value
DEBUG:root:curves = {}

It looks like the datapath has a "1" instead of "Location" in its key for whatever reason. I'm not too knowledgeable about the Blender API, so I'm not sure how to interpret this.

EDIT 2: I've tried switching back to Blender 2.8.1 and installing the MDL Exporter there, but I get the same result with the same debug messages.

EDIT 4: I have attached my .blend file so you can check everything yourself
 

Attachments

  • IssuesWithMDLExportTextureAnimation.png
    IssuesWithMDLExportTextureAnimation.png
    945.5 KB · Views: 167
  • CustomWaterElemental.mdl
    149 KB · Views: 89
  • CustomWaterElemental.blend
    1.3 MB · Views: 100
Last edited:
Level 1
Joined
Feb 21, 2019
Messages
6
Ok, thanks. Until now i have 2 issues with this exporter.
The exported model its not facing front direction, but facing left angle, in blender my model it is facing front, perhaps viewport issues?
Cant export animations right, they appear diferently when i preview them with magos, even with custom fps, my animations are fast and dont have long keyframes, thats maybe the problem?
 
Level 5
Joined
Mar 6, 2017
Messages
190
Ok, thanks. Until now i have 2 issues with this exporter.
The exported model its not facing front direction, but facing left angle, in blender my model it is facing front, perhaps viewport issues?
Cant export animations right, they appear diferently when i preview them with magos, even with custom fps, my animations are fast and dont have long keyframes, thats maybe the problem?
this is the "front" in blender, u might want to rotate it by -90 degree
upload_2020-9-1_10-32-19.png
 
Last edited:
Level 1
Joined
Feb 21, 2019
Messages
6
Yea, just noticed that, front views are different from blender to warcraft.
Its not a good idea just rotate it, because my animation is following y axis, so if i do it will not be the same as i want.
Still the problem not fixed even if i change the view to right, still exporting wrong, left angle.
Screenshot
Screenshot
 
Last edited:
Level 1
Joined
Oct 26, 2020
Messages
1
It worked well for me,but I have a little problem about the bone's order,I tried Neodex 2.7,it always read the first bone from rootbone,and read the parent bones before the children bones,is it possible to do this in blender?
 
Level 20
Joined
Apr 12, 2018
Messages
494
What technical significance does bone order have in the file?
I suppose technically nothing, but it is kind of a pain when reading it in textpad when none of the bones are in any consistent order.

Since no tool is perfect sometimes copy/pasting bone information manually has to happen and a lot of the time with this exporter it boils down to Ctrl-F the bone names.
 
I suppose technically nothing, but it is kind of a pain when reading it in textpad when none of the bones are in any consistent order.

Since no tool is perfect sometimes copy/pasting bone information manually has to happen and a lot of the time with this exporter it boils down to Ctrl-F the bone names.

I understand, currently i think they are written from a hashtable which results in a random order.. maybe i can put them in a list sorted by name before writing them to file.
 
@Fingolfin

Hi! Imported FBX model to Blender, added "Markers" in animation timeline. Then exported model to a MDL via your plugin, then i've got this result:

On the left side you can see the model i've got after exporting from Blender, it have problems with storing vertices connected properly to bones.

On the right side you can see reference model that does not have that problem (but have a lot of other problems haha, but that is not a case now).

So, i am thinking that there is somewhere problem in code.

Also you can look at those screenshots and video below:

And, i've sent you a .blend file in PM.

jP7WfVACVAc.jpg

 
Last edited:
@Fingolfin

Hi! Imported FBX model to Blender, added "Markers" in animation timeline. Then exported model to a MDL via your plugin, then i've got this result:

On the left side you can see the model i've got after exporting from Blender, it have problems with storing vertices connected properly to bones.

On the right side you can see reference model that does not have that problem (but have a lot of other problems haha, but that is not a case now).

So, i am thinking that there is somewhere problem in code.

Also you can look at those screenshots and video below:

And, i've sent you a .blend file in PM.

jP7WfVACVAc.jpg


Unfortunately, Warcraft has some limitations on bones which can reduce the quality of animations. Most significantly, it doesn't support bone weights at all - you can only have a set of max 3 bones per vertex, which will all have an equal influence. Since all bones will get the same influence regardless of weight, the exporter will filter out those weighted less than 0.25. You might need to tweak the weights to get good looking animations.
 
Level 5
Joined
Mar 6, 2017
Messages
190
Unfortunately, Warcraft has some limitations on bones which can reduce the quality of animations. Most significantly, it doesn't support bone weights at all - you can only have a set of max 3 bones per vertex, which will all have an equal influence. Since all bones will get the same influence regardless of weight, the exporter will filter out those weighted less than 0.25. You might need to tweak the weights to get good looking animations.
I see they're both the war3 models, so it must be problem in your code, or blender
 
Level 4
Joined
Oct 16, 2020
Messages
15
okay then, looks youre right but still has issues Screenshot it imports like this , but i want to export with bones for both objects Screenshot Screenshot, doesnt have sense it the bones are imported to the parent, but not the childs ( i duplicated both objects tho, the mesh and the armature objects)
armature and armature 001 are parented to armature 002 Screenshot Screenshot
 
Level 5
Joined
Mar 6, 2017
Messages
190
Hi, could you change the way to export animation by actions instead of creating markers? it's easier to edit the model's animation and not give any errors to the other ones
 
Hi, Can you take a look at this problem
View attachment 399027

That's strange, it works just fine for me... can you try uninstalling the exporter, restart Blender, and then try it again with the file i attached below? If that doesn't work, can you try it again but with Blender 3.1?
 

Attachments

  • export_mdl.zip
    106.8 KB · Views: 36
Level 6
Joined
Jul 15, 2020
Messages
21
I've been using this plugin to make some models.

I've noticed that when I add a few vertices in Blender, the MDL file produced has way more vertices in it.

I have attached two models. "SpiritLantern_MyriadFungiForHive.mdx" is the model before I added more vertices, and "SpiritLantern_MyriadFungiForHive_more_vertices.mdx" is after I added some more vertices. I added 18 vertices to the model in Blender, and the MDL has over 100 more vertices than before. Am I doing something wrong?

I am using Blender 2.8.3. I am using a version of the plugin from 2020. I downloaded it in August 3, 2020, so it's probably revision 939afdfeb70a0d926d8172607030b22781cd1d3d in the git repository.

I have attached the Blender file.

Please help me when you have time.
 

Attachments

  • SpiritLantern_MyriadFungiForHive_more_vertices.mdx
    20.3 KB · Views: 12
  • SpiritLantern_MyriadFungiForHive.mdx
    16.5 KB · Views: 12
  • SpiritLantern_MyriadFungiForHive.blend
    783.2 KB · Views: 13
Last edited:
Level 3
Joined
Dec 30, 2021
Messages
20
I've been using this plugin to make some models.

I've noticed that when I add a few vertices in Blender, the MDL file produced has way more vertices in it.

I have attached two models. "SpiritLantern_MyriadFungiForHive.mdx" is the model before I added more vertices, and "SpiritLantern_MyriadFungiForHive_more_vertices.mdx" is after I added some more vertices. I added 18 vertices to the model in Blender, and the MDL has over 100 more vertices than before. Am I doing something wrong?

I am using Blender 2.8.3. I am using a version of the plugin from 2020. I downloaded it in August 3, 2020, so it's probably revision 939afdfeb70a0d926d8172607030b22781cd1d3d in the git repository.

I have attache the Blender file.

Please help me when you have time.
I have the same problem
 
I've been using this plugin to make some models.

I've noticed that when I add a few vertices in Blender, the MDL file produced has way more vertices in it.

I have attached two models. "SpiritLantern_MyriadFungiForHive.mdx" is the model before I added more vertices, and "SpiritLantern_MyriadFungiForHive_more_vertices.mdx" is after I added some more vertices. I added 18 vertices to the model in Blender, and the MDL has over 100 more vertices than before. Am I doing something wrong?

I am using Blender 2.8.3. I am using a version of the plugin from 2020. I downloaded it in August 3, 2020, so it's probably revision 939afdfeb70a0d926d8172607030b22781cd1d3d in the git repository.

I have attached the Blender file.

Please help me when you have time.

This is not really a problem as much as an expected result. In Warcraft 3 models, each vertex has a normal, a UV coordinate, and a position, and if any of those values diverge (let's say two vertices have the same position but there's a UV seam, or a sharp edge), then the vertex must be split. But Blender has a much more efficient way of dealing with vertices, where UVs and normals are stored in "loops", which are defined by the boundary of the polygon. So it's a technicall difference between Wc3 and Blender that causes this.

One thing you can do is to merge vertices (select all vertices, then CTRL+M > by distance), and then use auto smooth in the vertex data settings to get the right edges. If your model is set to use "shade flat", then all vertices will be split - this would cause a lot of extra vertices.
 
Level 4
Joined
Oct 16, 2020
Messages
15
This is not really a problem as much as an expected result. In Warcraft 3 models, each vertex has a normal, a UV coordinate, and a position, and if any of those values diverge (let's say two vertices have the same position but there's a UV seam, or a sharp edge), then the vertex must be split. But Blender has a much more efficient way of dealing with vertices, where UVs and normals are stored in "loops", which are defined by the boundary of the polygon. So it's a technicall difference between Wc3 and Blender that causes this.

One thing you can do is to merge vertices (select all vertices, then CTRL+M > by distance), and then use auto smooth in the vertex data settings to get the right edges. If your model is set to use "shade flat", then all vertices will be split - this would cause a lot of extra vertices.
this doesnt seem to work, still my model has a lot of vertices, and CTRL+M is not actually to merge, is to mirror, Alt+M is to merge, and "merge by distance" is called "remove doubles" in old blender
 
Top