Converting DirectX .X Files for Use in Games
Join the DZone community and get the full member experience.Join For Free
what do you do if you have assets in microsoft’s directx x .x format and you want to use them with unity? you'd have no problems with xna, but unity doesn't like .x one bit.
what formats does unity support
amazingly unity has an astounding amount of support for 3d model formats, including:
road to conversion
now quite surprisingly converting models from .x is quite difficult, want a package to save in .x format no problem, but import!, that’s a one way trip to the funny farm.
after a few hours of searching and installing tools i eventually came across a solution that not only worked, it was also free.
lithunwrap is primarily a tool for mapping and editing the uv coordinates of low poly models, but it can also read and write models from one format to another.
it supports importing & exporting lwo, obj, dxf, 3ds, asc, cob, and x files .
so after launching up lithunwrap you can open up a model file:
once loaded we can simply then save the model to which ever format we want to use, i’ve no particular preference but i generally use obj files as they are more commonly supported by other tools, but if you are using unity and have access to 3d studio max (or have a modeler who does) then you can just export to .3ds which unity also supports:
just be sure to use the “model –> save” options, the export options are for other things.
i could not confirm (just because i didn’t have any assets to test with) if lithunwrap will also convert / save all the features of a model such as animations, bones. it does support meshes and textures (including the ability to unwrap / change the uv mapping of a model) but you should check if you have animations or bones in your model if they are also exported. granted if you have no other option you might just have to live with it and re-create them in your tool of choice
what didn’t work?
in my journey i followed many posts and hints of ways i could convert .x files, here why most of them didn’t work:
- milkshape – was free to try and could read .x files. but doesn’t allow saving in the trial. granted it wasn’t much and you may want to buy milkshape if you wish
- truespace3d – truespace was made free several years back after microsoft bought them, can be tricky to find but its a great free 3d tool. however it cannot import .x files no matter what people say! ( <download link> )
- online / downloadable model converters – looked at several but all require purchase, anything from $100 to $$$$, seems it’s a very hot market.
- 3ds max / maya – i found hints that these big boy tools may be able to read .x files but couldn’t confirm (plus autodesk’s site wasn’t working when i tried to check)
- moddb.com had some great tools (like xconv) but they generally only convert into 1 format or another, usually for specific game engines like modern warfare
- blender is a great and free 3d modelling tool, however it can only export .x files. i think it did import .x files at one point but such things have been lost to the past (i went back as far as version 2.49b but no luck)
- do it yourself – found a nice article on how you could write your own converter / importer for the .x format, but i’m just not going there right now – http://www.opengl.org/discussion_boards/showthread.php/166733-convert-from-x-or-obj-to-opengl-in-c
Published at DZone with permission of Simon Jackson, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.