This is a read only copy without any forum functionality of the old Modcraft forum.
If there is anything that you would like to have removed, message me on Discord via Kaev#5208.
Big thanks to Alastor for making this copy!

Menu

Author Topic: [TUTORIAL]Custom m2 using MDXtoM2 + fixing broken animations  (Read 10042 times)

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
[TUTORIAL]Custom m2 using MDXtoM2 + fixing broken animations
« on: March 29, 2015, 02:10:33 pm »

Introduction


Hello, Modcraft. Today I am going to show you guys how to make custom non-animated .m2 models out of .mdx (Warcraft III) models. It is believed that converting models using MDXtoM2 is quite a complicated process but actually it is not that hard.
You may ask: "Why do we need to do it if we have OBJtoM2 and it works fine?" Well, the answer is simple. This converter provides you a lot more possibilities than OBJtoM2, such as multiple materials, textures, lights, animations and etc. At first, I will show you how to convert static .m2s but I am going to update this tutorial from time to time when I find out something new. Okay let's go.

Tools and resources



The full conversion will require quite a big bunch of tools which you have to download.

1) MDXtoM2Converter_lazy - a tool that generates .m2 models out of .mdx files.
2) 3DS Max with MDX export plugin or Milkshape. Well, just something to convert your model to .mdx. If you already have your .mdx object, you don't need it.
3) MDLXConverter - a tool that converts .mdx files into .mdl files which are possible to edit manually via Notepad.
4) MDLVis - .mdx/.mdl editor.
5) War3ModelEditor- a tool that allows you to add some additional sections to .mdx, such as lights, bones etc.
6) BLPLab - for converting your textures to .blp (BLP2) file format which is undesrtandable for WoW. (Warcraft textures are BLP1 and cannot be read by WoW).
7) Collision adder - a tool that generates collision in your m2 file.
8) Resizer.py - a python script that allows you to resize the initial size of your model.
9) PyModelEditor (+Python 2.6 (see PyME thread for details)) to run Resizer.py
10) AddViewDistance for editing the render distance of the model.
11) Sweetscape 010 editor (+ M2 template)  - a hex-editor which we are using for fixing bugs in the model.
12) Nullmodel.mdl - .mdl template to make your model understandable for MDLVis.
Well, there are plenty of other utilities that can make your model better but they're not essential. The list is quite huge, but don't worry, it won't take that long to get your model into game. Tools which are not linked here are either included into one of the linked packages or can be found in the resource section of Modcraft.


Chapter 1. Static models




Step 1. Preparing your model



1. I won't explain you how to make an .mdx model. There are plenty of tutorials on this theme over the internet.
At first, your .mdx file does not contain all the information you need for converting it to .m2. In order to fix it you need to convert your .mdx file into .mdl using MDLXConverter. I will call the result model tree.mdl.
2. When it is done you need to open your model in MDLVis. To make MDLVis open your file you have to make the .mdl structure understandalbe for MDLVis. So, pick up Nullmodel.mdl and tree.mdl model and open them in Notepad++.
Find a section called Model in your tree.mdl and add missing strings into this section from Nullmodel.mdl.

* tree.mdl
Quote
}
Model "pine" {
   BlendTime 150,
   MinimumExtent { -261.362000, -252.451996, -88.562103 },
   MaximumExtent { 273.287994, 307.015015, 1465.869995 },
   BoundsRadius 796.038025,
}

* Nullmodel.mdl
Quote
}
Model "Sword_2H_Claymore_A_01" {
   NumGeosets 1,
   NumGeosetAnims 1,
   NumBones 1,
   BlendTime 150,
}

* Result
Quote
}
Model "pine" {
    NumGeosets 1,
   NumGeosetAnims 1,
   NumBones 1,
   BlendTime 150,
   MinimumExtent { -261.362000, -252.451996, -88.562103 },
   MaximumExtent { 273.287994, 307.015015, 1465.869995 },
   BoundsRadius 796.038025,
}

3. Now go to the end of both files and replace everything starting from "Bone" till the end of the file using data from Nullmodel.mdl. Now you can open your model in MDLVis.
4. Find string Image and write in the path to your textures. This path will be used in your MPQ files.

Step 2. Fixing the model in MDLVis



