Using Blender Models In XNA

posted in: General 3

What's in the box? Mario knows.The following is based on Part I of Stromcode’s excellent Modelling for XNA with Blender series, which details how to create a basic UV textured 3D model in Blender and export it as an .fbx file for use in XNA.

I’ve included a few extra solutions to problems I ran across while attempting to follow the tutorial myself using Blender 2.48a. Hopefully they’ll prove useful to someone out there.

Step 1. Follow the original tutorial to: add a mesh, apply a material to the mesh, add a texture to the material, and tell Blender to map the mesh using UV coordinates.

Step 2. Instead of changing the left window’s mode to UV Face Select, change it to Edit Mode and make sure that Textured is selected as the Draw Type (press ALT+Z to change) or use this menu:

Blender: Draw Mode Menu (Texture)

Step 3. You should now be able to continue following the tutorial to apply your texture.

Step 4. Time to export! Unfortunately, if you’re setup is anything like mine was: you can’t, because there is no Autodesk FBX option under the File->Export menu (if there is, skip ahead to step 5).

Solution One: Install an older version of Python. Ideally you should install Python before installing Blender, but in my experience that wasn’t necessary. What was necessary, however, (for unlocking full script support) was installing the correct version of Python. For Blender 2.48a that means Python 2.5 (found here), not the latest version (2.6 or 3.0 at the time of writing.)

If you see this when you start Blender, you're good to go!

Solution Two: Move the scripts folder. When you install Blender you should see the ‘Choose Install Location’ screen shown below. If, like me, you left the default option enabled your scripts folder will be located in “C:/Documents and Settings/UserName/Application Data/Blender Foundation/Blender/.blender/scripts”.

Blender: Install Location (use installation directory, not application data)

For some reason, Blender still looks in “C:/Program Files/Blender Foundation/Blender/.blender/scripts”, which doesn’t exist! A simple copy-and-paste from the former to the latter solves that, though. Upon restarting Blender the File->Export menu should be brimming with options, including the all-important Autodesk FBX (.fbx). Hooray!

Step 5. Export the .fbx file to your XNA project’s content directory and add it to the Content Pipeline.

Step 6. Open the .fbx file and edit the RelativeFilename string to point to your texture.

And you’re done! You should now have no problem adding the model to your game and moving on to Stromcode’s Modeling for XNA with Blender Part II, III, and IV! I’ll be doing so myself shortly, and I’ll be sure to post any other solutions I stumble upon if necessary.

Happy blending!

3 Responses

  1. Pinki
    | Reply

    Great, thanks for this information. I don’t think Stormcode’s tutorial ist that good, because your information is missing.

  2. Jonathan
    | Reply

    When I open my .fbx file that was exported using blender, I cannot find any RelativeFilename strings.

  3. Ray
    | Reply

    unless you’ve uv mapped the texture to the model properly, you won’t
    get a path to the texture in the .fbx

Leave a Reply to Jonathan Cancel reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.