Tuesday, June 02, 2009

Free models for XNA


A common problem for programmers is getting some decent artwork to use. I've previously posted about Sketchup but recently came across something new.

Rob's blog gives instructions about how to export Sketchup models to the XNA '.X' format. This means you can download free models from the Sketchup 3D Warehouse, export them to .X format, and use them in your 3D XNA program.

If you need to modify the model, you can do so in Sketchup or TrueSpace (also free).


Potential Problems
  • Not all Sketchup models are textured, and the ones with textures may need a bit of love to make them work in your game. Specifically the textures may be non power-of-two in size. To fix this you just need to scale the image in a paint program (I like Paint.net) so that instead of being some funky size like 13x111, they're power of two sized, like 16x128. The model should still look fine.
  • Models may be textured using many textures (the one I looked at used about 20). This isn't a problem if you're not concerned about performance, but the frequent render-state changes will cause performance problems if you're rendering a lot.
  • Models may be positioned away from the origin in the Sketchup scene, and need moving back.
  • Models will likely not be the scale you want, so you'll need to adjust this.
  • Models may be pointing down the wrong axis and need rotating.

The exporter is a Ruby Script file. Reading the file, one should be able to become familiar with the Ruby scripting language, and the Sketchup API. It should therefore be possible to use Sketchup as a level editor (as mentioned previously) and write a custom exporter in Ruby. Nice!

(Note - I'm not sure whether models from the 3DWarehouse can be used in commercial products, but they'll be fine for home/demo use.)

No comments: