Exporting meshes and skeletons from Maya to Torchlight

This article is an Island. It cannot be linked to using wiki BB-codes.
Torchlight's 3D content was made with 3DS Max, so wedging Maya into the pipeline was quite a challenge, but I have managed to get it to work, for the most part. (The one thing that still stymies me is utilizing existing player character meshes, such as for adding new armor. Mostly this appears to be due to problems with getting the skeleton into Maya and back out again without the joint location/orientation data getting distorted along the way. Unless/until that issue is figured out, Blender and Max will likely remain better choices for those who want to add new armor to the game -- or, if you really insist on using Maya to model your stuff, you will have to export the armor to Blender and bind it to the character skeletons in there, which I have done.)
But, for those who are interested in using Maya to make new weapons, new props/environment/tileset art, new characters, and new pets/monsters, and get them into Torchlight, I hope this guide will be of help.

Since there are other tutorials covering what to do with art assets (e.g. in TorchED) once they are already exported, this tutorial will only cover how to get them out of Maya and ready for use in either TorchED or Torchlight.

[top]Materials Needed, Exporter Installation

Obviously, you need Maya. The other thing you need is the Ogre exporter for Maya. Determine which version of the program you have, and download the appropriate exporter from: http://www.ogre3d.org/download/tools. I'm using Maya 2008, but they have exporters going all the way back to 6.5. If you have a version newer than 2008, there appears to be instructions pertaining to compiling your own version of the Ogre exporter here: http://www.ogre3d.org/tikiwiki/Maya+Exporter.

To install the exporter plugin, go to your \Program Files\Autodesk\[Maya folder]\bin\plug-ins folder. (This is the folder setup for Windows XP; if you are using a machine with a newer Windows operating system, or if you just installed Maya in a different location, you may have to look elsewhere.) Place the ogreExporter.mll file into the plug-ins folder.

Once the plug-in is installed, it should load automatically when you next start up Maya, and an Ogre menu should show up toward the end of your menu bar (next to the Help menu).
(At least I think it should load automatically; I installed it a while ago so I can't quite remember. If the menu does not show up after installing the plugin, go to Window -> Settings/Preferences -> Plug-In Manager. Look in the list for ogreExporter.mll, and check the Loaded and Auto Load checkboxes next to it. If ogreExporter.mll does not show up in the list, you've probably installed the plugin incorrectly.)

There is only one item inside the Ogre menu: an Export command. How straightforward.

[top]Some notes on orientation

-Weapons must face with their "attacking side" away from the orthogonal front camera. So, if you have a sword, the cutting edge of the blade must be on the other side when looking at the sword in the front camera (the blade should be facing in the the "negative Z" direction).

-The top of the hilt of the weapon should be just above the origin. Basically, 0, 0, 0 is where the top of the character's hand will be when wielding the weapon, so stick the weapon close to the origin with that in mind. Also keep in mind the location of any crossguards or other hand-protecty-things on your weapon, so they do not clip through the character's hand.

-Shields are a tad counterintuitive: You will need to see the back of them from the side camera, and their left side from the front camera. (They should be facing in the "negative X" direction.) They again need to be placed at the origin, only this time the origin describes the middle of a character's forearm instead of their hand/fist.

Here is an example of a sword and a shield located correctly and ready for export, plus a clarification of the axis orientations in relation to the cameras:

Using Maya's default unit measurements, weapon sizes (while they can vary a fair amount) usually have a one-handed weapon being roughly one to two units long. Two handed weapons are almost always at least two units long, but can go up to three or four (once you start getting too long though, your weapon is likely to start clipping through either the characters or through the ground).

It is worth mentioning that crossbows and rifles have an odd orientation that must be dealt with. If you modeled a weapon like this out "prone" and pointing forward horizontally, you need to rotate it back about 75 degrees, like thus.

-Characters/monsters/pets make the most sense in that they must face in alignment with the top/front/side cameras to be oriented correctly within the game world. So, if looking through the front camera, you should be able to see the character/creature's face; and from the side camera, the creature must be facing to your left.

Creature sizes can vary even more than weapons, but, for the sake of character-based height reference, it may be helpful to know the heights of the 3 default classes.