1. For some reason MDXToM2 does not create a usual transparancy chunk in the model. In order to resolve this issue open your model in MDLVis, go to Modules>>Sequences>>Skeleton>>Switch back to Anims. Select both geosets (using check boxes) and mark them as visible.
2. Save your model as .mdx



Step 3. Solving possible problems



1. In most cases now you can just drag'n'drop your tree.mdx to the converter and it will turn it to m2. Try doing it. If there is a crash open your .mdx in War3ModelEditor, go to Windows>>Node editor>>Right click on the bone>>Add light. Add 4-5 lights and try converting the model with MDXtoM2_lazy. If it does not work, add more lights. Okay, you should get your .m2 model now.



Step 4. Fixing  different converter issues


1. Open Resizer.py with a Notepad. (should be placed inside a PyModelEditor folder). Edit paths to your model, set the size to 0.02. We need to decrease the scale of your model in 50 times. Save the file.
2. Run it by double clicking. If it works you will see a black command promt window for a second.

3. Open your model in the 010 editor. Run a template on the file.
4. Go to "struct TheFloats floats" and divide each value there by 50. For doing this operation faster open "Hex operations" tab, "Divide". Use the following settings: Treat Data As: Float, Operand: 50, Decimal, and press Okay. Now make sure that BoundingBox size is equal to VertexBox size. If not, copy values from bounding box to vertex bpx. Go to "struct sAnimations _Animations" and make sure if the bounding box values are divided by 50 too.



5. Go to "struct RenderFlags _RenderFlags" and set the blendingmode of every geoset to RM_AlphaTesting (1) (for usual models) and set the Render Flag to the one you need. I used double sided on my leaves geoset to make it visible from both sides. You can find the flag explanation on the WoW Dev Wiki.
6. If you added lights with War3ModelEditor you have to go to "uint Lights", "ofsLights" and set the values to 0. Then go to "struct Lights", select the section and press Shift + Delete on the selected bytes.

Step 5. Adding collision



1. If you need your collision to be 100% of the size of the model, just drag'n'drop your .m2 on CollisionAdder.exe and you're done. If you need to make some parts of the model non-collideable, you need to create another .m2 model which contains only the geometry you need to keep the collision on. You can even add more geometry if you need to make some invisible collsion walls in your model or smth else. For example, for making tree collision for the second model you leave only bark without leaves. Generate the collision for this model and open both ones in the 010 editor.
1. Copy the values from "uint BoundingTriangles",  "uint BoundingVertices" and "uint BoundingNormals" to your model. Go to the end of the file and add 5-6 empty strings containing only zeros.



Pick up the offset of the last empty string and write it to "uint ofsBoundingTriangles". Copy the entire bounding triangles section to the empty space. Finish the string with zeros. Pick up the offset of the new string and do the same for the rest two sections.



You're done. Don't forget to rescale the collision model before doing that using Resizer.py.

Chapter 2. Animated models



I won't explain you how to convert animated models because there already a good tutorial by Phucko1 which should explain you everything you need to know about getting animated models to work. Here it is: http://modcraft.io/viewtopic.php?f=20&t=5536 So, let's think you already have your model converted.

However, I am pretty sure that after doing eveything written there most of your model animations will be glitchy. How? This video is the only example I found over the internet, but it looks exactly like this: [media:2egyg736]http://www.youtube.com/watch?v=TUtNSHAPML4[/media:2egyg736]
(To the author of this: I just used your video to show how the bug looks like and demonstrate the solution to this problem. I hope you understand it.)

Well, as you can see, some models glitch on some parts of animation. If you reduce the speed of changing frames, you will notice that it looks like the animations start going back at some point. So, it is correct in general, but goes in wrong backwards direction instead of looping. Yeah, that's the mistake of MDXtoM2 converter. I don't know what exactly it is caused by, but I know quite a simple solution for this problem.

Step 1. Gethering data



Go to model viewer and open your model. Start playing animations in slow motion mode and make a list of the bugged ones. Now, comes the hardest part. By moving the frames switcher in your WMV you change animation frames. Though, not all of these frames are real. Actual KeyFrames are written to M2, and there are not so much of theme. All other hundreds of frames are just interpolation between them. So, you need to slowly move this switcher and stop it when the animation starts behaving weirdly (most likely goes back or loops where it is not supposed to).  Pick up this numbers and add them to your list under your animation. Do it for every animation if necessary.Keep in mind that these frames value are always approximate, and later you will need to find the closest keyframe value. Though, it is not hard as it probably seems to you now. By opening your model in MDLvis (mdx/mdl source model, not m2), you can pickup the bone numbers of the bugged animation parts. Just look in WMV what parts of the body swing badly, find the corresponding bone numbers in MDLVis and add them to the list for each bugged animation.

