menu
info Documentation

Content Creation Guide

Introduction

D2S2 is compatible with most content files created by the MonoGame Content Builder (MGCB) tool. You can read more about this tool at https://docs.monogame.net/articles/getting_started/tools/mgcb.html . D2S2 converts MGCB content automatically when it loads it from a content directory. This page will guide you through the process of preparing content files to be directly used in D2S2 in custom plugins or user code.

Requirements

  • Windows 10 or 11
  • .NET 8 SDK
  • MGCB, installed with: dotnet tool install --global dotnet-mgcb

Preparing Models

Models can be supplied as FBX or STL files. STEP files are not supported; export them as STL from the CAD tool first.

FBX

FBX files must be supplied with their textures. Textures must be no larger than 2048 x 2048, stored next to the FBX and linked from the model's material with a relative path. Embedded textures are not supported and will cause the build to fail.

Apply all transforms before exporting. Rigged models (armatures or bone-parented meshes) are not supported: parts of the model may appear in the wrong place.

STL

Binary and ASCII STL files are supported. Most CAD tools export STL with Z as the up axis; where the tool allows, export with Y up.

Size Limit

Each mesh may contain at most 65,535 vertices. For an STL file this is about 20,000 triangles. Reduce the export resolution (tessellation) of larger models.

Building

Building happens using the standard MGCB commands. For ease of use, create a command-file named content.mgcb in the folder that contains the models:

/outputDir:MGCB_Build
/intermediateDir:MGCB_obj
/platform:Windows
/profile:Reach
/compress:False

/importer:FbxImporter
/processor:ModelProcessor
/build:model_a.fbx
/build:model_b.stl

Add one /build line per model. FBX and STL files use the same importer and processor lines. Linked textures are built automatically and must not be listed. All paths are relative to content.mgcb. List every model in the same file: each build removes any earlier output in Build that is not listed.

Run the build from the same folder:

mgcb /@:content.mgcb

The build is successful when MGCB reports 0 failed.

Delivery

Copy the contents of the MGCB_Build folder into a folder listed under Content Directories in the Developer User Settings, keeping the folder structure. Do not rename the files: models refer to their textures by file name.

To draw a component with the delivered mesh, see Linking Custom Models to Meshes.

Troubleshooting

MGCB reports "The source file ... does not exist"

The model's texture is missing or embedded. Place the PNG next to the FBX, link it with a relative path and export again.

D2S2 reports "HiDef content, but the graphics device only supports Reach"

The graphics card only supports the Reach profile, and the /profile:Reach line is missing from content.mgcb.

D2S2 reports "compressed"

The /compress:False line is missing from content.mgcb.

D2S2 reports "no XNA 4.0 equivalent"

The model was built without /importer:FbxImporter. Make sure the importer line appears above all /build lines.

MGCB reports "IFC: Unrecognized file schema"

The file is a STEP file. Export it as STL and build the STL instead.

The application reports "Reach profile does not support 32 bit indices"

A mesh exceeds the size limit (see Size Limit). Export the model at a lower resolution.

Parts of the model are in the wrong place

The model is rigged. Remove the armature, apply all transforms and export again.