1
\$\begingroup\$

The Problem:

I have been making a model of a Steampunk-themed street light in Blender for use in my MonoGame/XNA Game. To test it I exported it to the *.fbx file format using the fbx export plugin for Blender.

After setting everything up in the code and starting the game, that was the result:

The rendering output of MonoGame/XNA

As you can see some of the triangles are missing or their vertices are connected in a wrong way. In addition to this you can recognise two additional faces on the top that were not intended to be there.

I am using a pretty standard code to render my model with a BasicEffect:

        foreach (ModelMesh mesh in model.Meshes)
        {
            foreach (ModelMeshPart part in mesh.MeshParts)
            {
                part.Effect = effect;
            }
            mesh.Draw();
        }

What I tried so far to solve the issue:

  • Searching on Stackexchange, no result
  • Asking Google, no result
  • Playing arround with the GraphicsDevice settings was either not solving the problem

        gDevice.RasterizerState.CullMode = CullMode.None;
        gDevice.DepthStencilState = DepthStencilState.Default;
        gDevice.BlendState = BlendState.Opaque;
    
  • Downloading the latest Blender version and exporting again did not solve anything despite the fbx plugin was updated
  • I also suspected a problem with the normals so I recalculated them in Blender but it did not help too

What software/hardware did I use?

  • Surface Pro 2 (intel core i5 with intel hd 4400 graphics)
  • Blender 2.75a
  • Visual Studio Express 2013
  • MonoGame Framework(I believe its version 3.4)

So here are my questions:

What is causing this result? Could it be a problem with MonoGame/XNA or a problem with Blender/the fbx exporter (or my export settings?)?

Did maybe one of you had such issues with fbx models and MonoGame/XNA?

I would very appreciate any guesses, help or solutions from you. If you need more Information, just ask for it. Thanks in advance.

\$\endgroup\$
1
  • \$\begingroup\$ Is the problem just on this specific model ? Although I am pretty sure your code has the same result, just in case, take a moment and try the most basic way to draw the model. The code you need is on the Step 4 in that site. The foreach statement is done a bit differently: foreach (ModelMesh mesh in myModel.Meshes). \$\endgroup\$
    – dimitris93
    Commented Aug 11, 2015 at 21:02

4 Answers 4

1
\$\begingroup\$

After another hour of researching and trying I finally solved the problem. As Shiro suspected it was not the rendering code that causes the problem. I tried it with models from which I know they worked for other projects and they were drawn just fine.
So I began to search for issues with the lamp model itself. With the current Blender exporter, there is no option to triangulate the model during conversion. But what I tried was to apply a triangulate modifier in Blender and then exporting it, but the result was even worse than before. Now the whole model seemed to be corrupted.
My research on the internet brought me to this bug report. According to this I tried everything again with Blender version 2.68 but this solved nothing. I continued my research on the mesh by looking specifically on the corrupted parts e.g. the right lamp. What I found was that I used linked duplicates (alt+d) to copy it from one side to the other. Also I joined all parts of the meshes together.
After playing around a bit with the two Blender versions and making duplicates real I solved it by first making all duplicates real, selecting all the single objects, applying the scale/rotation/location and checking "export selected" and "XNA strict options" in the export settings of Blender 2.68 and then exporting.

By the way to those of you who use MonoGame: the fbx exporter of Blender 2.68 does not support the binary fbx format so the fbx file will not work with the MonoGame content pipeline. To get my fbx converted to a xnb file I used a Content converter from CodePlex, and added some code to convert 3d models. I then manually put the xnb to the bin/Debug directory.

To conclude I think it was a problem with both the model/mesh and the fbx-exporter.

I hope I could help some other people too.
Thank you for your help.

Note: the original Content converter from CodePlex does not seem to have an official migration project elsewhere, however this GitHub project claims to be based on the original code.

\$\endgroup\$
1
  • \$\begingroup\$ Had a similar problem. Did you attempt to turn off backface culling? \$\endgroup\$ Commented Aug 28, 2015 at 2:15
0
\$\begingroup\$

Looks like a export setting. Make sure the model is triangulated on export or prior. Also I assume your draw call is set to indices with individual triangles? Might be worth checking if you get TriangleStrips exported.

\$\endgroup\$
0
\$\begingroup\$

I'm not sure what causes this problem completely, but I think that some blender models are just plain not supported well in XNA and the FBX format.

This has happened to me before, and my solution was to export the model as STL, upload it to here: https://netfabb.azurewebsites.net/ and import it back into blender and export as FBX.

The only downside is that the STL format doesn't seem to keep track of material and / or color settings, so generally this model fixing would have to be done before any texturing and stuff or you'd have to redo a lot of work.

Basically, why this works is because the STL format is for 3D printing. So the STL fixing tool (netfabb) pretty much has one main goal, make the object solid so that a 3D printer could understand it.

I hope that you find a better solution than I did, because this process can get very annoying. But if you can't, then I hope this works for you. :)

\$\endgroup\$
2
  • \$\begingroup\$ That did not solve the entire problem but removed some of the artifacts and I agree that this process, especially with a high number of models can get annoying. Thankfully I found another solution for me. Maybe the Blender 2.68 fbx exporter can help you too... \$\endgroup\$
    – justinnk
    Commented Aug 12, 2015 at 9:36
  • \$\begingroup\$ Okay, great! By the way you can make a write-up of your solution and post it as an answer to your own question. :P then you should be able to mark it as the solution, rather just having it as an edit to the question. \$\endgroup\$
    – Superdoggy
    Commented Aug 12, 2015 at 13:05
0
\$\begingroup\$

I think I know what is wrong. It seems like some of faces in your model have one side. Try to open your model in blender, match three vertices that makes some triangle you cant see and use ctrl + N (in edit mode as far as I remember). It should flip your face, so it would be visible. When I had that that problem I did that with every single face, but there may be some easier method to do that.

\$\endgroup\$
1
  • \$\begingroup\$ If I understand you right, you want me to flip the Normals (if not, correct me)? As I wrote in my question wrong normals were one of my first suggestions. But I think they are fine and the problem is elswhere. Anyway, thank you for your answer. \$\endgroup\$
    – justinnk
    Commented Aug 12, 2015 at 11:26

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .