--- layout: post title: 'Tutorial: Creating OpenSim terrain with Blender' date: '2009-09-08T17:18:00.000-04:00' author: Anna Wiggins tags: - tutorial - opensim - second life - linux - metaverse - Technology modified_time: '2013-10-22T11:19:50.728-04:00' blogger_id: tag:blogger.com,1999:blog-4209116010564764361.post-5832678214939499715 blogger_orig_url: http://www.stringofbits.net/2009/09/tutorial-creating-opensim-terrain-with.html --- This tutorial will explain how to create RAW terrain files for OpenSim and Second Life using Blender and the Gimp.

Before we begin


You will need the following software for this tutorial. All of this software is free and open source.

In addition to the above software, you will also need a blank RAW terrain file. You could download a terrain file from OpenSim and transform it into a blank one (replace the Height layer with #ffffff, replace the factor layer with #808080), or you could just use the one I've included with terrainerizer.

Create a heightmap


A good tutorial on creating a generic heightmap in Blender can be found here.

The tutorial above creates a heightmap that is 512x512 pixels. However, an OpenSim RAW terrain file is only 256x256 pixels. This means that the above tutorial will create terrain for 4 regions, arranged in a square. If you need terrain for a different number of regions, you can modify the above tutorial to create different sized heightmaps.

For example, suppose you want to create an oblong island that is 2 regions by 4 regions in size. To do that:

1. Create the plane, but instead of scaling it to 2x2 blender units, scale it to 2x4 blender units. To do this, you can use this command sequence in blender:

Now you should have a plane that is oblong instead of perfectly square.

2. When you configure the render settings, you will need to use different values.



Creating RAW terrain files with the Gimp


Now that you have a heightmap file, you still need to turn it into terrain files that can be uploaded into OpenSim.

Enter Domino Marama, creator of gimpterrain, an import/export plug-in for the Gimp that can handle the OpenSim RAW terrain format. Download gimpterrain and install it into your gimp plug-ins directory.

Now, if you are running Linux, you can automate the rest of this section with my terrainerizer script. See below.

We also need the blank terrain file that I mentioned earlier.

Armed with these tools, we can open a terrain file in the gimp and combine it with a portion of our heightmap.


  1. Open your blank terrain file (blank.raw) and the heightmap in the Gimp.

  2. Using the Rectangle Select tool, select a 256x256 pixel section of the heightmap, starting in the upper-left corner.

  3. Click Edit -> Copy

  4. Select the terrain file and make sure the Height layer is selected.

  5. Click Edit -> Paste. You should see the section of the heightmap you copied appear as a floating layer.

  6. Click Layer -> Anchor Layer. The Height layer should now look like the copied portion of the heightmap.

  7. Click File -> Save As and save this file as a new file with the .raw extension.



Now, repeat this process for every 256x256 pixel section in your original heightmap.

Making it easier


Performing the steps in the previous section is very tedious, especially given how long it takes to save the terrain files. To make this easier, I have automated the process with the terrainerizer script.

If you are running Linux, simply put the terrainerizer script somewhere in your path. Edit it and specify the path to your blank.raw file, then run:

terrainerizer heightmap.png


Replace 'heightmap.png' with your heightmap file. Now let terrainerizer work. It will handle everything we did in the previous section automatically. It may take a while, depending on how large your heightmap is.

When it is finished, terrainerizer will leave several files in your current directory, named with this scheme:

heightmap-nxm.raw

Where 'n' and 'm' are numbers starting at 0 that represent the column and row for that terrain file. So, 0x0 is the top left region of your terrain, 0x1 is the next region (moving from top to bottom), and so on. Just upload these terrain files and you're done!


Uploading the terrain files


Now that you have the terrain files, you can upload these files into OpenSim. There are two ways to do this.

1. From the OpenSim server console, you can simply:

change region RegionName
terrain load /path/to/terrain.raw


Repeat this for each of your regions.


2. From a viewer connected to OpenSim (assuming you are using Hippo or a similar viewer):



[caption id="attachment_190" align="alignright" width="300" caption="The Upload Terrain menu in Hippo"]The Upload Terrain menu in Hippo[/caption]

Repeat these steps for each region where you want to upload terrain.


Edit: Apparently wordpress.com doesn't allow arbitrary files any more, so I've moved terrainerizer to github. The links have been fixed above, or you can simply click here.