<table border="0" cellpadding="0" cellspacing="0" width="700">
<tbody>
<tr>
<td width="700"><table id="toc" summary="Contents">
<tbody>
<tr>
<td><div id="toctitle">
<h2>Contents</h2>
<ul>
<li class="toclevel-1"><a href="#Introduction"><span class="tocnumber">1</span> <span class="toctext">Introduction</span></a></li>
<li class="toclevel-1"><a href="#Create_Blank_Terrain"><span class="tocnumber">2</span> <span class="toctext">Creating Blank Terrain</span></a></li>
<li class="toclevel-1"><a href="#Add_Existing_Terrain_File"><span class="tocnumber">3</span> <span class="toctext">Adding an Existing Terrain File</span></a></li>
<li class="toclevel-1"><a href="#Heightmap.2C_Opacity_Layer.2C_Terrain_Textures"><span class="tocnumber">4</span> <span class="toctext">Importing a Terrain</span></a></li>
<li class="toclevel-1"><a href="#Importing_A_Heightmap"><span class="tocnumber">5</span> <span class="toctext">Importing A Heightmap</span></a></li>
<li class="toclevel-1"><a href="#TerrainBlock_Properties"><span class="tocnumber">6</span> <span class="toctext">TerrainBlock Properties</span></a></li>
<li class="toclevel-1"><a href="#Conclusion"><span class="tocnumber">7</span> <span class="toctext">Conclusion</span></a></li>
</ul></td>
</tr>
</tbody>
</table>
<a name="Introduction" id="Introduction"></a>
<h2> <span class="mw-headline">Introduction</span></h2>
<p>Terrain simulates a land mass in your game which can be occupied, traversed, or flown over by objects in your game world. Terrain is represented in a game level by a TerrainBlock.</p>
<p><br />
In order to follow along with this article using World Builder, you must either create a new game project or open an existing project. </p>
<p><br />There are three methods to add a TerrainBlock to a level: (1) Create a
blank terrain; (2) Add an existing .ter file; and (3) Import a heightmap.</p>
<p><br />
<a name="Create_Blank_Terrain" id="Create_Blank_Terrain"></a></p>
<h2> <span class="mw-headline">Creating Blank Terrain</span></h2>
<p>To create a new blank terrain start from the menu by selecting File>Create Blank Terrain. </p>
<p><br />
<img alt="Image:CreateBlankTerrain.jpg" src="images/CreateBlankTerrain.jpg"
border="0" /> </p>
<p><br />After you click the menu entry, a Create New Terrain Dialog will appear. </p>
<p><br />
<img alt="Image:NewTerrainDialog.jpg" src="images/NewTerrainDialog.jpg"
border="0" /> </p>
<p><br />The Name field allows you to specify a name for your TerrainBlock. This name will appear in the Scene Tree and can be used to reselect your terrain later for editing. Enter a name for the terrain in the text box, in this example <em>theterrain</em>. </p>
<p><br />The Material for the terrain, that is the texture that will be displayed to depict the ground cover, is selected using a drop-down list. This list is populated by the World builder with all the existing materials created specifically for terrains. </p>
<p><br />
<img alt="Image:TerrainMaterialMenu.jpg" src="images/TerrainMaterialMenu.jpg"
border="0" /> </p>
<p><br />The Resolution that you select from that drop-down list determines the size of the terrain that will be created. The size of the terrain that you choose is largely dependent on the design of your game. You will have to experiment to find the right size that works for each game you create and some combinations of options are not very practical. For example, selecting a terrain size of 256 and using the Noise option will result in a terrain that is so drastically contoured that it will not be of much use.</p>
<p><br />The radio buttons to the right of the Resolution dropdown determine the smoothness of the terrain that is generated. Selecting Flat will create a relatively smooth terrain and selecting Noise will generate a bumpy terrain. </p>
<a name="Creating_a_Flat_Terrain"></a>
<h2> <span class="mw-headline">Creating a Flat Terrain</span></h2>
<p><br />
To create a flat terrain: from the main menu select File > Create Blank Terrain; enter a name; select a material; select a size such as 256; and select the Noise radio button, then click the Create New button. A contoured TerrainBlock will be generated and automatically loaded into the scene. </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/NewTerrainAdded.jpg" class="livethumbnail"><img src="images/NewTerrainAdded.jpg" width="320" height="247" largewidth="640" largeheight="495" /></a><br />
<p><br />
A Flat terrain is a great place to start, but is more suitable for terrains that will remain relatively flat. Using a flat terrain requires you to create all the terrain details yourself using the <a href="../Editors/TerrainEditor.html">Terrain Editor</a>.</p>
<h2> <span class="mw-headline">Creating a Bumpy Terrain</span></h2>
<p><br />To create a bumpy terrain: from the main menu select File>Create Blank Terrain; enter a name; select a material; select a larger size such as 1024; and select the Noise radio button, then click the Create New button. </p>
<p><br />
<img alt="Image:CreateNoisyTerrain.jpg" src="images/CreateNoisyTerrain.jpg"
border="0" /> </p>
<p><br />TerrainBlock loaded into the scene. A contoured extremely mountainous terrain will be generated and automatically loaded into your scene. The noise algorithm randomly generated the hills and valleys for you. </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/NoisyTerrainAdded.jpg" class="livethumbnail"><img src="images/NoisyTerrainAdded.jpg" width="320" height="247" largewidth="640" largeheight="495" /></a><br />
<p><br />
Starting with a contoured terrain this is a decent method of starting from scratch with a little randomness thrown in. </p>
<br />
<a name="Add_Existing_Terrain_File" id="Add_Existing_Terrain_File"></a>
<h2> <span class="mw-headline">Adding an Existing Terrain File</span></h2>
<p>To add an existing terrain file to a level start by selecting the Object Editor tool. Locate your Library panel and click it. Click on the Level tab then select the Environment folder. Once that is open, locate the TerrainBlock entry, and double-click it. </p>
<p><img alt="Image:LibraryTerrainBlock.jpg" src="images/LibraryTerrainBlock.jpg"
border="0" /> </p>
<p><br />The new terrain dialog will open. </p>
<p><img alt="Image:LoadTerrainDialog.jpg" src="images/LoadTerrainDialog.jpg"
border="0" /> </p>
<p><br />The Object Name field allows you to specify a name for your TerrainBlock. This name will appear in the Scene Tree and can be used to reselect your terrain later for editing. Enter a name for the terrain in the text box, in this example <em>theterrain</em>.</p>
<p><br />The Terrain file box indicates the information file which holds the data describing the terrain to be loaded. Clicking the box loads the OS file browser.</p>
<p><br />Terrain files are named with a .ter extension. The .ter file type is a proprietary format that contains terrain data understood by Torque 3D. Locating a .ter file then clicking Open/OK will cause it to be selected as the Terrain file to be loaded. </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/OpenTerFile.jpg" class="livethumbnail"><img src="images/OpenTerFile.jpg" width="314" height="239" largewidth="628" largeheight="478" /></a><br /><br />
Leave the square size in the dialog set to its default value then click OK. The .ter file will be immediately imported into your scene with both geometry and textures. The sample shown here is a very simple and low detailed terrain file. </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/TerFileAdded.jpg" class="livethumbnail"><img src="images/TerFileAdded.jpg" width="320" height="247" largewidth="640" largeheight="495" /></a><br />
<a name="Heightmap.2C_Opacity_Layer.2C_Terrain_Textures" id="Heightmap.2C_Opacity_Layer.2C_Terrain_Textures"></a>
<h2> <span class="mw-headline">Importing a Terrain</span></h2>
<p>The most recommended and effective method to add a TerrainBlock to a level is to import the terrain from external data files. However, this method requires the skill and the third-party tools to create those data files. Very high-quality and professional-looking terrain can be created with tools such as <a href="http://www.garagegames.com/products/l3dt" class="external">L3DT</a> and <a href="http://www.geocontrol2.com/e_index.htm" class="external">GeoControl</a>. These tools allow you to generate extremely detailed heightmaps that can be imported by Torque 3D and to generate terrain data. </p>
<p><br />
There are several types of asset required to import and use a terrain in Torque 3D using this method: (1) a heightmap, (2) an opacity map and layers, and (3) texture files.</p>
<h3>Heightmaps</h3>
<p><br />
The primary asset required is a heightmap. A heightmap is a standard image file which is used to store elevation data rather than a visible picture. This elevation data is then rendered in 3D by the Torque engine to depict the terrain. The heightmap itself needs to be in a 16-bit greyscale image format, the size of which is a power of two, and must be square. The lighter an area of a heightmap is, the higher the elevation will be in that terrain location. </p>
<p><br />
<b>Example Heightmap</b> </p>
<p><img alt="Image:HeightMapExample.jpg" src="images/HeightMapExample.jpg" border="0" width="256" height="256" /> </p>
<h3>Opacity Maps</h3>
<p><br />An opacity map acts as a mask, which is designed to assign opacity layers. Opacity layers need to match the dimensions of the heightmap. For example, a 512x512 heightmap can only use a 512x512 opacity map. </p>
<p><br />
If the opacity map is a RGBA image, four opacity layers will be used for the detailing (one for each channel). If you use an 8-bit greyscale image, only a single channel. You can then assign materials to the layers. This allows us to have up to 255 layers with a single ID texture map, saving memory which we can apply to more painting resolution. </p>
<p><br />
Notice that the following example Opacity Map resembles the original heightmap. </p>
<p><br />
<b>Example Opacity Map</b> </p>
<p><img alt="Image:ExampleOpacityMask.jpg" src="images/ExampleOpacityMask.jpg" border="0" width="256" height="256" /> </p>
<h3>Texture Files</h3>
<p><br />Texture files "paint" the terrain giving it the appearance of real ground materials. When creating a terrain from scratch textures can be manually applied to it using the Terrain Painter, which is built into the World Editor, but that is a time and effort intensive method. Instead of hand painting them, the opacity layer will automatically assign textures to the terrain based upon what channel they are loaded into. </p>
<p><br />
For each type of terrain to be rendered you will want to have three textures: (1) a base texture, also referred to as a diffuse texture, (2) a normal map, and (3) a detail mask. </p>
<p><br />
<b>Diffuse</b> </p>
<p><img alt="Image:ExampleBaseTex.jpg" src="images/ExampleBaseTex.jpg" border="0" width="256" height="256" /> </p>
<p><br />
<b>Normal</b> </p>
<p><img alt="Image:ExampleNormalMap.jpg" src="images/ExampleNormalMap.jpg" border="0" width="265" height="265" /> </p>
<p><br />
<b>Detail</b> </p>
<p><img alt="Image:ExampleDetailTex.jpg" src="images/ExampleDetailTex.jpg" border="0" width="256" height="256" /> </p>
<p><br />The base represents the color and flat detail of the texture. The normal map is used to render the bumpiness or depth of the texture, even though the image itself is physically flat. Finally, the detail map provides up-close detail, but it absorbs most of the colors of the base map. </p>
<a name="Importing_A_Heightmap" id="Importing_A_Heightmap"></a>
<h2> <span class="mw-headline">Importing a Heightmap</span></h2>
<p> To import a heightmap for terrain start the World Editor, then from the menu select File > Import Terrain Heightmap: </p>
<p><br />
<img alt="Image:ImportTerrainHeightmap.jpg"
src="images/ImportTerrainHeightmap.jpg" border="0" /> </p>
<p><br />
The Import Terrain heightmap dialog will appear. </p>
<p><br />
<img alt="Image:ImportHeightMapDialog.jpg" src="images/ImportHeightMapDialog.jpg"
border="0" /> </p>
<p><br />
<b>Name:</b> If you specify the name of an existing TerrainBlock in the dialog it will update that existing TerrainBlock and its associated .ter file. Otherwise, a new TerrainBlock will be created. </p>
<p><br />
<b>Meters Per Pixel:</b> What was the TerrainBlock SquareSize (meters per pixel of the heightmap), which is a floating point value. It does not require power of 2 values. </p>
<p><br />
<b>Height Scale:</b> The height in meters that you want pure white areas of the heightmap to
present. </p>
<p><br />
<b>Height Map Image:</b> File path and name of a .png or .bmp file which is the heightmap itself. Remember, this needs to be a 16-bit greyscale image, the size of which is a power of two, and it must be square. </p>
<p><br />
<b>Texture Map:</b> This list specifies the opacity layers, which need to match the dimensions of the heightmap image. If you add an RGBA image it will add 4 opacity layers to the list, one for each channel. If you add an 8-bit greyscale image, it will be added as a single channel.You can then assign materials to the layers. If you do not add any layers
or do not add materials to the layers, the terrain will be created with just the Warning Material texture. </p>
<p><br />
Click the browse button to the right of the Height Map Image box to open a file browser dialog. Navigate to where your terrain files are located, select the desired heightmap PNG file, then click Open. The selected heightmap file will be entered in the Height Map Image box.</p>
<p><i>(click to enlarge)</i> </p>
<a href="images/ChooseHeightmap.jpg" class="livethumbnail"><img src="images/ChooseHeightmap.jpg" width="313" height="239" largewidth="627" largeheight="479" /></a><br /><p><br />
Click on the + button next to Texture Map to open
another file browser. This is where you add opacity
layers. Start by locating the masks. If you have the right assets, it should resemble something like this: </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/ChoosePrairieMask.jpg" class="livethumbnail"><img src="images/ChoosePrairieMask.jpg" width="313" height="239" largewidth="627" largeheight="479" /></a><br />
<p><br />
Do not worry if you do not see the detail. The mask is
supposed to be solid white. Repeat the process until you have imported all your opacity layers.</p>
<p><br />
Now that our opacity layers have been added, you should assign a material to each one. You can do so by clicking on one of the layers, then clicking
the edit button in the bottom right. You will now see the Terrain
Materials Editor. </p>
<p><br />
<img alt="Image: TerrainMaterialEditor.jpg"
src="images/TerrainMaterialEditor.jpg" border="0" /> </p>
<p><br />Click the New button, found at the top next to the garbage bin, to add a new material. Type in a name then click the Edit button next to the Diffuse preview box. Again, a file browser will pop up allowing you to open the base texture file for the material. Alternatively, you can click the preview box itself, which is a checkerboard image until you add a texture.</p>
<p><i>(click to enlarge)</i> </p>
<a href="images/ChoosePrairieBase.jpg" class="livethumbnail"><img src="images/ChoosePrairieBase.jpg" width="314" height="239" largewidth="628" largeheight="479" /></a><br />
<p><br />Once you have added the base texture, the preview box will update to show you what you opened. Set the Diffuse size which controls the physical size in meters of the base texture.</p>
<p><br />Click on the Edit button next to the Detail Preview box. Using the file browser, load the detail map. </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/ChoosePrairieDetail.jpg" class="livethumbnail"><img src="images/ChoosePrairieDetail.jpg" width="314" height="239" largewidth="628" largeheight="479" /></a><br />
<p><br />Next, click on the Edit button next to the Normal Preview box. Use the file browser to open the normal map. </p>
<p>(<i>click to enlarge)</i> </p>
<a href="images/ChoosePrairieNormal.jpg" class="livethumbnail"><img src="images/ChoosePrairieNormal.jpg" width="314" height="239" largewidth="628" largeheight="479" /></a><br />
<p><br />Your final material properties should look like the following: </p>
<p><br />
<img alt="Image:FinalPrairieMaterials.jpg" src="images/FinalPrairieMaterials.jpg"
border="0" /> </p>
<p><br />
<br />Repeat this process until each opacity layer has a material assigned to it. Back in the Import Terrain Height Map dialog, click on the import button. It will take a few moments for Torque 3D to generate the terrain data from our various assets. When the import process is complete, the new TerrainBlock will be added to your scene (you might need to move your camera back to see it). </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/HeightmapTerrainAdded.jpg" class="livethumbnail"><img src="images/HeightmapTerrainAdded.jpg" width="320" height="247" largewidth="640" largeheight="495" /></a><br />
<p><br />
If you zoom in close to where materials overlap, you can notice the high quality detail and smooth blending that occurs. </p>
<p><i>(click to enlarge)</i> </p>
<a href="images/DetailBlending.jpg" class="livethumbnail"><img src="images/DetailBlending.jpg" width="516" height="397" largewidth="1032" largeheight="795" /></a><br />
<p><br />
<br />
</p>
<a name="TerrainBlock_Properties" id="TerrainBlock_Properties"></a>
<h2> <span class="mw-headline">TerrainBlock Properties</span></h2><br />
<p><br />A TerrainBlock has properties which can be set like any other object using the Object Editor. Clicking a TerrainBlock in the scene or selecting it from the Scene Tree will update the Inspector pane with information about it. TerrainBlocks have their own unique set of properties. Hover over a section of the image below for a description of the properties in that section:</p>
<img src="images/TBName.jpg" border="0"
onmouseover="Tip('<strong>name</strong>: <i>TypeName</i>. Optional global name of this object.<br><br><strong>id</strong> : <i>TypeCaseString</i>. SimObjectId of this object. Read Only.<br><br><strong>Source Class</strong> : <i>TypeCaseString</i>. Source code class of this object. Read Only.', WIDTH, 450)"
onmouseout="UnTip()" > <br />
<img src="images/TBTransform.jpg" border="0"
onmouseover="Tip('<strong>position</strong>: <i>MatrixPosition</i>. Object world position.<br><br><strong>rotation</strong> : <i>MatrixOrientation</i>. Object world orientation.<br><br><strong>scale</strong> : <i>Point3F</i>. Object world scale.', WIDTH, 450)"
onmouseout="UnTip()" > <br />
<img src="images/TBMedia.jpg" border="0"
onmouseover="Tip('<strong>terrainFile</strong>: <i>TypeStringFilename</i>. The source terrain data file.', WIDTH, 450)"
onmouseout="UnTip()" > <br />
<img src="images/TBMisc.jpg" border="0"
onmouseover="Tip('<strong>squareSize</strong>: <i>TypeF32</i>. Indicates the spacing between points on the XY plane on the terrain.<br><br><strong>tile</strong> : <i>TypeBool</i>. Toggles infinite tiling of terrain.<br><br><strong>baseTexSize</strong> : <i>TypeS32</i>. Size of base texture size per meter.<br><br><strong>screenError</strong> : <i>TypeS32</i>. Not yet implemented.<br><br><strong>isRenderEnabled</strong>: <i>TypeBool</i>. Only render if true (and if class is render-enabled, too).', WIDTH, 450)"
onmouseout="UnTip()" > <br />
<img src="images/TBSimBase.jpg" border="0"
onmouseover="Tip('<strong>canSaveDynamicFields</strong>: <i>typeBool</i>. True if dynamic fields (added at runtime) should be saved, defaults to true.<br><br><strong>internalName</strong> : <i>TypeString</i>. Non-unique name used by child objects of a group.<br><br><strong>parentGroup</strong> : <i>TypeString</i>. Group object belongs to.', WIDTH, 450)"
onmouseout="UnTip()" /><br />
<img src="images/TBNamespace.jpg" border="0"
onmouseover="Tip('<strong>superClass</strong>: <i>TypeString</i>. Links object to script super class (parent) namespace.<br><br><strong>class</strong>: <i>TypeString</i>. Links object to script class namespace.<br><br><strong>className</strong>: <i>TypeString</i>. Legacy version of class field.<br><br>', WIDTH, 450)"
onmouseout="UnTip()" ><br />
<img src="images/TBDynamic.jpg" border="0"
onmouseover="Tip('<strong>(n/a)</strong>: <i>*</i>. No stock dynamic values.', WIDTH, 450)"
onmouseout="UnTip()" > <br />
This article showed you the three methods available to add a TerrainBlock to your level: creating a blank terrain, adding an existing .ter file, and importing a heightmap. Regardless of which method you use to add the TerrainBlock to a level, you can continue to adjust it using the Terrain Editor and Terrain Painter tools.
</td>
</tr>
</tbody>
</table>