Adding 3D Textures to Pipeline (Works, but Strange)

This isn’t so much a complaint but a ‘am I even doing this right?’ discussion of adding 3D models (with textures) to my project. Maybe it will help someone (such as myself in the future after I forget the process). I will walk step by step how I successfully load 3D models into my monogame project, including textures. The last 6 steps or so are where the strange stuff is.

Getting Set Up

Before we can bring your awesome textured 3D models into your MonoGame, you need to A. have a monogame program that can load .dae models and B. have a simple textured 3D model that you know works to test your program with.

Install Monogame

Install Windows Studio Community 2017 from visualstudio.com

Install Monogame 3.7.1 from monogame.net, this includes the Pipeline

Create Project

This method has been tested with MonoGame Windows 10 Universal (XAML) Project and MonoGame Windows Project and should work for all project types.

Fix ‘Build Action’ for Content/Content.mgcb

Build Action should point to Pipeline .exe file (E.G. C:\Program Files (x86)\MSBuild\MonoGame\v3.0\Tools\Pipeline.exe). Do this by right clicking Content/Content.mgcb in Solutions Explorer and selecting ‘Open With…’

Create a test model from scratch

Before we can use models we downloaded from TurboSquid and other complex models, we should create a very simple model that we know works. Use this tutorial to do so: MonoGame Tutorial – Creating and exporting a textured model from Blender to MonoGame

Create basic program to display your 3D Model

Create the basic program that displays your 3D model, including its textures. Use this tutorial to do so: MonoGame Tutorial Part Five: 3D Programming (text version: https://www.gamefromscratch.com/post/2015/08/20/Monogame-Tutorial-Beginning-3D-Programming.aspx) Test your program with the simple test model you made in the last step. You should now have a program with a simple rotating textured cube.

Adding Your Existing Models

Now comes the hard part. Getting your existing models with textures into Monogame is frustrating and fraught with problems related to converting to .dae and setting your texture’s path.

Download Model

Download a cool model from www.turbosquid.com for Free. Preferrably one with existing textures and a filetype that can be open by Blender.

Convert your file to .dae with blender or other tools

Import your file to blender and export as a .dae file. In 3D View Enable Texture on Viewpoint Shading as in the picture and make sure your textures are showing correctly. If you are using older version of blender, make sure under ‘Texture Options’ you have UV Mapping enabled (newer versions do not ask).

Test .dae file to make sure it was converted successfully

Open the file with Autodesk FBX Converter and press ‘Display Mode’ until Display Mode is set to Textures. Your model and textures should be visible and looking as expected. If not, textures needs to be fixed in blender.

Open the .dae with a text editor and modify path

The .dae contains xml. Under library_images tag, there will be your path to your texture(s). Your new path should be set to something like this:

file://C:\Users\MyName\source\repos\Game1\Game1\Content\bin\WindowsStoreApp\MyTextureFilename.png

This path is determined by your project file and your pipeline. It is where your pipeline is saving it’s .xnb files.

Add .png texture file to new path

Navigate to the long path above and add a .png or .jpg version of your texture. This is because when building your .dae file will want a .png or .jpg and will not build off a .xnb.

If there are already .xnb versions of your texture here, you may have to duplicate or rename them. At new path, change myTexture.xnb texture file name to myTexture_0.xnb. I’m not sure why adding _0 helps or if this has to be done everytime yet.

Run Pipeline Tool

Double click Content.mgcb in Solution Explorer to open pipeline tool.

Add .dae model and .png texture files

Add the .dae and .png resources to pipeline tool.

Change model importer to Fbx Importer in pipeline tool

Select your .dae in the pipeline tool and under properties change model importer to Fbx importer.

Build Pipeline Resources

Press Build in the pipeline.

Now try this on linux :slight_smile: