Game Creation with XNA/3D Development/Importing Models

Importing ModelsEdit

In the previous chapter we learned how and where to find 3D models. The real problem comes about when you actually want to use them in your game. There are many issues to worry about. So here we show you how to import models generated with

  • Cinema4D
  • Maya
  • Blender
  • Sketchup
  • Others

into your XNA game.


The topic of this short intro is, how to import models in XNA. Why we put this import stuff in the introduction has a simple reason... it is everytime the same with the .x files or with the .fbx files.

Now, how do we Import the model into the XNA framework?Edit

First of all, the bones and polygons of your model are limited in XNA:

  1. Bones: max. 59 up to 79 in 4.0
  2. Polygons: depends on the hardware

I will show you how to import the model by using the simple code from the site. This demo shows the most important methods which we need. Demo:

First we need a model:

 Model currentModel;

next we take a look at the LoadContent() method:

 protected override void LoadContent()
            // Load the model.
            currentModel = Content.Load<Model>("ModelName");

            // Look up our custom skinning information.
            SkinningData skinningData = currentModel.Tag as SkinningData;

            if (skinningData == null)
                throw new InvalidOperationException
                    ("This model does not contain a SkinningData tag.");


The LoadContent() method is the only way to import your models. We do not take a look on the animation so far, but this is either the topic.





Cinema 4D is a 3D modelling tool from Maxon and is comparable with Autodesk Maya. C4D is able to export .fbx files which then can be imported to XNA. There's no possibility to export directely to .x files like in Google's SketchUp.

In the link below you can find helpful links concerning Cinema 4D:

Exporting in adequate formatsEdit

Simple .fbx file exportEdit

When you are using the normal .fbx export, sometimes the textures aren't exported as well. It's a bug caused by Maxon's C4D - maybe it works, maybe not.

  • File
    • Export
      • Expot as .fbx
Settings for the normal import:

Exporting a .fbx file with a plug-inEdit

In the link below you can find an exporting/importing plug-in for C4D:
YouTube Turtorial:

Now you can import the .fbx file into your XNA program. It may be more reliable than the export into a .x file.

Importing in XNAEdit

Actually for XNA it is insignificant whether the file is a .fbx or a .x file. It is only important for the modeler concerning the software they are using.

--> Introduction





Maya is a commercial 3D computer graphics software from Autodesk. It runs an many different operatings systems like Linux, Mac OSX or Windows. Its used for all 3D aplications like video games, animations, films or visual effects. Maya and 3Ds MAX are both from Autodesk, these are consimilar with each other.

Is it possible to export .x files from Maya?Edit

The main problem in Maya and XNA is that both are written in different languages. Maya is written in OpenGL and XNA is basend on DirectX. According to this problem it is tricky to import .x files from OpenGL to DirectX but there are tools to manage this, like the cvXporter.

Exporting in adequate formatsEdit

How to Export (.x)?Edit

If you use the cvXporter, here are a few steps to use this tool. Click

Here is an example how to manage the problem if your plug-in doesn't work! Click

Please do only these steps if the fbx and .x importer doesn't work. I will talk more about the fbx importer later.

How to Export (.fbx)?Edit

The fbx format is the simplest way to export a file which can be used in XNA. Maya doesn't support the fbx file format so we have to use a plug-in.
This plug-in allows us to export fbx files in Maya.

What an amazing coincidence... Autodesk knows a lot of problems and wrote a whole e-book for fbx files in Maya. So if you have some problems with the fbx exporter, please use this quite useful link.
E-Book on fbx & Maya:

How to Import?Edit

--> Introduction




3ds MaxEdit

3D Studio MAX called 3ds MAX is a commercial 3D modeling tool from Autodeks.In the use and logic between Maya and 3ds Maya are not so many differences. The one and only diffence is 3ds MAX runs only on Windows systems.

Is it possible to export .x files from 3ds Max?Edit

First of all there is no possibility to export a .x file from 3ds Max, but there are a lot of quite useful plug-ins for 3ds Max. One of those is KWXPorts.

This tool allows you to put the x into 3ds Max. XNA support also the FBX Format as well. But there could be some problems with the animations and textures of your model.

Exporting in adequate formatsEdit

How to export?Edit
  • First download the plug-in from the web-source above and install the tool.

...a few minutes later...

  • In 3ds Max
    • File-->
      • Export-->
        • KWXPort(format)-->
          • The KWXPort Export Options
  1. Geometry
    1. Import the Normalt(lightning)
    2. Make Y up (for the right alignment)
    3. Export flight-handed Mesh (the mesh from the model)
  2. Materials
    1. Export Materials
    2. Export Textures
  3. Animations
    1. Export Animation: There is a list of all your animations, if you setup some of them in 3ds Max.Your have the option to give names to the different animations and put these animations in the correct frames from your hole animation.
  4. Finaly
    1. Export as Binary(gives us the best format)

