Hey everyone,
I use Blender for most of my 3D modeling like a lot of others since it is free and has a lot of features, if not always easy to use. In my experience, getting 3D models exported from Blender and running properly in XNA had some quirks. Unfortunately, 3D models from Blender seem to have trouble importing into MonoGame as well, but they are different than XNA.
Below is my experience so far. I haven't gotten .FBX to import but I do have .OBJ importing with some minor additional steps. I would be curious how others are fairing getting Blender Models into MonoGame projects and they steps they take.
.OBJ
When exporting a model as .OBJ from Blender, after some minor file changes, I can get the model rendering in MonoGame with the proper texture. This worked with both Blender 2.68 and Blender 2.77a.
There should be an associated .mtl file built when Blender exports the .OBJ file. The .mtl file will reference the model's texture. In my case, the .mtl file was looking for the texture on my desktop for some reason. See the uncorrected Asteroid's full MTL file below.
# Blender MTL File: 'Asteroid.blend'
# Material Count: 1
newmtl Material
Ns 96.078431
Ka 1.000000 1.000000 1.000000
Kd 0.640000 0.640000 0.640000
Ks 0.000000 0.000000 0.000000
Ke 0.000000 0.000000 0.000000
Ni 1.000000
d 1.000000
illum 1
map_Kd C:\Users\username\Desktop\RockSmooth0188_1_S.jpg
map_Bump -bm 0.200000 C:\\Users\\username\\Desktop\\RockSmooth0188_1_S.jpg
I edited the last two lines to search for the texture file in the same directory that the .MTL and .OBJ file are located as so:
map_Kd RockSmooth0188_1_S.jpg
map_Bump -bm 0.200000 RockSmooth0188_1_S.jpg
Now you can add both the .OBJ and texture file (RockSmooth0188_1_S.jpg in this case) into the MonoGame pipeline. DO NOT add the .MTL file to the content pipeline, but place it in the same directory as the .OBJ file and texture file that the Content Pipeline is referencing.
The Content Pipeline will default to not setting the Importer and Processor for a .OBJ file. You must manually set the Importer to Open Asset Import Library - MonoGame and Processor to Model - MonoGame.
Now, you should be able to build the content pipeline and load the model into MonoGame without trouble.
.FBX
When exporting a 3D model from Blender as a .FBX file, I am unable to get the modeling rendering in MonoGame.
A direct FBX export from Blender (version 2.68), gives the following error after adding to MonoGame Content Pipeline and attempting to compile: Error importing file: FBX-DOM unsupported, old format version, supported are only FBX 2011, FBX 2012, and FBX 2013.
A program called Autodesk FBX converter (free program) can be used to convert the .FBX to FBX 2013 format. When updated to the new format, the MonoGame content pipeline built without errors. However, when I attempt to load the model using Content.Load<Model>("…") in the code, I got the following error: An unhandled exception of type 'Microsoft.Xna.Framework.Content.ContentLoadException' occurred in MonoGame.Framework.dll. Additional information: Could not load Asteroid asset as a non-content file!
I verified that the model was serialized into .XNB format and was in the right directory under DEBUG, so unsure why MonoGame is attempting to load the file as non-content.
Also, I had to place a copy of the .JPG texture in the root project directory in addition to adding it to the MonoGame Content Pipeline. This may be an issue with the .FBX file looking in the wrong place for the texture and may be fixable.
.X
Have not attempted yet.