Step 2. Fixing bugs



Now open your model in pymodeleditor. Show Node Tree>>Pick up the bone

You will now see the Bone Editor. Here you have two buttons: Edit Translation and Edit Rotation. One of them, or both can contain bugged data. Fortunately, it is quite easy to track.

When you open either of them, you get the animation KeyFrames cords. For fixing animations, you need to pick up the animation ID of the animation you need to fix in the dropdown menu marked as 4 in the screenshot. Now, speaking about the data itself.



Let's now see what is wrong here. This the original block of data.

Quote
0:{ -32759 , -32317 , -32287 , -7 }
1:{ -32758 , -32317 , -32287 , -7 }
105:{ -31914 , 31173 , -31813 , -64 }
243:{ -29948 , 26571 , -31292 , -749 }
313:{ -29284 , 25977 , -31367 , -932 }
382:{ -28844 , 28110 , -31543 , -595 }
521:{ -29063 , -29421 , -32425 , -385 }
590:{ -29558 , -27700 , 32598 , -555 }
694:{ -30218 , -29822 , 32081 , -240 }
868:{ -31503 , 28143 , 31892 , -365 }
973:{ -32071 , 25472 , 32029 , -839 }
1077:{ -32320 , 26522 , 32240 , -609 }
1251:{ -32396 , 31488 , 32626 , -28 }
1424:{ -32577 , -32500 , -32588 , -3 }
1667:{ -32758 , -32317 , -32287 , -7 }
1668:{ -32759 , -32317 , -32287 , -7 }

The number of the each string before ":" is a KeyFrame number. So, the error should be in some numbers close to our previous WMV records. If you look carefully, some values does not follow the common pattern in the middle of the structure. The errors can be only related to negative/positive value differences. You never need to change the numbers. In most cases you mostly need to remove some minuses in from of the first value. But I picked up the hardest example I could find for you here.  :twisted:

Quote
521:{ -29063 , -29421 , -32425 , -385 }
590:{ -29558 , -27700 , 32598 , -555 }
694:{ -30218 , -29822 , 32081 , -240 }

These 3 keyframes look weird for me. And they suprisingly almost exactly match my WMV aniamtion bug records.
Let's see why. Keep a look at the second coloumn.  These 3 values are negative while everything around them is positive. Here our animation is most likely to go backwards. Let's change them to positive.

Quote
0:{ -32759 , -32317 , -32287 , -7 }
1:{ -32758 , -32317 , -32287 , -7 }
105:{ -31914 , 31173 , -31813 , -64 }
243:{ -29948 , 26571 , -31292 , -749 }
313:{ -29284 , 25977 , -31367 , -932 }
382:{ -28844 , 28110 , -31543 , -595 }
521:{ -29063 , 29421 , -32425 , -385 }
590:{ -29558 , 27700 , 32598 , -555 }
694:{ -30218 , 29822 , 32081 , -240 }
868:{ -31503 , 28143 , 31892 , -365 }
973:{ -32071 , 25472 , 32029 , -839 }
1077:{ -32320 , 26522 , 32240 , -609 }
1251:{ -32396 , 31488 , 32626 , -28 }
1424:{ -32577 , -32500 , -32588 , -3 }
1667:{ -32758 , -32317 , -32287 , -7 }
1668:{ -32759 , -32317 , -32287 , -7 }

And it works like that for Translations and Rotations. Just save your files more often to avoid erros and make backups. It takes approximately and hour for every model. But I am pretty sure if you do it often, you will get a faster skill.


That's all for now. Big thanks to Vel, Malice and other people who helped me and to the authors of all these tools I used here. I will add some pictures soon enough to make this tutorial more understandable for newbies. If you don't undestand something (my English sucks) or have some problems/tips feel free to ask me. Check this thread from time to time for getting recent updates. Good luck with your first model ;).
« Last Edit: May 25, 2015, 04:54:31 pm by Admin »

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #1 on: March 29, 2015, 10:55:52 pm »
Updated the tutorial with images for better understanding of the complicated steps.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Alastor

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 1105
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #2 on: March 30, 2015, 04:49:47 am »
or you can import directly as M2 :D


