Import script for M2 files (WoW models)


I wrote a script someone might be interested in. It takes care of loading .M2 files, the models from World of Warcraft. It currently supports uv’s, normals, boneweights, mesh configuration (check the help text in the plugin) and loading and binding of the armature.

You can get it here: M2 import v0.7.1alpha

I have had animation support working but broke it when I started coding the GUI, so I’ll add that in the next version. Also, getting textures to map correctly as in: this image requires some work. The engine cuts the clothing and face textures together dynamically, so you’ll have to do that manually in PS§ or GIMP.

A screenshot of the mesh configuration UI

Have fun!

  • dreeze

Looks really cool, but whenever I try to load a .m2 I get a “struct.error: unpack str size does not match format” error…
I’m using Blender 2.43 with a Python 2.4.4 install on Windows XP SP2 x86
Pythonpath variable is correctly set… any idea?
Thank you in advance…

I’ve been trying to find the .M2 files but I can’t see them anywhere in the WoW game map.

.M2 files are embeded into .MPQ (those are a sort of archive files, like zips).
You need to search for an MPQEditor application somewhere on the net in order to be able to open them and extract files.

Hmm… okay, I haven’t tested the script in windows, I’m gonna try doing that and see what happens. I’ll get back to you.

There we go. I hope this works. I updated the link in the first post (version 0.7.1alpha).

Confirmed! It works now… now I’ll begin doing some tests (at the moment looks like not all the mesh have the UV coords).
Many thanks for the prompt solution!

I think the UV’s are correct (I could be wrong though), it’s how the engine treats the character textures that’s a bit of a mess (but it’s efficient renderingwise)

The body and face uses a 256x256 texture. The game dynamically builds this texture depending on the clothes your character is wearing. E.g for the female bloodelf model there is a file called BLOODELFFEMALESKIN00_0.BLP. This file contains the basic layout of all the parts and it pastes the other clothing parts on top of that file.

If that’s gibberish I can write up a little guide with screenshots to show you what I mean.

I’ve noticed the “messy” approach to the UV mapping and the fact that the meshes compose a sort of “puzzle” (I used as an example an export from WoWModelViewer), but loading the female bloodelf I have UV mapping on the body and hairs, but the vest mesh does not appear to have any UV data. The same on the male undead (I was trying to re-create my warlock), where also the vest looks like it’s not lagre as it should be.
Now that I think about that, in both cases these are “alternate” meshes to the pants, that are the first choice. Maybe there is a problem due to that?

Ah, yes, that’s quite possible. Now that I think about it, I don’t think I have tried texturing any alternate stuff but the hair. I’m going to look into that.

A really nice script. I’ve tried to import a bloodelf female mesh, added the textures to it which needed just a little tweaking and finally added the armature. But it seams that the armature contains loads of bones which don’t have a functionality or something, so I did removed it an build a complete new one to make it more perfect.

Finally I added a material to be able to render the textures with the mesh, and here is the result. :smiley:

This looks fantastic, Dreeze, but when I try and use this script I get the following error on a windows xp, blender 2.4.4.
“Traceback <most recent call last>:
File “<string>”, line 81, in <module>
ImportError: No module named struct”

What do I do to get this working?

Ok, i ran the script, and get nothing. When i went into the import, there was no way to import anything into it. A little help here please, Relatively new.

GnomePunter, you need to download python 2.5 (python 2.5) complete to run this script.


First, copy the m2 import into scripts folder: C:\Program Files\Blender Foundation\Blender.blender\scripts
Then, in Blender go to Menu and select, File, Import, M2 Model (.M2)

The script will run and in the 3D screen appear a new screen with 3 buttons, push “Select File” and search for M2 file. Then click on “Load Model”, click on the new button “Animations”, then “Load armature”, click button “Back” and to finish “Done”.

When you click in done you can see the new model with armature.

In my next post, I will give you all the files needed to import, how to texturize the new model and more…

I get the following error when I attempt to use this script. I’ve had a LOT of trouble installing scripts before, though…

Loading: /Volumes/Samus/WOWMODEL/Character/Goblin/Female/GoblinFemale.m2
Traceback (most recent call last):
  File "", line 1010, in button_event
  File "", line 851, in ButtonEvent
  File "", line 712, in LoadModel
  File "", line 330, in __init__
  File "", line 303, in LoadVertices
IOError: [Errno 22] Invalid argument

This is what my console reports, which indicates a problem, even though I am using the latest Blender AND Python installs. I’ll keep trying, though any help would be appreciated.

Oh, also, I use Mac OS X 10.4.11, for whatever that may matter.

I am trying to publish a guide and make animations of World of Warcraft characters in Blender here:

updating here with further information…

I run Blender 2.45 with Python 2.5.1 on my PowerPC 700 MHz G4, and the error that pops up is “Python Script Error - check console”, which produces the aforementioned error every single time. So apparently there is an invalid argument for some function, but I can’t figure out what it is.

It seems, squishythought has gone away… are there any news on the m2_import script?



Any word on importing animations?

Any person can edit this python code to fix the animation import? Thank you!