XExporter v1.2
By Markus Bergqvist and Jesper Henning
About
This is a MEL script .x file exporter for Maya. It is written specifically for the open source 3D engine Irrlicht. The reason I wrote this is that I could not find any free .x file exporter for Maya that works well. Microsofts exporter included in the DirectX SDK has some terrible drawbacks, it exports everyting in the scene, like the four default cameras and so on, and it exports animation data for every frame in the timeline. It also exports data that the Irrlich engine can not read (yet).
Features:
- Exports text encoded .x files.
- Exports triangulated polygon meshes.
- Supports Maya's Lambert and Blinn materials.
- Exports skeletons.
- Exports skin data.
- Exports keyframe animation for joints, ik handles and object transform.
Drawbacks:
This is a script so exporting is slow. 3000 triangles took me about 1 minute to export on my P4 3GHz computer.
TODO's:
Support more than one polygon object in the same file.
Flip the Z-axis to convert Maya's right hand coordinate system to DirectX left hand.
Check which versions of Maya the script works with =). It works with Maya 7.0 and probably down to like 4.5 or so but it will not work with the PLE.
Installation
Copy the XExport.mel file to "Alias/MayaX.X/scripts/startup" for example "C:\program files\Alias\Maya7.0\scripts\startup".
Source the script or just restart Maya.
Now you can call XExport(); in the command line to open the GUI.
Usage
You can only export polygon objects. Be sure to triangulate, delete history and freeze transormation on your object before export or before you skin it to a skeleton. You can only use max 4 influences in your skin bind (limitation in DirectX). You can only animate your object by keyframe the transformation on joints, ik handles and the object it self. Keyframes can only be from frame 1.
- Open the GUI.
- Select either a polygon object or, if you want to export just a skeleton, the root joint of a skeleton.
- Check what you want to export in the GUI.
- Enter a file name. You can write an absolute path or just a file name.
- Click export and wait for the script to export your scene.
- Place the .x file and all texture files it uses in the same folder.
- In Irrlicht you have to scale the animatedMeshSceneNode in negative z-axis to correct from Mayas coordinate system. For example:
model = scnMgr->addAnimatedMeshSceneNode(scnMgr->getMesh("model.x"));
model->setScale(vector3df(1, 1, -1));