but i personally never start to using 3dsm only because i would export m2 and not obj that will be converted to m2
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
No matter how fast light travels it finds the darkness has always got there first and is waiting for it
Star Citizen Referral Code : STAR-XNFS-HVL9

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #3 on: March 30, 2015, 09:21:55 am »
As i said in the first post, this is not a tutorial about getting your model into .mdx/3d editors or something else. But thanks for the tip anyway, it is useful for someone who wants to modify existing m2s.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #4 on: March 30, 2015, 01:51:52 pm »
Wait. Are these export plugins? Where I can get them? Are they public?
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Alastor

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 1105
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #5 on: March 30, 2015, 02:05:09 pm »
This script is unfinished random fire of some idk men
its exporting only staic models without armature and there are problems with collisions bouding boxes floats you dont want these ... AND mainly there is bad structure in these script i dint posted this as real way more likely funny thing

i plan to manage about export/import script for Blender in future even with armature options
i just dont see way in 3dsm too complex for me


BUT if ouy are interesed in these scripts Scripts for M3 are working nicely you could use them as base for M2 scripts i mean just little rework beceause M3 and M2 arent much diferent
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
No matter how fast light travels it finds the darkness has always got there first and is waiting for it
Star Citizen Referral Code : STAR-XNFS-HVL9

spik96

  • Registred Member
  • Model Change Addict
  • *****
  • Posts: 275
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #6 on: April 03, 2015, 06:19:47 pm »
Hi ! Fantastic tutorial :) ! However the link to the M2 Template downloading page is dead (links to filedropper.com)
(easy to find on these forums anyway)
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Github ]https://github.com/Koward[/url]    Skype : koward723 =)

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #7 on: April 03, 2015, 06:34:53 pm »
Thanks, I will reupload it soon enough. Animation conversion is coming soon too.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Alastor

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 1105
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #8 on: April 03, 2015, 06:54:27 pm »
here
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
No matter how fast light travels it finds the darkness has always got there first and is waiting for it
Star Citizen Referral Code : STAR-XNFS-HVL9

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #9 on: April 03, 2015, 10:58:28 pm »
Thank you for the link.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

spik96

  • Registred Member
  • Model Change Addict
  • *****
  • Posts: 275
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #10 on: April 04, 2015, 08:33:35 pm »
Quote from: "Skarn"
Thanks, I will reupload it soon enough. Animation conversion is coming soon too.

So we could convert a WC3 model with its animations to WoW ? I never seen anything like that. Would be interesting for sure.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Github ]https://github.com/Koward[/url]    Skype : koward723 =)

phucko1

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 523
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #11 on: April 04, 2015, 08:36:33 pm »
Quote from: "spik96"
Quote from: "Skarn"
Thanks, I will reupload it soon enough. Animation conversion is coming soon too.

So we could convert a WC3 model with its animations to WoW ? I never seen anything like that. Would be interesting for sure.


Lol that is easy, since the WC3 models are almost close to perfect for MDXTOM2 to convert. Just gotta remove camera and fix some bones afaik.

@Skarn
Good job at the tutorial, beats mine by miles :P
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #12 on: April 05, 2015, 07:48:57 am »
spik96, some guys have been doing it for quite a long time already.
@Phucko1 Thanks ;) Your one was useful too for learning how to convert at first.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

spik96

  • Registred Member
  • Model Change Addict
  • *****
  • Posts: 275
    • View Profile
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #13 on: April 05, 2015, 11:57:04 am »
Quote from: "Skarn"
spik96, some guys have been doing it for quite a long time already.

Well that's not a model from Warcraft 3. Looks more like an edited boss from Ulduar. XT01 or something like that.
But I take your word x) !
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
Github ]https://github.com/Koward[/url]    Skype : koward723 =)

Skarn

  • Contributors
  • Creator of Worlds
  • *****
  • Posts: 807
    • View Profile
    • http://skarn-project.net
Re: [TUTORIAL] Custom static m2 using MDXtoM2 (the full guid
« Reply #14 on: April 05, 2015, 12:25:26 pm »
It is a fully custom model created and animated in mdlvis which is for Warcraft III. Check other videos on this channel.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »