How to load a Google SketchUp model into a XNA game

Google AdSense

For casual 3D modelers, Google SketchUp is a good alternative to more complicated and robust software such as Blender and Maya.

For developers who prefer to get decent looking models up and spend their time writing code, then SketchUp could be used to assist in visualizing their concept.

You can use the free version of Google SketchUp to export to the Microsoft DirectX .X format by using a custom built plug-in. I’ll describe the steps below, but if you are just looking for the plug-in then it can be found at:

The script was created by r1kdou (of XNA forums). You can view his original post here.

Installation & Setup

First, install Google SketchUp, install the above plug-in (just copy it to the <Google SketchUp install directory>/plugins folder).

Finding & Loading the Model

Next create your own or find a model via Google SketchUp warehouse. There’s tons of free models built by users and you’ve bound to find at least one or two you can use.

Here’s a good looking model that I’ll be using:

Sketchup Model Example

Export To DirectX

Next, export the model to .X format by choosing the “Export DirectX” menu choice in the “Plugins” menu.

Loading the Model into your XNA Game

Finally, copy the .x file to your “Content” folder, and include it in your project using the default “X File – XNA Framework” content importer and “Model – XNA Processor” content processor.

Don’t forget to include any texture files that the model requires. If you don’t know which textures are in use, you can open the .X file using Notepad and see the TextureFilename values (listed at the top of the .X file).

Place the textures in the same directory as the .X file, but you don’t need to add the texture images to your XNA project. Also, make sure your image dimensions are all resized to a power of 2 (2, 8, 16, 32, 64, 128, 256, etc.).

You will get a compile error if you are missing texture files or an image size is not a power of 2.

Viewing the Model in your XNA Game

Assuming, you have your camera and basic game already coded, you can now just load the model using the ContentManager.Load<Model>(“modelName”) function.

Here’s a screen capture of the above model loaded into my current game framework. You may recognize the terrain and skydome from the XNA Generated Geometry sample.

XNA Game using SketchUp Model

You can also use Google SketchUp for designing entire levels. I’m unsure of the speed involved in loading a level of that size, but hopefully (one day), I’ll test that out when my game makes a little more progress.

33 thoughts on “How to load a Google SketchUp model into a XNA game

  1. This is really cool. I’ve toyed around with Sketchup, and I’ve wondered if some of the models could be exported to other programs like this. Thanks for the info.

  2. Hi can someone help me with this question,is it easy to use xna if you have no experiance with writing code? i have made great models using sketchup for a game that i always wanted to make

    • I would say that it is as easy to use as any other programming library. First, you have to know how to program and understand that. Then you can start learning how to use the items within the XNA libraries. It all just depends on how much time you want to invest in learning how to program and how to use the XNA libraries. Just remember, there’s no drag and drop for programming. It’s just a whole lot of text/code and structuring it so that it works correctly.

      If you’d rather stick to modeling and graphics, then there’s tons of programmers over in the XNA forums that can’t build a good looking model to save their lives. You can always team up with a programmer who can’t model and then you can stick to doing what you’re good at and let your partner stick to what they are good at.

  3. sketchup is on mac os x, but this isn’t? too bad its made by microsoft. can you tell me a program that lets you put sketchup models in to games on a mac os x??

  4. Good luck finding a program that allows you to write code or import your own models into an existing game on a Mac 🙂 I don’t know if they exist or Apple allows developers to modify software unless you are a licensed Apple developer.

    XNA is a library designed and distributed by Microsoft, so developers (and hobby devs like me) can build games for the XBOX. Microsoft makes the XBOX and .NET frameworks along with Visual Studio. You can download everything for free (the IDE and the XNA libaries), you just need a PC and/or XBOX to play the games you build.

    There isn’t any games that allow you to import directly from Sketchup. That’s why I wrote this article. You are exporting the model from Sketchup format into another format. Then you are loading that other format into XNA.

    I’m sure you can find/write another script that exports from Sketchup into another format that is more compatible for your needs.

  5. You should look at the SketchUp documentation. You could also just resize it by setting the model scale in your Visual Studio content project’s item properties.

  6. Note that when using this plugin you should “explode” the model in sketchup so that nothing is grouped before doing the conversion. Sometimes you have to explode multiple times to get all the subgroups. Otherwise you get conversions that don’t load or look right.

    This converter is still not 100% working either. Sometimes the texture maps don’t show up and other times the converted models just plain don’t load.

    The most reliable way I have found to get from .skp to .x is to use the demo version of Sketchup Pro to generate a .3ds file, then use GameSpace to convert from .3ds to .x. GameSpace has a rock solid .x exporter, and the .3ds output of Sketchup Pro is a lot more reliable than this xExporter script.

  7. quoted from above:
    Place the textures in the same directory as the .X file, but you don’t need to add the texture images to your XNA project.

  8. At least with Google Sketchup 8 Pro exporting straight to a FBX (File -> Export -> 3d model) seems to be the best way. It does not seem to matter whether you explode the model or not. The only important thing is to change the Units to for example millimeters (File -> Export -> 3d model -> FBX -> Options).

    Sad that the google warehouse models are full of backfaces, so you might want to check also the “Export two-sided faces” option.

  9. Error 1 Could not read the X file. The file is corrupt or invalid. Error code: D3DXFERR_PARSEERROR. C:UsersmohammadDocumentsVisual Studio 2010Projects3D AmaZing GaMe3D AmaZing GaMe3D AmaZing GaMeContent3d modelsGroundHousesHouse2Untitled_1.x 3D AmaZing GaMe

    problem what i can do ??

  10. Ok thank you , but why when I load the model inside my game then some surfaces won’t be textured ?? the problem with my effect or what ??

    • I’m not sure. This post was made years ago and I haven’t worked with XNA since then. I would open your .x file in Notepad and make sure the paths to the textures are correct.

  11. Hi Jim, nice work. I realize that you haven’t done anything new with XNA but maybe you have an answer for my problem. I am using SketchUp8 and XNA 4.0. My imported SketchUp models do not render correctly if geometry overlaps. For instnce two cubes which overlap each other. Some of the outside planes are not being drawn. This results in the inner plane being visible. I am not using textures. The models are only colored.

    Any idea?

    • I haven’t used XNA or SketchUp in a while, but I remember having the same problems. I had to keep redoing my SketchUp models in order to prevent geometry overlaps. If I remember correctly, there was a tool or something inside of SketchUp (or maybe a script I downloaded) that assisted somewhat. I can’t remember what that script/function did, but I remember using something to at least find or maybe fix those problems.

  12. Where do i grab the textures from the models from in Google sketch-up? There is an option to export the model and textured faces.

  13. Is there any way to make the models in Sketchup that you have made “look better,” by any chance, meaning refining and sculpting them in another software, like, say, Blender? I want to use Google Sketchup in a project, but I need the models to be better-looking than they come out from the program? Thanks.

Leave a Reply