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 3
Joined
Jul 15, 2020
Messages
10
@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: 81
  • CustomWaterElemental.mdl
    149 KB · Views: 53
  • CustomWaterElemental.blend
    1.3 MB · Views: 43
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
183
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 18
Joined
Apr 12, 2018
Messages
498
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.
 
Level 7
Joined
Oct 26, 2014
Messages
79
@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
183
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 3
Joined
Oct 16, 2020
Messages
11
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
183
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
 
Top