3

I am trying to load an fbx (cube.fbx) Model using Monogame on Visual Studio Express 2013. I've been looking around and from what I can tell this should be such so simple. However, I cannot find a solution to my problem.

My environment is Visual Studio Express 2013 with Monogame.

I get the following error no mater what I try:

"Could not load cube asset as non content file"

I've changed the settings on the fbx file to: [Content, Copy Always]

There are no "Content Importer" or "Content Processor" options as per: http://msdn.microsoft.com/en-us/library/bb203933.aspx

The initialisation function is:

protected override void Initialize()
    {
        // TODO: Add your initialization logic here
        Model model;
        Texture2D tex2d;

        tex2d = Content.Load<Texture2D>("spot");
        model = Content.Load<Model>("cube");
        base.Initialize();
    }

The program throws the error at the line where it tries to load the model.

Hopefully, it's something stupid.

I've uploaded the test solution to recreate the issue here: https://www.dropbox.com/s/2a6lir2z04kyv7u/CubeTest.rar

Thanks in advance for your help!

Edit: Adding the following directory structure to show how the test app is structured:

   C:.
│   CubeTest.sln
│
└───CubeTest
    │   CubeTest.csproj
    │   Game1.cs
    │   Icon.ico
    │   Program.cs
    │
    ├───bin
    │   └───Windows
    │       ├───Debug
    │       │   │   CubeTest.exe
    │       │   │   CubeTest.pdb
    │       │   │   CubeTest.vshost.exe
    │       │   │   Lidgren.Network.dll
    │       │   │   MonoGame.Framework.dll
    │       │   │   SharpDX.Direct2D1.dll
    │       │   │   SharpDX.Direct2D1.xml
    │       │   │   SharpDX.Direct3D11.dll
    │       │   │   SharpDX.Direct3D11.xml
    │       │   │   SharpDX.Direct3D9.dll
    │       │   │   SharpDX.Direct3D9.xml
    │       │   │   SharpDX.dll
    │       │   │   SharpDX.DXGI.dll
    │       │   │   SharpDX.DXGI.xml
    │       │   │   SharpDX.MediaFoundation.dll
    │       │   │   SharpDX.MediaFoundation.xml
    │       │   │   SharpDX.RawInput.dll
    │       │   │   SharpDX.RawInput.xml
    │       │   │   SharpDX.XAudio2.dll
    │       │   │   SharpDX.XAudio2.xml
    │       │   │   SharpDX.XInput.dll
    │       │   │   SharpDX.XInput.xml
    │       │   │   SharpDX.xml
    │       │   │
    │       │   └───Content
    │       │           Cube.fbx
    │       │           spot.png
    │       │
    │       └───Release
    ├───Content
    │       cube.fbx
    │       spot.png
    │
    ├───obj
    │   └───x86
    │       └───Debug
    │           │   CubeTest.csproj.FileListAbsolute.txt
    │           │   CubeTest.csprojResolveAssemblyReference.cache
    │           │   CubeTest.exe
    │           │   CubeTest.pdb
    │           │   DesignTimeResolveAssemblyReferencesInput.cache
    │           │
    │           ├───InProcessTempFiles
    │           │       _CubeTest.g.cs
    │           │
    │           └───TempPE
    └───Properties
            AssemblyInfo.cs
misterfitzy
  • 77
  • 1
  • 9
  • Do you have XNA installed? That would probably explain why you don't have importer/processor options. – Cole Campbell Jul 30 '14 at 19:07
  • Hi Cole, I went back to basics after you posted your comment. I reinstalled everything but it didn't fix it. I confirmed that the XNA plugin is active but still don't have those options. When I get a bit of time later I am going to rebuild the environment from scratch to rule out my setup as an issue. I'll let you know if anything comes of it! – misterfitzy Jul 31 '14 at 09:16
  • I downloaded your project and I see what's wrong. See my answer for details. – Cole Campbell Jul 31 '14 at 13:39

3 Answers3

5

Your content needs to be in a separate project, an aptly-named "Content Project," in order for it to be built correctly. In XNA you would then add a content reference to your main project, but in MonoGame I believe you need to manually add a link to the .xnb files that are generated when the content project is built.

So move cube.fbx and spot.png into the content project, then right click -> "Add Existing Item" and add cube.xnb and spot.xnb from the content project's output folder. Make sure to click the arrow on the "Add" button and choose "Add as Link," so you're always using the latest copy.

Cole Campbell
  • 4,846
  • 1
  • 17
  • 20
0

Did you check if your file is at the good place ? I had the error as you for a longggg time and it's only because i didn't put my files to the good place on my project.

(Check in the parameters of your project and in your files on your computer)

Nicolas Le Bot
  • 324
  • 5
  • 15
  • Thanks Nicholas, I think my directory structure is OK as I am able to load the texture2d no problem. I will edit the main question to show the directory structure so you and others may check it out. Thanks for taking the time! – misterfitzy Jul 30 '14 at 18:40
0

In your supplied solution, the fbx model is named Cube.fbx but you are trying to "cube". The upper case C in the fbx filename is important. So try loading "Cube" instead of "cube"

Steve H
  • 5,479
  • 4
  • 20
  • 26
  • Hi Steve, thanks for looking into this and taking the time to download the test app. I've tried various combinations of case and just to be sure tried your suggestion just now. Were you able to get the code to work on your system? If so at least I know it's my setup that's the problem. – misterfitzy Jul 30 '14 at 18:38