[[File:PROP18.png|thumb|250px|[[Propagation Module]]'s Terrain Generator dialog]]
Â
[[EM.Cube]] provides a convenient and powerful Terrain Generator for creating a variety of terrain [[Surface Objects|surface objects]]. [[EM.Cube]]'s Terrain Generator looks very similar to [[CubeCAD]]'s Surface Generator. However, whereas the Surface Generator creates a generic or polymesh surface object, Terrain Generator always creates another special type of object known as a '''Tessellated Object'''. A terrain object is much simpler than [[EM.Cube]]'s polymesh objects and is usually made up of triangular or quadrilateral facets. As such, terrain objects have limited editing capabilities. For example, you can cut, copy, paste, translate or rotate terrain objects. But operations like scaling, mirroring, grouping (composite), arraying, exploding, linking or Boolean operations do not work on terrain objects.
Â
To create a new terrain object using Terrain Generator, first you need to define a terrain group in the Navigation Tree. Right click on the name of the terrain node and select '''Terrain Generator...''' from the contextual menu. This opens up the Terrain Generator Dialog. Using Terrain Generator, you can build a single terrain surface or an array of surfaces patched together. Some of the available terrain models include:
Â
# Flat Plane
# Hill (Elliptic Quadratic)
# Mountain (Elliptic Cone)
# 1-D and 2-D Cliff
# Gaussian Hump
# Undulated Sinusoid
# Undulated Sinc
# Super-quadratic Plateau
# Custom Function
# XY Grid Data
Â
In all of the above models, you can set the height of the surface object to an any desired value. You set the lateral extents of the surface and its resolution along the X and Y directions in the boxes labeled '''Range Start''', '''Range Stop''' and '''Range Step'''. The step values along the X and Y directions are a measure of surface smoothness: the smaller the step values, the higher the resolution and the smoother the resulting terrain object.
Â
Some surface types have an additional shape factor called '''Alpha''' that is identical to the alpha parameter in the surface generator. For example, a Gaussian Hump is defined as exp(-r<sup>2</sup>/(2a<sup>2</sup>)), where r is the polar radius. For a Super-quadratic Hump, the input parameter a defines the degree of the super-quadratic surface. a = 2 corresponds to an ellipsoid. Larger values of a get close to a rectangular base with rounded corners. An undulated sinusoidal surface is defined by cos(pax/D<sub>x</sub>)*cos(pay/D<sub>y</sub>), and an undulated sinc is defined by D<sub>x</sub>*D<sub>y</sub>*sin(pax/D<sub>x</sub>)*sin(pay/D<sub>x</sub>)/(2pxy), where D<sub>x</sub> and D<sub>y</sub> are the X and Y dimensions, respectively. Terrain Generator creates a unit cell based on the specified surface type. From the same dialog, you can also produce an array arrangement of such unit cells. Simply enter any number of elements along the X and Y directions in the boxes labeled '''Array'''.
Â
[[File:PROP19.png|800px]]
Â
Figure: A 4 Ã 4 array of hill terrain objects.
Â
You can define any arbitrary surface by entering an equation of the two [[variables]] x and y as z = f(x,y). In this case, you have to select the '''Custom Function''' option in the dropdown list labeled '''Model'''. You should enter your equation as any mathematical expression in the box labeled '''Function f(x,y)'''. You can use any of EM.Cube's mathematical functions listed in the '''Function Dialog''' or combine several of them. Note that after selecting the custom function option, the height of the surface is determined by your equation, and the '''Height''' box is disabled. You can also introduce random noise and create a rough terrain. You can do this by setting a nonzero value for '''Noise''', which represent the RMS peak-to-valley amplitude of the surface roughness. The figures below show two custom terrain surfaces modeled by the equation z = (x.y)/20 defined over the range [0, 10] in both X and Y directions. Random noise has been added to both surfaces, with the noise amplitude being 0.2 and 0.5 for the left and right figures, respectively.
Â
[[File:PROP21.png|400px]] [[File:PROP20.png|400px]]
Â
Figure: Two noisy custom terrain surfaces both defined as z = (x.y)/20: (Left) RMS noise amplitude = 0.2, (right) RMS noise amplitude = 0.5.
=== Generating Grid-Based Terrain ===
Every time you create a new terrain object [[using Terrain Generator]], an ASCII data file named "GeneratedTerrain" with a "'''.TRN'''" file extension is created and placed in your project folder. This is [[EM.Cube]]'s simple native terrain file format that basically lists all the (x, y, z) coordinates of the generated surface points on a horizontal, rectangular XY grid. Terrain Generator simply takes your custom function definition or one of the selected catalog surface types and generates the digital elevation data on the specified grid.
Another type of terrain model that the terrain generator provides is '''XY Grid Data'''. In this case, you define a rectangular XY grid with a uniform grid cell size along the X and Y directions and manually define the Z-elevation for each grid point. This is similar to the surface generator's "2D Uniform Grid" model type in [[CubeCAD]]. Based on your input to '''Range Start''', '''Range Stop''' and '''Range Step''' along X and Y, a 2D grid is set up and displayed in a table at the bottom of the terrain generator dialog. By default, all the Z-elevations are set to zero initially. You can click on each table cell and overwrite it with a new value. At the end, click the '''Create''' button of the dialog to add the new grid-based terrain object to the Navigation Tree.