If you wish, you can try editing Maya's graph settings to something that will better match the scale of Torchlight's existing meshes. Personally I have not, so I have no particular suggestions for settings to use for this, but if you find yourself doing a lot of TL modding, it could be helpful to figure something out yourself. (To change the grid settings, open the Display menu, and click the box to the right of the Grid option.)

The following file contains blank (textureless) meshes of the Destroyer, Vanquisher, and Alchemist for scaling purposes:
Download .ma file

[top]Export settings for a weapon or prop

The Ogre exporter window looks like this when first called up:

A basic asset, such as a weapon, shield, or environment prop is probably the easiest example of what you can export. After having modeled, UV-ed, and textured your object, select the mesh and open the Export window.

First thing is to set the Output Directory, under Common Parameters at the top. This is just what folder you want the exported files to be deposited in. There isn't a button to let you select a location using a dialog box or anything, so you'll have to either manually type in a location on your computer or copy-paste the location in. Either one will work. If your current document is a Maya file saved on the hard drive somewhere (and isn't an untitled document that hasn't been saved yet), the Current Directory field just above it will show the location of the file; this is a decent choice for where to export it, so you can just copy-paste it from there if you want.

Second, there is a line saying "Export:" followed by two radio buttons, one saying "all" and the other syaing "selected." Unless the only piece of geometry in the scene is the one you're exporting, be sure to select the radio button "selected".
If you want to rescale the object during export, you can use the "Scale all by" field to do this. The rest of the settings in this section can be ignored.

Next, check the Export mesh box, under the Mesh section. The remaining checkboxes will un-dim themselves.
The step after this is important: UNCHECK USE SHARED GEOMETRY. I don't know what it is about shared geometry that causes problems, but in my early attempts at importing Torchlight meshes, leaving that box checked caused weird display issues for the exported meshes once they were imported into TorchED. So, leave the thing unchecked.

Most of the other checkboxes can be ignored, since we're not dealing with vertex bones, vertex normals, or vertex colors. You should leave "Include texture coordinates checked" (should be checked by default), otherwise your texture will not display on the mesh correctly.

Type the filename you want into the Mesh Filename text field. By default, if your file is a saved Maya file, the filename will show here with the extension (".ma" or ".mb") replaced with ".mesh". You can leave it that way, or type in a new filename; just be sure to end it with ".mesh". It's probably best to avoid using funny characters as well, so no symbols or punctuation marks. Underscores should be used instead of spaces.
The remaining settings under the Mesh section can be ignored.

Next is the Materials section. This one is simpler. As before, the text field will inherit any existing filename for the .material filename. Change it if you like, but make sure the base filename matches the one you posted in the Mesh section (e.g. if you decided to make the exported file be "awesome_sword.mesh", the material file should be "awesome_sword.material").

Note that the exported material file will take on whatever settings that are set in the shader assigned to the mesh you have selected. So, if the mesh shader's Ambient Color is set to a particular color, the ambient section in the material file will take on that color. Personally, I don't bother thinking about this as I just wind up editing the exported .material file in a text editor anyway, but it's helpful to know about.

You can check the "Copy texture files to output dir" if you feel that copying the texture files to the same location as the mesh and material files would be helpful. The rest of this section can be ignored.

The first three sections of the export window should look like so:

We are now ready to do the export. Scroll down the export window all the way to the bottom and click the big ol' EXPORT button. Maya's Output window should pop up (if it isn't already open) and list somethings pertaining to the exporting, finishing off with "Export completed succesfully". You can now take the mesh, material, and texture files and set them up to take them into TorchED, or create a Torchlight mod directly by creating the folders and .DAT files manually.

[top]Export settings for a character/creature

If you're doing something involving a skeletal mesh, such as a character, or making a new pet/monster, or making a prop that does something fun that requires an animation skeleton, there are additional settings to be aware of. Note that the mesh and material settings are exactly the same.
(The Common Parameters section should also be the same -- you may have noted the "Animation Type" drop box there, with the two options "Skeleton/Blend Shapes" and "Vertex", but don't be fooled. While the Ogre engine supports vertex animation, Torchlight does not. So any animation you do should use skeletal animation, and should have this option set to Skeleton/Blend Shapes.)

[top]Dealing with them bones first

After dealing with the Mesh and Material sections as outlined before, we now come to the first of the two new sections we need to deal with here. Under the Skeleton section, check "Export skeleton." As before, the text field will inherit the filename from the Maya scene if it has already been saved somewhere. Type whatever you want, but also as before, the base filename needs to match the mesh's base filename.

Now, in other Ogre-based games you'd continue to the Skeleton Animations section, but Runic's way of doing things seems to involve animations based in different skeleton files, instead of inside the same skeleton file. Right now we just need the base skeleton file to be exported, with no animations inside of it. So after selecting both the skeleton and the mesh that it's bound to, go down and export the skeleton at this point. Be sure to select both mesh and skeleton -- selecting just the skeleton before export won't do it.

[top]Ready to export animations

Once you are ready to export the animations, you will have to select "Export Skeleton" again. Only this time, the skeleton file should be named after the animation that you will be exporting.

Second section to deal with is the Skeleton Animations section. This is where stuff gets a little complicated.

Note that everything here, including "Export animations" will be greyed out until you check "Export skeleton" in the previous section. (Hey, it does say "requires export of skeleton" right there, after all.) Check Export animations.

For the neutral pose options, you will most likely want to pick the "skin bind pose".

Here's where it gets tricky. If you have done all the animations in the same file, this will be a little more straightforward; if you have done each animation in a separate file, you'll have to repeat the process each time for each animation. Therefore, I would recommend that when first creating the animations, you designate certain sections of the timeline within the same Maya scene file for each animation. E.g. if you are doing a pet, frames 1 through 16 might be the walk cycle, frames 17 through 28 might be an attack animation, etc.

For the sake of example, say we have 4 animations, all done within the same Maya scene file, that we want to export.
1) Idle animation, from frames 1 to 16.
2) Walk animation, from frames 17 to 32.
3) Attack animation, from frames 33 to 48.
4) Death animation, from frames 49 to 66.

Starting with the Idle animation, the skeleton file we covered a moment ago should be called idle.skeleton. Next, under the Clip1 section, we check the "Clip Name" box and type in a name for the animation. This name is important: it is the animation name that will be stored inside the skeleton file, and it is what Torchlight's data files will look for when it wants to call upon the animation. For the first export in our example, we would type idle as the clip name.

Under Time Range, you can either enter the start and end frames directly, or use the Time Slider's current location to determine the beginning and ending of this particular animation. I have used both and either one works just dandy; use whichever method is easier for you. As per the example, we would enter 1 into the Start time and 16 into the End time, or I would set up the time slider so the start and end times of the playback range specifically (the inner numbers on the time slider, not the outer numbers) were 1 and 16 to correspond to the start and end times of the animation we want to export.

Unless you have some funny settings in the Maya preferences set for your time slider, the Frames/Seconds option should remain on Frames.
Personally I have not had a need to change the number of samples, in the last section here. Perhaps, if you have a very complicated animation that generates very bulky files, you might try to set the frame sampling to a higher number so it will sample by fewer frames (e.g. "sample by 1 frames" samples every frame, but "sample by 2 frames" would probably only sample every other frame). But I have never found this to be an issue. Most likely you will not need to change this.

After the animation clip's info has been sorted out, again select both the mesh and the skeleton, scroll down in the Export window, and click export.

For each subsequent animation (walk, attack, etc.), go back and alter the information in the Skeleton and Skeleton Animation sections accordingly. (Or, if you are making the animations in separate scene files, close the export window, open each file, and repeat the procedure from the beginning.) Keep in mind that each animation needs its own separate skeleton file -- don't try to use the "Add Clip" button to add the other animations in. That method may be standard for other Ogre games, but it's not the way Torchlight does it.

Once all the .skeleton animation files have been exported, along with the main skeleton file, mesh file, and material file, you are ready to begin following the procedures involved in importing your new character/monster/pet!

Posting Permissions

Posting Permissions

  • You may not post new pages
  • You may not post comments
  • You may not post attachments
  • You may not edit your posts