How to use XnaContent XML Files

Google AdSense

There’s a couple methods to working with XML documents in the XNA games. First, you can just serialize and deserialize your class files at run-time.

Why use XML files for game development?

By saving data outside of your executable, you can keep your data and code separate. With external data, you can make updates to the files without needing to write more code. You can also easily update and maintain the files without rebuilding your projects.

What’s the difference between using XnaContent and Serialization methods?

Run-time vs. Design-time Validation

The biggest difference between the two methods, is that using XnaContent XML files allow you to catch errors when you build your project rather than getting XML errors at run-time.

Of course, you could build XSD documents to validate your serialized class files or just trust that however the files were created, that they were created correctly.


The second difference is that the XnaContent XML documents will be converted and compressed to XNB format and your serialized files will still be XML documents.

Continue reading

Creating a textured sphere in Google SketchUp

Google AdSense

One of the downsides of using a simplistic 3D modeling software is that it may lack some of the needed capabilities. One of these capabilities that I needed was a way to map a texture to a sphere.

Imagine having a 2D image of earth and then wrapping that around a sphere. Each vertex of the sphere will need to know the pixel that it should be mapped to, so it can be rendered correctly. This is pretty simple for most 3D modeling software, but I couldn’t figure it out nor could I find any instructions on how to do this with SketchUp.

Luckily, I found an tutorial written by James of with instructions of how to use the freeware Anim8or to create and map a sphere then import that into SketchUp.

Here’s is one of my simple spherical characters from a simple 3D game I was messing around with. The characters have two spheres for their bodies: head and torso. You can see that the face wraps around the head sphere. There’s no clothing on the torso yet, so it’s just a solid render.

Continue reading

Free Development Related Tools

Here’s a few links for free development related software and tools. This is not an exhaustive list, so I’m sure there’s lots of things that I have forgotten or left out. This is just a list of things that I’ve used in the past and/or present.

As you can see, most of the free products rely heavily on Microsoft. That’s just because nearly everything that I’ve done in the last 5 years or so revolves around Microsoft technologies.

In addition, many of these free products may not be used for commercial products, so please consult the individual license agreements prior to use.

Continue reading

XNA Game Development

Well, I’m back trying to make my XNA game again. It feels like forever ago, when XNA was just in beta and I was messing around with it. And it feels like even more forever ago, that I was working in C++ trying to get my game finished.

Today, I don’t get much free time to devote to my hobby of game development. So I’ve got to make the most of the time that I can spend. Between work and life, I do squeeze in a few hours, but I’ve yet to finish a game.

Continue reading

How to load a Google SketchUp model into a XNA game

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.