«

Jul 16 2015

Using Sketchup Models in MonoGame

I recently ran into this minor problem when working with MonoGame, and I couldn’t find a guide that covered the entire process so I thought I would collect the different steps together here.

First, after creating the 3D model in Sketchup (I was using the latest 2015 version), you should export the model in the .dae format; you can do this with File->Export->3D Model. Unfortunately, the .dae model format is not supported by the current MonoGame pipeline (I am talking about this tool), or at least the build process was unable to complete for me, freezing after creating an empty .xnb file.

Thankfully a tool I had previously used was helpful here, the FBX Converter (I used version 2013.3) made by AutoDesk, which can similarly be used to convert old format .fbx files from blender into a new format that can be used in MonoGame. The converter can be downloaded for free here, and this video should show you how to use it (although the process is pretty simple – add a file on the left hand side, make sure the FBX 2013 format is selected, and press the convert button in the bottom right).

After you have converted the file into the .fbx format, you can add it to the MonoGame Pipeline like any other file. If the model has attached textures, be sure to keep the folder that contains them (the folder will be named the same as your model) in the same directory as the .fbx model, and the pipeline will copy it automatically to the output directory with the .xnb when it builds.

Although at this point the same model would draw fine for me in XNA 4, I found that in MonoGame 4 I needed to use the following code to make it render properly:

            GraphicsDevice.RasterizerState = RasterizerState.CullCounterClockwise;
            GraphicsDevice.SamplerStates[0] = SamplerState.AnisotropicWrap;
            GraphicsDevice.BlendState = BlendState.Opaque;
            GraphicsDevice.DepthStencilState = DepthStencilState.Default;

Source.

After this I simply used the Model.Draw() method without any problems.

Note: This is using the free version of Sketchup, from what I have read if you have the pro version then there is a built in fbx exporter – although you still may need to use the FBX converter like if you were trying to use a model from Blender.

Leave a Reply

Your email address will not be published. Required fields are marked *


+ five = 11

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>