BlacRyu
03-01-2011, 05:51 PM
Ok, so I think this guide is going to end up pretty long, so I decided to just post it in pieces when I have time to work on it. Feel free to post feedback, suggestions, and/or requests here.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/Blizzard_logo.jpg
Model Importing
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/ysera_blend4.png
Table of Contents
Overview
Getting Ready...
Step 0: Choosing a Model
Step 1: Getting the Files
Step 2: Importing the Model
Step 3: Fixing stuff (textures, bones, animations)
Step 4: Exporting the Model
Step 5: Fixing more stuff (materials, animations)
Overview:
In this guide I will be explaining how to import models and textures from blizzard MPQ archives into HoN's K2 format. This (currently) includes the games Warcraft III, Starcraft 2, and World of Warcraft. 3D Models don't like being thrown around between different formats, so you will most likely run into some weird glitches which require even weirder workarounds to fix, and as such I don't expect this guide will be able to cover everything. So if you have any questions or you discover something useful that isn't in the guide please leave your questions or comments here.
Getting Ready...
Things you will need:
3DS Max 8 (not 2008)
M3 Plugins for 3DS Max (http://www.sc2mapster.com/assets/m3-export-plugin-3ds-max/files/24-m3-plugins-v1-7b/) (v1.8 doesn't seem to work with 3DS Max 8, so use 1.7b instead)
MPQ Archive Browser/Editor (http://www.zezula.net/en/mpq/download.html)
S2's 3DS Max 8 K2 Model Exporter (http://forums.heroesofnewerth.com/showthread.php?t=23225)
BLP Laboratory (http://www.hiveworkshop.com/forums/tools-560/blp-lab-v0-5-0-a-137599/) (not needed for WoW)
WoW Model Viewer (http://www.wowmodelviewer.org/) (use this one for WoW)
Things you will probably want:
An image editor. I personally use Paint.NET (http://www.getpaint.net/) and GIMP (http://www.gimp.org/about/introduction.html). Both are free to download and use.
Normal map plug-in for GIMP (http://code.google.com/p/gimp-normalmap/) is an easy way to generate normal map textures to add an extra layer of detail to a model.
Notepad++ (http://notepad-plus-plus.org/) is useful for editing the script/text files that HoN uses to define the properties of it's models and textures. It will give you XML syntax highlighting (if you set it up), as well as auto-tabbing and other useful coding stuff.
Step 0. Choosing a model
Before you can import a model, you have to know what it is you're going to import! If you don't already have one in mind, here are some good ways to get some ideas and see your model in action before you import it over to HoN.
0a. World of Warcraft: The best way to find a model from WoW is using the WoW model viewer (link in the above section). You can search for models by name, see them instantly, look through all their animations, and attach weapons and other items to them. It can also export the models into the M3 format which is needed to import them into 3DS Max 8, as the M2 importer doesn't seem work.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_wmv_ysera1.jpg
0b. Starcraft II: The best way I've found to look through the models in SC2 is by using the built-in previewer inside the Starcraft 2 Map Editor. To open the Previewer, click on Window > Previewer or press ctrl+shift+V
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/sc2Previewer.jpg
In order to see all the models you will need to create a blank map and add dependencies. To do this, click file->New..., then where it says Dependencies, click the Modify button, then click Add Standard and choose the dependencies you want (or just use all of them). When you click OK it will take a while to load all the assets. Then open up the previewer as stated above (ctrl+shift+V) and look through the models there. Alternatively you can browse/search for units in the terrain editor and then right click their name and click View in Previewer. Don't use anything that starts with SM or StoryMode, as it is meant to be used in cinematics and won't have the animations you would want to use.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/sc2Editor.jpg
0c. Warcraft III: The only reason I can think of for looking for models from WC3 is to import models from DotA for nostalgia's sake, so you probably already know what it is you want.
Here's a list of DotA Heroes in HoN: http://honwiki.net/wiki/DotA_vs_HoN#Ported_Heroes
Step 1. Getting the Files
1a. World of Warcraft: Alright, back to the WoW Model Viewer (link above). Once you have found the model you want, click on File > Export Model > Export Options....
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_wmv_exptopt.jpg
On the window the opens up, click on the M3 tab. Set the Bound Scale and Sphere scale to 1.0, leave texture path blank, and then select the animations you want to import. I recommend importing most animations, as you won't be able to come back and import more later. However, importing all the animations is usually a bad idea, as there are usually some animations that are broken to begin with (such as some of the emotes), and will cause problems with the model when you try to import. You can continue to mess around with the model in the viewport while this options window is open, so you can see which animations you want or if any are broken (you will definitely be able to tell if an animation is broken). Keep in mind that the animations are sorted by number in this window, while in the default viewing window they are sorted alphabetically.
Once you have all of your animations set, you can click Apply and close that window, then click File > Export Model > M3... and choose where you want to save the model file.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_wmv_m3exp.jpg
Then click File > Export Textures... and click on Export all to TGA. This will place all relevant texture files into the WoW Model Viewer/Export Directory. Now you should have everything you need and can start importing stuff into 3DS Max![/b]
1b. Starcraft II: To get the files from Starcraft 2 you will need the mpq editor linked in the Getting Ready section. First, make sure you don't have SC2 open as it won't let you access the files if it is. Now, open up the MPQ editor and click File -> Open MPQ, then navigate to your Starcraft 2 directory. There will be two directories here where your model could be located; Campaigns\Liberty.SC2Campaign or Mods\Liberty.SC2Mod. The folder it is in depends on whether your model was only used in single player or if it's a standard multiplayer unit. If you aren't sure where it is, just check one folder and if you don't see it there then try the other one. In each folder you should see a Base.SC2Assets and another one that corresponds to your language. First, open up the base.SC2Assets file (it should be the largest file). After you open the MPQ, first find the model you want by expanding the Assets folder, then the Units folder. You should be able to find the folder you want from there. Once you've navigated to your units folder, you should see a file with a m3 extension. Right click on it and click extract, then choose a location where you want to extract the file.
Now that you have the model, you will want to find the texture that goes with it. You can find all the textures in the Assets -> Textures folder inside base.SC2Assets. Open it up and search for the textures you think go with your model. You can filter through the files by using the File Mask box in the toolbar at the top. You need to use * as a wildcard, so for example, type in *zergling* to get all the textures for a zergling. Be sure you delete the mask after you find what you want or all the other folders will appear to be empty. Once you have the textures extracted, you will need to open them up with a compatible image editor (Paint.NET should work), and then re-save them as tga files.
And finally, sounds. If you want sounds for your unit there are two locations where they could be located. Firstly, for sounds other than speech, simply look in the Assets\Sounds folder in the same MPQ that you found your model. For sounds which are related to a specific language, you will need to open up the MPQ archive for that language (i.e. enUS.SC2Assets) and then look in LocalizedData\sounds. Once you find the sounds you want, just extract them like you did with the model/texture.
1c. Warcraft III: To get the files from Warcraft III you will need the mpq editor linked in the Getting Ready section. First, make sure you don't have WC3 open as it won't let you access the files if it is. Now, open up the MPQ editor and click File -> Open MPQ, then navigate to your Warcraft III directory. Your model will be inside either War3.mpq or War3x.mpq, depending on whether it is an expansion character or an original one. If you don't know which one it is from just try them each one at a time. Once you open the MPQ, you can either manually browse through the files for the unit you want, or click Tools -> Search Files... and search for the unit you want. Once you get to the folder for your unit, there should be two files with a mdx extension. If there isn't then your unit is probably just a re-skin of another model, and you'll have to figure out which one that is. Once you have your model, right click the mdx file that doesn't say portrait and click Extract, then choose a location where you want to extract the file. If you want to, you can extract the sounds now as well if there are any in the folder. Some sounds may be located in War3xLocal.mpq.
Now that you have the model, you will want to find the texture that goes with it. You can find all the textures in the Textures folder inside the MPQ. Open it up and search for the textures you think go with your model. You can filter through the files by using the File Mask box in the toolbar at the top. You need to use * as a wildcard, so for example, type in *arthas* to bring up the texture for Arthas. Be sure you delete the mask after you find what you want or all the other folders will appear to be empty. Once you have the textures you want, extract them like you did with the model. The textures should have a blp extension, but we want tga, so you will need to open up BLP Laboratory (linked in the Getting Started section) and then open and save the textures as TGA files.
Step 2. Importing the Model
2a. WoW & Starcraft II: At this point you should have at least one *.m3 file and one or more textures (*.tga). You will also need to have 3ds max 8 installed and the import scripts (http://www.sc2mapster.com/assets/m3-export-plugin-3ds-max/) downloaded.
Open up 3DS Max and Click on the Utilities tab.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_util.jpg
Now click on the button labeled MAXScript, then on the button labeled Run Script.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_script.jpg
Find and open the script you downloaded named m3_import_v0.30.ms. Then you should be able to select "M3 - Import" from the Utilities list just below. Click on it and the Import options should show up below. Click on the button labeled 'Open', then navigate to the m3 file for the model you want to import. Leave all the settings checked, and change the FPS from 1000 to 30. 30 FPS is the default used by HoN, but you will be able to tweak the animation speeds a little bit later if you need to. Now, click on the Import button. You should get a message saying that it couldn't find the textures in the maps directory. Just tell it to import anyways and it should work fine. If you get an error message that there isn't enough scripting memory, try importing again, sometimes it will fix it on its own. If it doesn't, then click on Customize > Preferences..., then select the MAXScript tab and find and modify the Memory field as necessary.
Now you should see your model in grey the viewport, congratz! But there's still a lot of work to do before it is ready to be exported into HoN.
2b. Warcraft III: To import from Warcraft III, follow the same instructions as WoW/SC2 above, however instead of using the M3 Importer you will use the mdx importer from the same package. The script should be called impexpmdx_v2.0.4.ms
If you end up with a bunch of big flat squares on your model, you can select and delete them if you don't think they are needed (left click and press del). Usually these are for static player-colored glows and things that are usually just handled using effects scripts in HoN. But if you do want a glow to be player-colored in HoN, it will need to be a textured part of the model, as effects currently can't change with player color.
Step 3. Fixing stuff
At this point you should have your model imported into 3DS Max 8. You may think that you're almost done, but unfortunately you're really only getting started. There are a lot of things that need to be fixed and added to the model before it is ready to be exported to HoN. The first thing we'll look at is getting the textures back onto the model.
3a. Scale: The first thing we need to do is change the scale of the model to fit properly in HoN's engine. You can tweak the hero's scale after you export it and have it in game, but this will also scale up any effects that play on your hero. So if you were to scale it up 100 times bigger this way, then the effects that play on your hero would be 100 times bigger than on other heroes as well. So, you'll want to get it as close as you can before you export it. Fortunately this is pretty easy to do. Simply press ctrl+A to select all the parts of your model, then right click on the scale button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_Scale.jpg
You'll need to type in the x y and z scales individually. Generally you want to set the scale to somewhere between 5000-10000. An average sized hero shouldn't be bigger than about half the size of the grid (press G if the grid isn't visible). After you enter the values, close the scaling window and your model should be a lot bigger. Zoom out with the scroll wheel and make sure this didn't screw anything up. Some models that are split up into multiple parts will have their animations break when they are scaled up, and it may not be possible to fix them.
3b. Textures: First, open up the Material Editor:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat.jpg
This will bring up a window with a bunch of grey circles on top and Parameter fields below. The Grey circles are the materials which you will create to be applied to the model. Materials are composed of one or more textures (images), along with some paramaters which together describe how the model, or a part of the model, should be colored. There may already be some materials defined here using the Starcraft 2 Material type. You will not be able to use these materials in HoN, so you will have to replace them with new ones.
To create a new material, fist click on one of the empty material slots. The material type should be just to the right of the materials name. If it isn't Standard, click on it and then choose Standard from the list that appears.
Next, choose a diffuse texture. The diffuse texture is the main texture used to define the color of the object. To choose a diffuse texture, first click on this button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat_diff.jpg
Now click on bitmap at the top of the list that appears and then navigate to where you saved your textures in step 1 and pick whichever texture you think is a skin for your model. Your model should already be split into a few pieces and be ready to have the textures wrapped around it, so select the piece or pieces you think the material you made applies to and then click on the 'Assign material' button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat_apply.jpg
The model's color might change a little bit, but you won't be able to see the actual texture on the model unless you click this button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat_show.jpg
Now just repeat this process of creating and applying materials until you have the whole model textured. Note that what you see in the viewport isn't at the full quality of what you will get in-game. To see how the model looks in a higher quality you can press f9 or click the teapot icon to get a quick render of the model, although it still won't be exactly what it will look like in HoN:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_quickrender.jpg
One thing you may notice on some models is that some flat objects like capes will only be visible from one side, but invisible from the other side. To fix this, right click the object and click properties. Then find the box that says 'Backface Cull' and uncheck it and click OK. Now the object should be visible from both sides.
Alright, I think that about covers it for textures. Remember if you have any questions feel free to post them here or PM me and I'll try to get back to you. Now, moving on...
3c. Animations:
To view the imported Animations in 3DS Max, simply go to the Utilities panel on the right side of the screen which you used to import the model, and In the maxScript box click on the Utilities list and select M3 Sequences. This should open up the M3 - Sequences box which has a drop-down box labeled "Select Animation". Select the animation you want to look at, then use the animation controls at the bottom right of the screen to play the animation.
Looping Animations:Animations are usually working pretty well already, but if you're importing from WoW you might have a small issue which is easy to fix. If you are using a WoW model and you select a looping animation, you may notice that the animation doesn't loop correctly. To fix this, simply press ctrl+a to select everything in the scene. This will show you all the keyframes in the animation in the timeline at the bottom of the screen. Hold shift, then click and drag the first keyframe in the animation all the way to the right and drop it onto the last frame in the animation. This will copy the keyframe so that the first and last frame of the animation will be the same, allowing for a smooth transition from start to end. Now play the animation again and if you did it right it should loop correctly.
Warcraft III:Unfortunately the importer for Warcraft III doesn't give any options for FPS, so you will need to change it manually. Even more unfortunately, the M3 Sequences tool doesn't automatically adjust for this, so you will need to go through each animation and change the start and end times. According to 3DS Max the animations import at 960 FPS, and we want them to be 30, so that means the start/end times for all the animations need to be divided by 32 (960/30 = 32). When you divide the times you will usually get a decimal result, so you will have to round it. When you are changingthe start times you will need to round up, and when changing the end times you will need to round down. This is because just before and after the animation, there will be a key frame that sets the model back to it's reference pose. If you round incorrectly then this frame will become part of your animation, which will make your character flip out really fast whenever your animation loops.
Hooray, animations complete! Now it's time for the fun part, bones...
3d. Bones: The goal of this section is to get the bones of your new model to roughly match the bones of the original one so that effects will properly show on your hero. You don't need to copy every single bone over, however there are some bones which are shared amongst all heroes and are used as attachment points for skill and item effects. I'll try to list these bones out here, but you might want to look at the bones on the model of the hero you are replacing for reference. To do this, open up HoN and start up a practice game. Then spawn the hero you want to look at and then press ctrl+F8 to open up the console. Type in these commands: vid_drawbonenames true and vid_drawbones true. You also might want to use the commands ServerPause and ServerUnpause to make it easier to see the bone names. Now just zoom in and try to see the bones and their locations on the model.
List of shared effects bones:
_bone_overhead
_bone_centerofchest
_bone_center
_bone_head
_bone_back
_bone_chest
_bone_lefthand
_bone_righthand
_bone_leftfoot
_bone_rightfoot
Bip01 Head
Bip01 Pelvis
Bip01 Spine
Bip01 Spine1
Bip01 Spine2
Bip01 Neck
Bip01 Head
Bip01 L Clavicle
Bip01 R Clavicle
Bip01 L UpperArm
Bip01 R UpperArm
Bip01 L Forearm
Bip01 R Forearm
Bip01 L Hand
Bip01 R Hand
Bip01 L Thigh
Bip01 R Thigh
Bip01 L Calf
Bip01 R Calf
Bip01 L Foot
Bip01 R Foot
Yeah, that's a lot of bones. If you don't want to take the time to do all of them, I recommend just doing the ones that begin with _bone, as they are used quite often. Now, unfortunately you can't just rename the existing bones on the model, as there are problems with the effects scaling up way bigger than they should. This is due to the effects inheriting the size of the bone they are attached to, and in the process of importing and exporting from one game engine to another, the scaling of bones can get out of whack, and I don't know the proper way to fix it without screwing up the animations. If you just try to resize the bones, then it will shrink the part of the model that uses that bone for animating the model.
So instead, we will have to add attachment points to the model which have no impact on the models animation, and therefore can be resized without screwing anything up. There should be some of these attachment points already, which will show up as green cubes in the viewport. You can use these ones if you want to. First just rename them to one of the bones listed above, then you'll need to change their box size and scale to 1. To change the box size, click on the Modify tab:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_ModifyTab.jpg
Then change the field titled Box Size to 1
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_BoxSize.jpg
To rename them just change the name in the box at the top of any tab.
To change the scale, right click this Icon:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_Scale.jpg
Set the scale to 1 for now. You may need to come back and change this later if effects appear too small or large in-game.
Continue this with all the attachment points on the list which you plan on including with your model. If there isn't already a green box somewhere where you need a it, then you should just copy an existing one and then put it where you need it. You can do this by using the move or translate tool, and holding shift when you drag an existing attachment point, which will create a copy at the new location and leave the original one unchanged. Then rename the new copy and move it to wherever you want it to be.
Once you think you have it where you want it on the model, you will need to link it to the nearest model bone so that it follows the units animations correctly. To do this, first find the nearest model bone to the attachment point you are adding and remember it's name. Now select your attachment point again and click on the Select and Link button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_Link.jpg
Now press the H key on your keyboard to bring up a list of all objects in the scene. Find the bone you want to link to (you can filter out bones using the check-boxes on the right), select it on the list and then click link in the bottom right.
Now if you right click on your attachment point and click properties, it should show the linked bone in the "Parent" field.
Alright... hardest part is over. Now let's see if we can get this thing into the game.
Step 4: Exporting the Model
Alright, time to export the model into a format that the game can use. The model and each of the animations will be contained in separate files, and each animation will need to be exported one at a time...
~WIP~
4b. Help! My program crashed when I clicked export: This is pretty common, and happens with probably over half of the models I've tried. But fortunately I found a solution which has worked every time for me so far. I don't know why it works, but it does. Be sure to save before you start doing this (you should always be saving pretty often anyways), so that you can start over if things get really messed up.
So I noticed that the crashes during export always occurred when it was "copying skin weights", so I looked around Max for things that looked like they were related to that. I found this thing called the Weight Tool Dialog that lets you do some fancy skin weight stuff that I don't fully understand, but what I do know is that it will magically fix whatever stops the model from exporting. We will need to fix each of the different 'parts' of the model one at a time, which can be seen by pressing H and selecting the Geometry filter on the right. So, to open up the Weight Tool Dialog first select the Modify Tab
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_ModifyTab.jpg
With the Modify Tab open, select a part of the model (by either clicking on it in the viewport, or pressing H and double clicking it), then right click somewhere in the viewport and click on Weight Tool Dialog.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_weighttool.jpg
Now back on the Modify Tab, click on the big Edit Envelopes button, then press ctrl+A to select all the vertices in the part of the model you have selected. Make sure there are at least 2 bones in the list on the modify tab:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_bonelist.jpg
If there is only one bone, then click Add and pick any other bone at random to add to the list.
Now, select a bone and go back to the weight tool window. Click on the 1 button, then on the 0 button. If it doesn't look right, click on the 1 button again. Once you're done with this, everything should look exactly like it did before you started, but after you do this to each section of the model, it should export correctly.
Step 5: Fixing more stuff
Alright, now you've got your model in the game (hopefully) and you start up a practice match to have a look at it, but when the game starts you notice something doesn't look right. Maybe your model is all white, has a checkerboard skin, looks like a jumbled up ball, isn't visible at all or, or it is simply too dark or lacks detail. Obviously nobody would want to play with something that looks like that, so now we'll try to address some of these problems.
5a. Animations: Parameters regarding animations are located in a hero's mdf file. This file should be copied straight from the hero you are replacing and then modified to use your custom model and animations. If you rearrange or remove any animations in this file, then the game will get confused and your animations will no longer work correctly in online games.
In the mdf file you can change the speed (fps) of your animations, you can make animations loop, and you can tell the game to play special sounds or effects at certain frames of the animation.
-WIP-
5b. Materials: The material file is what holds information about how the game should draw the model. It defines the textures, shaders, and parameters used and can be used and modified to add a lot of detail to your model. You can learn a lot about modifying textures and materials here (http://forums.heroesofnewerth.com/showthread.php?t=59189).
The exporter will give you basic material files for each material but they usually wont look too great and might not even work at all. I recommend starting with a material file from a fairly new hero that has been released, as these usually use the newest shaders and parameters available. However, be sure names of the material files match what they were in the material editor in 3DS Max as that's the only way the model knows which material to use on which parts of the model.
So take an existing material file and open it up with a text editor. Find the lines that say <sampler name="diffuse"> and change the texture on those lines to be the one that your model uses for color. You will probably also want to add a normal map and possibly a team color map which can be generated using GIMP or Photoshop. You can find the normal map plugin for GIMP here: http://code.google.com/p/gimp-normalmap/. The tool will make your normal map for you automagically and usually it gives pretty good results. Using a normal map will make your model look much better. For those who don't know, a normal map (also known as a bump map), is used by the pixel shader to determine the lighting on the model at a specific point by pretending as if the surface of the model is facing a different direction than it actually is. This allows you to add bumps, cracks, and other small details to a model without needing to actually alter the geometry.
A team color map is used to tell the game what parts of the model will be colored with the color of a players slot (blue, pink, orange, brown, etc.). I usually make these by using various tools in GIMP/Paint.NET until I get what I want. A team map should be transparent in all parts that you don't want the players color to appear, and white in places that you do want it. The diffuse/color texture should also be white or gray at these parts so that it is easy to see the tint of the player color.
Well, that's pretty much it. At this point you might want to make some custom effects or work more on the textures. If you need help with anything else or if there's something I missed just let me know so I can add it to the guide. If you need some real-time help you can usually find me on irc at irc.s2games.com channel #honlabs, my nick is either BlacRyu or Vorg.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/Blizzard_logo.jpg
Model Importing
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/ysera_blend4.png
Table of Contents
Overview
Getting Ready...
Step 0: Choosing a Model
Step 1: Getting the Files
Step 2: Importing the Model
Step 3: Fixing stuff (textures, bones, animations)
Step 4: Exporting the Model
Step 5: Fixing more stuff (materials, animations)
Overview:
In this guide I will be explaining how to import models and textures from blizzard MPQ archives into HoN's K2 format. This (currently) includes the games Warcraft III, Starcraft 2, and World of Warcraft. 3D Models don't like being thrown around between different formats, so you will most likely run into some weird glitches which require even weirder workarounds to fix, and as such I don't expect this guide will be able to cover everything. So if you have any questions or you discover something useful that isn't in the guide please leave your questions or comments here.
Getting Ready...
Things you will need:
3DS Max 8 (not 2008)
M3 Plugins for 3DS Max (http://www.sc2mapster.com/assets/m3-export-plugin-3ds-max/files/24-m3-plugins-v1-7b/) (v1.8 doesn't seem to work with 3DS Max 8, so use 1.7b instead)
MPQ Archive Browser/Editor (http://www.zezula.net/en/mpq/download.html)
S2's 3DS Max 8 K2 Model Exporter (http://forums.heroesofnewerth.com/showthread.php?t=23225)
BLP Laboratory (http://www.hiveworkshop.com/forums/tools-560/blp-lab-v0-5-0-a-137599/) (not needed for WoW)
WoW Model Viewer (http://www.wowmodelviewer.org/) (use this one for WoW)
Things you will probably want:
An image editor. I personally use Paint.NET (http://www.getpaint.net/) and GIMP (http://www.gimp.org/about/introduction.html). Both are free to download and use.
Normal map plug-in for GIMP (http://code.google.com/p/gimp-normalmap/) is an easy way to generate normal map textures to add an extra layer of detail to a model.
Notepad++ (http://notepad-plus-plus.org/) is useful for editing the script/text files that HoN uses to define the properties of it's models and textures. It will give you XML syntax highlighting (if you set it up), as well as auto-tabbing and other useful coding stuff.
Step 0. Choosing a model
Before you can import a model, you have to know what it is you're going to import! If you don't already have one in mind, here are some good ways to get some ideas and see your model in action before you import it over to HoN.
0a. World of Warcraft: The best way to find a model from WoW is using the WoW model viewer (link in the above section). You can search for models by name, see them instantly, look through all their animations, and attach weapons and other items to them. It can also export the models into the M3 format which is needed to import them into 3DS Max 8, as the M2 importer doesn't seem work.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_wmv_ysera1.jpg
0b. Starcraft II: The best way I've found to look through the models in SC2 is by using the built-in previewer inside the Starcraft 2 Map Editor. To open the Previewer, click on Window > Previewer or press ctrl+shift+V
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/sc2Previewer.jpg
In order to see all the models you will need to create a blank map and add dependencies. To do this, click file->New..., then where it says Dependencies, click the Modify button, then click Add Standard and choose the dependencies you want (or just use all of them). When you click OK it will take a while to load all the assets. Then open up the previewer as stated above (ctrl+shift+V) and look through the models there. Alternatively you can browse/search for units in the terrain editor and then right click their name and click View in Previewer. Don't use anything that starts with SM or StoryMode, as it is meant to be used in cinematics and won't have the animations you would want to use.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/sc2Editor.jpg
0c. Warcraft III: The only reason I can think of for looking for models from WC3 is to import models from DotA for nostalgia's sake, so you probably already know what it is you want.
Here's a list of DotA Heroes in HoN: http://honwiki.net/wiki/DotA_vs_HoN#Ported_Heroes
Step 1. Getting the Files
1a. World of Warcraft: Alright, back to the WoW Model Viewer (link above). Once you have found the model you want, click on File > Export Model > Export Options....
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_wmv_exptopt.jpg
On the window the opens up, click on the M3 tab. Set the Bound Scale and Sphere scale to 1.0, leave texture path blank, and then select the animations you want to import. I recommend importing most animations, as you won't be able to come back and import more later. However, importing all the animations is usually a bad idea, as there are usually some animations that are broken to begin with (such as some of the emotes), and will cause problems with the model when you try to import. You can continue to mess around with the model in the viewport while this options window is open, so you can see which animations you want or if any are broken (you will definitely be able to tell if an animation is broken). Keep in mind that the animations are sorted by number in this window, while in the default viewing window they are sorted alphabetically.
Once you have all of your animations set, you can click Apply and close that window, then click File > Export Model > M3... and choose where you want to save the model file.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_wmv_m3exp.jpg
Then click File > Export Textures... and click on Export all to TGA. This will place all relevant texture files into the WoW Model Viewer/Export Directory. Now you should have everything you need and can start importing stuff into 3DS Max![/b]
1b. Starcraft II: To get the files from Starcraft 2 you will need the mpq editor linked in the Getting Ready section. First, make sure you don't have SC2 open as it won't let you access the files if it is. Now, open up the MPQ editor and click File -> Open MPQ, then navigate to your Starcraft 2 directory. There will be two directories here where your model could be located; Campaigns\Liberty.SC2Campaign or Mods\Liberty.SC2Mod. The folder it is in depends on whether your model was only used in single player or if it's a standard multiplayer unit. If you aren't sure where it is, just check one folder and if you don't see it there then try the other one. In each folder you should see a Base.SC2Assets and another one that corresponds to your language. First, open up the base.SC2Assets file (it should be the largest file). After you open the MPQ, first find the model you want by expanding the Assets folder, then the Units folder. You should be able to find the folder you want from there. Once you've navigated to your units folder, you should see a file with a m3 extension. Right click on it and click extract, then choose a location where you want to extract the file.
Now that you have the model, you will want to find the texture that goes with it. You can find all the textures in the Assets -> Textures folder inside base.SC2Assets. Open it up and search for the textures you think go with your model. You can filter through the files by using the File Mask box in the toolbar at the top. You need to use * as a wildcard, so for example, type in *zergling* to get all the textures for a zergling. Be sure you delete the mask after you find what you want or all the other folders will appear to be empty. Once you have the textures extracted, you will need to open them up with a compatible image editor (Paint.NET should work), and then re-save them as tga files.
And finally, sounds. If you want sounds for your unit there are two locations where they could be located. Firstly, for sounds other than speech, simply look in the Assets\Sounds folder in the same MPQ that you found your model. For sounds which are related to a specific language, you will need to open up the MPQ archive for that language (i.e. enUS.SC2Assets) and then look in LocalizedData\sounds. Once you find the sounds you want, just extract them like you did with the model/texture.
1c. Warcraft III: To get the files from Warcraft III you will need the mpq editor linked in the Getting Ready section. First, make sure you don't have WC3 open as it won't let you access the files if it is. Now, open up the MPQ editor and click File -> Open MPQ, then navigate to your Warcraft III directory. Your model will be inside either War3.mpq or War3x.mpq, depending on whether it is an expansion character or an original one. If you don't know which one it is from just try them each one at a time. Once you open the MPQ, you can either manually browse through the files for the unit you want, or click Tools -> Search Files... and search for the unit you want. Once you get to the folder for your unit, there should be two files with a mdx extension. If there isn't then your unit is probably just a re-skin of another model, and you'll have to figure out which one that is. Once you have your model, right click the mdx file that doesn't say portrait and click Extract, then choose a location where you want to extract the file. If you want to, you can extract the sounds now as well if there are any in the folder. Some sounds may be located in War3xLocal.mpq.
Now that you have the model, you will want to find the texture that goes with it. You can find all the textures in the Textures folder inside the MPQ. Open it up and search for the textures you think go with your model. You can filter through the files by using the File Mask box in the toolbar at the top. You need to use * as a wildcard, so for example, type in *arthas* to bring up the texture for Arthas. Be sure you delete the mask after you find what you want or all the other folders will appear to be empty. Once you have the textures you want, extract them like you did with the model. The textures should have a blp extension, but we want tga, so you will need to open up BLP Laboratory (linked in the Getting Started section) and then open and save the textures as TGA files.
Step 2. Importing the Model
2a. WoW & Starcraft II: At this point you should have at least one *.m3 file and one or more textures (*.tga). You will also need to have 3ds max 8 installed and the import scripts (http://www.sc2mapster.com/assets/m3-export-plugin-3ds-max/) downloaded.
Open up 3DS Max and Click on the Utilities tab.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_util.jpg
Now click on the button labeled MAXScript, then on the button labeled Run Script.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_script.jpg
Find and open the script you downloaded named m3_import_v0.30.ms. Then you should be able to select "M3 - Import" from the Utilities list just below. Click on it and the Import options should show up below. Click on the button labeled 'Open', then navigate to the m3 file for the model you want to import. Leave all the settings checked, and change the FPS from 1000 to 30. 30 FPS is the default used by HoN, but you will be able to tweak the animation speeds a little bit later if you need to. Now, click on the Import button. You should get a message saying that it couldn't find the textures in the maps directory. Just tell it to import anyways and it should work fine. If you get an error message that there isn't enough scripting memory, try importing again, sometimes it will fix it on its own. If it doesn't, then click on Customize > Preferences..., then select the MAXScript tab and find and modify the Memory field as necessary.
Now you should see your model in grey the viewport, congratz! But there's still a lot of work to do before it is ready to be exported into HoN.
2b. Warcraft III: To import from Warcraft III, follow the same instructions as WoW/SC2 above, however instead of using the M3 Importer you will use the mdx importer from the same package. The script should be called impexpmdx_v2.0.4.ms
If you end up with a bunch of big flat squares on your model, you can select and delete them if you don't think they are needed (left click and press del). Usually these are for static player-colored glows and things that are usually just handled using effects scripts in HoN. But if you do want a glow to be player-colored in HoN, it will need to be a textured part of the model, as effects currently can't change with player color.
Step 3. Fixing stuff
At this point you should have your model imported into 3DS Max 8. You may think that you're almost done, but unfortunately you're really only getting started. There are a lot of things that need to be fixed and added to the model before it is ready to be exported to HoN. The first thing we'll look at is getting the textures back onto the model.
3a. Scale: The first thing we need to do is change the scale of the model to fit properly in HoN's engine. You can tweak the hero's scale after you export it and have it in game, but this will also scale up any effects that play on your hero. So if you were to scale it up 100 times bigger this way, then the effects that play on your hero would be 100 times bigger than on other heroes as well. So, you'll want to get it as close as you can before you export it. Fortunately this is pretty easy to do. Simply press ctrl+A to select all the parts of your model, then right click on the scale button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_Scale.jpg
You'll need to type in the x y and z scales individually. Generally you want to set the scale to somewhere between 5000-10000. An average sized hero shouldn't be bigger than about half the size of the grid (press G if the grid isn't visible). After you enter the values, close the scaling window and your model should be a lot bigger. Zoom out with the scroll wheel and make sure this didn't screw anything up. Some models that are split up into multiple parts will have their animations break when they are scaled up, and it may not be possible to fix them.
3b. Textures: First, open up the Material Editor:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat.jpg
This will bring up a window with a bunch of grey circles on top and Parameter fields below. The Grey circles are the materials which you will create to be applied to the model. Materials are composed of one or more textures (images), along with some paramaters which together describe how the model, or a part of the model, should be colored. There may already be some materials defined here using the Starcraft 2 Material type. You will not be able to use these materials in HoN, so you will have to replace them with new ones.
To create a new material, fist click on one of the empty material slots. The material type should be just to the right of the materials name. If it isn't Standard, click on it and then choose Standard from the list that appears.
Next, choose a diffuse texture. The diffuse texture is the main texture used to define the color of the object. To choose a diffuse texture, first click on this button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat_diff.jpg
Now click on bitmap at the top of the list that appears and then navigate to where you saved your textures in step 1 and pick whichever texture you think is a skin for your model. Your model should already be split into a few pieces and be ready to have the textures wrapped around it, so select the piece or pieces you think the material you made applies to and then click on the 'Assign material' button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat_apply.jpg
The model's color might change a little bit, but you won't be able to see the actual texture on the model unless you click this button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_mat_show.jpg
Now just repeat this process of creating and applying materials until you have the whole model textured. Note that what you see in the viewport isn't at the full quality of what you will get in-game. To see how the model looks in a higher quality you can press f9 or click the teapot icon to get a quick render of the model, although it still won't be exactly what it will look like in HoN:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_quickrender.jpg
One thing you may notice on some models is that some flat objects like capes will only be visible from one side, but invisible from the other side. To fix this, right click the object and click properties. Then find the box that says 'Backface Cull' and uncheck it and click OK. Now the object should be visible from both sides.
Alright, I think that about covers it for textures. Remember if you have any questions feel free to post them here or PM me and I'll try to get back to you. Now, moving on...
3c. Animations:
To view the imported Animations in 3DS Max, simply go to the Utilities panel on the right side of the screen which you used to import the model, and In the maxScript box click on the Utilities list and select M3 Sequences. This should open up the M3 - Sequences box which has a drop-down box labeled "Select Animation". Select the animation you want to look at, then use the animation controls at the bottom right of the screen to play the animation.
Looping Animations:Animations are usually working pretty well already, but if you're importing from WoW you might have a small issue which is easy to fix. If you are using a WoW model and you select a looping animation, you may notice that the animation doesn't loop correctly. To fix this, simply press ctrl+a to select everything in the scene. This will show you all the keyframes in the animation in the timeline at the bottom of the screen. Hold shift, then click and drag the first keyframe in the animation all the way to the right and drop it onto the last frame in the animation. This will copy the keyframe so that the first and last frame of the animation will be the same, allowing for a smooth transition from start to end. Now play the animation again and if you did it right it should loop correctly.
Warcraft III:Unfortunately the importer for Warcraft III doesn't give any options for FPS, so you will need to change it manually. Even more unfortunately, the M3 Sequences tool doesn't automatically adjust for this, so you will need to go through each animation and change the start and end times. According to 3DS Max the animations import at 960 FPS, and we want them to be 30, so that means the start/end times for all the animations need to be divided by 32 (960/30 = 32). When you divide the times you will usually get a decimal result, so you will have to round it. When you are changingthe start times you will need to round up, and when changing the end times you will need to round down. This is because just before and after the animation, there will be a key frame that sets the model back to it's reference pose. If you round incorrectly then this frame will become part of your animation, which will make your character flip out really fast whenever your animation loops.
Hooray, animations complete! Now it's time for the fun part, bones...
3d. Bones: The goal of this section is to get the bones of your new model to roughly match the bones of the original one so that effects will properly show on your hero. You don't need to copy every single bone over, however there are some bones which are shared amongst all heroes and are used as attachment points for skill and item effects. I'll try to list these bones out here, but you might want to look at the bones on the model of the hero you are replacing for reference. To do this, open up HoN and start up a practice game. Then spawn the hero you want to look at and then press ctrl+F8 to open up the console. Type in these commands: vid_drawbonenames true and vid_drawbones true. You also might want to use the commands ServerPause and ServerUnpause to make it easier to see the bone names. Now just zoom in and try to see the bones and their locations on the model.
List of shared effects bones:
_bone_overhead
_bone_centerofchest
_bone_center
_bone_head
_bone_back
_bone_chest
_bone_lefthand
_bone_righthand
_bone_leftfoot
_bone_rightfoot
Bip01 Head
Bip01 Pelvis
Bip01 Spine
Bip01 Spine1
Bip01 Spine2
Bip01 Neck
Bip01 Head
Bip01 L Clavicle
Bip01 R Clavicle
Bip01 L UpperArm
Bip01 R UpperArm
Bip01 L Forearm
Bip01 R Forearm
Bip01 L Hand
Bip01 R Hand
Bip01 L Thigh
Bip01 R Thigh
Bip01 L Calf
Bip01 R Calf
Bip01 L Foot
Bip01 R Foot
Yeah, that's a lot of bones. If you don't want to take the time to do all of them, I recommend just doing the ones that begin with _bone, as they are used quite often. Now, unfortunately you can't just rename the existing bones on the model, as there are problems with the effects scaling up way bigger than they should. This is due to the effects inheriting the size of the bone they are attached to, and in the process of importing and exporting from one game engine to another, the scaling of bones can get out of whack, and I don't know the proper way to fix it without screwing up the animations. If you just try to resize the bones, then it will shrink the part of the model that uses that bone for animating the model.
So instead, we will have to add attachment points to the model which have no impact on the models animation, and therefore can be resized without screwing anything up. There should be some of these attachment points already, which will show up as green cubes in the viewport. You can use these ones if you want to. First just rename them to one of the bones listed above, then you'll need to change their box size and scale to 1. To change the box size, click on the Modify tab:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_ModifyTab.jpg
Then change the field titled Box Size to 1
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_BoxSize.jpg
To rename them just change the name in the box at the top of any tab.
To change the scale, right click this Icon:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_Scale.jpg
Set the scale to 1 for now. You may need to come back and change this later if effects appear too small or large in-game.
Continue this with all the attachment points on the list which you plan on including with your model. If there isn't already a green box somewhere where you need a it, then you should just copy an existing one and then put it where you need it. You can do this by using the move or translate tool, and holding shift when you drag an existing attachment point, which will create a copy at the new location and leave the original one unchanged. Then rename the new copy and move it to wherever you want it to be.
Once you think you have it where you want it on the model, you will need to link it to the nearest model bone so that it follows the units animations correctly. To do this, first find the nearest model bone to the attachment point you are adding and remember it's name. Now select your attachment point again and click on the Select and Link button:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_Link.jpg
Now press the H key on your keyboard to bring up a list of all objects in the scene. Find the bone you want to link to (you can filter out bones using the check-boxes on the right), select it on the list and then click link in the bottom right.
Now if you right click on your attachment point and click properties, it should show the linked bone in the "Parent" field.
Alright... hardest part is over. Now let's see if we can get this thing into the game.
Step 4: Exporting the Model
Alright, time to export the model into a format that the game can use. The model and each of the animations will be contained in separate files, and each animation will need to be exported one at a time...
~WIP~
4b. Help! My program crashed when I clicked export: This is pretty common, and happens with probably over half of the models I've tried. But fortunately I found a solution which has worked every time for me so far. I don't know why it works, but it does. Be sure to save before you start doing this (you should always be saving pretty often anyways), so that you can start over if things get really messed up.
So I noticed that the crashes during export always occurred when it was "copying skin weights", so I looked around Max for things that looked like they were related to that. I found this thing called the Weight Tool Dialog that lets you do some fancy skin weight stuff that I don't fully understand, but what I do know is that it will magically fix whatever stops the model from exporting. We will need to fix each of the different 'parts' of the model one at a time, which can be seen by pressing H and selecting the Geometry filter on the right. So, to open up the Weight Tool Dialog first select the Modify Tab
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_ModifyTab.jpg
With the Modify Tab open, select a part of the model (by either clicking on it in the viewport, or pressing H and double clicking it), then right click somewhere in the viewport and click on Weight Tool Dialog.
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_weighttool.jpg
Now back on the Modify Tab, click on the big Edit Envelopes button, then press ctrl+A to select all the vertices in the part of the model you have selected. Make sure there are at least 2 bones in the list on the modify tab:
http://dl.dropbox.com/u/5534703/model%20import%20tutorial/hontut_max_bonelist.jpg
If there is only one bone, then click Add and pick any other bone at random to add to the list.
Now, select a bone and go back to the weight tool window. Click on the 1 button, then on the 0 button. If it doesn't look right, click on the 1 button again. Once you're done with this, everything should look exactly like it did before you started, but after you do this to each section of the model, it should export correctly.
Step 5: Fixing more stuff
Alright, now you've got your model in the game (hopefully) and you start up a practice match to have a look at it, but when the game starts you notice something doesn't look right. Maybe your model is all white, has a checkerboard skin, looks like a jumbled up ball, isn't visible at all or, or it is simply too dark or lacks detail. Obviously nobody would want to play with something that looks like that, so now we'll try to address some of these problems.
5a. Animations: Parameters regarding animations are located in a hero's mdf file. This file should be copied straight from the hero you are replacing and then modified to use your custom model and animations. If you rearrange or remove any animations in this file, then the game will get confused and your animations will no longer work correctly in online games.
In the mdf file you can change the speed (fps) of your animations, you can make animations loop, and you can tell the game to play special sounds or effects at certain frames of the animation.
-WIP-
5b. Materials: The material file is what holds information about how the game should draw the model. It defines the textures, shaders, and parameters used and can be used and modified to add a lot of detail to your model. You can learn a lot about modifying textures and materials here (http://forums.heroesofnewerth.com/showthread.php?t=59189).
The exporter will give you basic material files for each material but they usually wont look too great and might not even work at all. I recommend starting with a material file from a fairly new hero that has been released, as these usually use the newest shaders and parameters available. However, be sure names of the material files match what they were in the material editor in 3DS Max as that's the only way the model knows which material to use on which parts of the model.
So take an existing material file and open it up with a text editor. Find the lines that say <sampler name="diffuse"> and change the texture on those lines to be the one that your model uses for color. You will probably also want to add a normal map and possibly a team color map which can be generated using GIMP or Photoshop. You can find the normal map plugin for GIMP here: http://code.google.com/p/gimp-normalmap/. The tool will make your normal map for you automagically and usually it gives pretty good results. Using a normal map will make your model look much better. For those who don't know, a normal map (also known as a bump map), is used by the pixel shader to determine the lighting on the model at a specific point by pretending as if the surface of the model is facing a different direction than it actually is. This allows you to add bumps, cracks, and other small details to a model without needing to actually alter the geometry.
A team color map is used to tell the game what parts of the model will be colored with the color of a players slot (blue, pink, orange, brown, etc.). I usually make these by using various tools in GIMP/Paint.NET until I get what I want. A team map should be transparent in all parts that you don't want the players color to appear, and white in places that you do want it. The diffuse/color texture should also be white or gray at these parts so that it is easy to see the tint of the player color.
Well, that's pretty much it. At this point you might want to make some custom effects or work more on the textures. If you need help with anything else or if there's something I missed just let me know so I can add it to the guide. If you need some real-time help you can usually find me on irc at irc.s2games.com channel #honlabs, my nick is either BlacRyu or Vorg.