Reputation: 77
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
Upvotes: 3
Views: 5226
Reputation: 4867
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.
Upvotes: 5
Reputation: 5519
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"
Upvotes: 0
Reputation: 324
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)
Upvotes: 0