The result is a combination of three files.

  1. The Texture: nameofthemodel.png
  2. The DirectX File: nameofthemodel.x
  3. The .X Log-file: nameofthemodel.log

In the log file are quite useful information for us. The number of verteces......and the whole bone-structure of the model with the complete hierarchy of these. The DirectX SDK Viewer is a nice tool to check your .x file. There you have the possibility to see the normals, the textures... on your model from the .x file.

DirectX SDK

How to import?Edit






Blender is the Linux under the 3D modeling software, it is a completely open source program and it runs on all known operating systems.
You can do anything with blender like in the other commercial tools like Maya and so on.... UV Mapping, rigging, skinning.... and also for animations in games and film.

Here is a list of nice tutorials for Blender in combination with XNA.


Is it possible to export .x files from Blender?Edit

No blender cannot export to .X without a plugin.

Exporting in adequate formatsEdit

How to export(.x)?Edit
  1. File-->
  2. Export-->
  3. DirectX(.x)

The result is a nice .x file from your model.

How to export(.fbx)?Edit

Here we are, again the only solution is a plugin. What else? Blender supports the script language Python, here is a nice script for the export to xna.

How to import?Edit






Sketchup is an opensource software from Google for developing 3D models. There are two different versions available - the "normal" and the Pro Sketchup. In the normal version 3D exporting is restricted supported. You can only export your models into 2D image formats like .jpg, .png, .tif and .bmp or the one and only 3D format COLLADA (.dae). The Pro version allows exports into additional 2D formats (.pdf, .eps, .epx, .dwg, .dxf) and other 3D formats (.3ds, .dwg, .dfx, .fbx, .xsi, .vrml).

Exporting in adequate formatsEdit

Simple .fbx file exportEdit

In Sketchup it is really simple to export 3D files into a .fbx file:

  • Select File
    • Export
      • 3D Model
 The Export Model dialog box is displayed (Microsoft Windows).
 In the link below you can find information about the export dialog box and what settings you can conduct:
  • Enter a file name for the exported file in the 'File name' (Microsoft Windows) or 'Save As' (Mac OS X) field.
  • Select the FBX export type from the 'Export type' (Microsoft Windows) or 'Format' (Mac OS X) drop-down list.
  • (optional) Click on the Options button. The FBX Export Options dialog box is displayed.
  • (optional) Adjust the options in the FBX Export Options dialog box.
  • (optional) Click the OK button.
  • Click the Export button.

Now you can import the .fbx file into your XNA program. It may be more reliable than exporting it into a .x file.

Exporting a .x file with a plug-inEdit

But there is also another possibility! Thanks to a free plug-in, we can also directely export the 3D model into a .x file to simply importing it into our XNA program.

In the link below you can find a really nice tutorial which explains step by step the usage of this plug-in:
Another link... to another plug-in:

Importing in XNAEdit

--> Introduction





What we learned in this chapterEdit

It seems like it is really simple to export models into .fbx or .x files and also to import them into the xna framework. But actually it only seems ike that. When you keep yourself busy with reading forums concerning the importation of 3D models, you have to assert that there are many problems which can occur. Textures are not shown, the models are shown wrong in the xna game...

To avoid those bugs aroused by the modelling software you can work with the free Autodesk Softimage Mod Tool:

But most of you won't create models themselves. So what about our "Finding free models"-models? In our Introduction the "normal" way of importing is explained, also that for the xna framework the file extension is irrelevant.

Thus I will concentrate on the pros&cons of the export of these files.

But is it better to export to .fbx or to .x files?Edit

The difference between these two:

  • FBX represents an entire scene within a modeling tool, with animations, modifiers, geometry and other properties, in fairly high detail
  • The .X format stores only the data needed to render animated geometry at runtime - there is no explicit support for things like cameras, lights, morphers or modifiers in the format

More details about the difference can be found in the link below

Pros & ConsEdit

Pros & Cons .fbx .x
Pros 3DS Max & Maya support .fbx out of the box
Supports animation
Supports skeletons & skinning
Supports embedded media
Smaller file sizes
Supports animation
Supports skeletons & skinning
Is a format designed specifically for 3D game models
Supports embeded media
Cons Lots of unneeded options in the exporter, since it is not game-specific
Does not support animation clips within the file
Usually 1 order of magnitude larger than .X
Requires a third-party exporter

Now you have to measure and to decide which is the best approach for you. But please be aware of importing only .fbx or .x files into your program!

Help and solutionsEdit

Here you can find help for the topic "importing models":

  • On page 282
  • On page 261