1.11. ADDING RAIL, ROADS, ETC.

This section’s all about using GIS vector data to add roads, rail and trails to the landscape.

We Need:

Since UE4 doesn’t natively support GIS vector data, we’ve developed an editor plugin to provide this functionality.

  • We’re using TerraForm Lite in this tutorial.
  • Alternatively you can use TerraForm Free to import vectors, but you’ll need to do a little more work create roads/rail lines from the splines once you’ve imported them.
Section Video:

Here’s a video showing the processes outlined in this section of the tutorial.

Step 1:

Add the TerraForm Lite plugin to your project.

With the Unreal Editor closed:

  • Create a ‘Plugins’ folder inside your project folder.
  • Unzip the ‘TerraFormLite_V1-0.zip’ folder into the ‘Plugins’ folder.
Step 2:

Enable the ‘TerraForm Lite’ plugin in Unreal Editor.

  • Launch the Unreal Editor
  • ‘Edit’ > ‘Plugins’
  • In the ‘Plugins’ window select ‘Installed’
  • Ensure the ‘Enabled’ check box is ticked on the ‘TerraForm Lite’ plugin.
Step 3:

Give your landscape a geographic reference point.

Once enabled, a new TerraForm panel will appear in the ‘Modes’ section of the Editor.

TerraForm needs to know a little bit of information about your landscape: its origin (the location of the 0,0,0 point in the real world), and its projection/datum. You can either set this manually, or you can set it from the geographical information stored in your heighmap source data. Since we’ve got the source data files, we’ll use that method.

  • Click the button to the right of the ‘Raster File’ field.
  • In the ‘Import’ window that appears, select the 16-bit DTM Geo-Tiff file you used to create the .png heightmap.
  • Click ‘Open’.
  • Click ‘Set Reference’.
  • The ‘Origin X’, ‘Origin Y’, and ‘SRS’ fields will be automatically populated and a ‘TerraFormGeoLocator’ actor will appear in the ‘World Outliner’:
Import Rail Line Vectors:

We’re now ready to import the rail line vectors. The process is the same for roads and trails but with slightly different values and different meshes.

Step 1:

With the ‘Landscape’ actor selected, specify the rail shape file to import:

  • In the ‘Import GIS Data’ section, click the button to the right of the ‘Shape File’ field.
  • In the ‘Import’ window that appears, select the rail .shp file you edited.
  • Click ‘Open’.
Step 2:

Set the ‘Control Point Defaults’ for the spline to be created:

  • The width of the spline mesh is set in the ‘Control Point Defaults’. Rail width (gauge) is ~1.4m in the US. The Procedural Landscape Ecosystem (“PLE”) mesh includes some modelling of sleepers and track ballast, so we’ll set the width of the overall mesh (control point) to 3m (300cm).
  • The ‘Side Falloff’ and ‘End Falloff’ values affect how the spline is blended with the landscape (both in respect of heightmap and any landscape layer mask we add). Because the DTM is relatively accurate and high resolution, we’ll use a small value of 2m either side – TerraForm automatically applies the spline to the landscape’s surface.
  • We want to get rid of any vegetation under the rail lines, so we’ll specify the dirt layer (‘Global_ground_a’) in the ‘Layer Name’ – this will modify the layer masks to reveal ‘Global_ground_a’ layer under the rail lines when we import the file.
  • ‘Raise Terrain’ and ‘Lower Terrain’ should both be checked.
Step 3:

Set the Segment Defaults for the spline to be created:

  • Set the ‘Layer Name’ for the segments (‘Global_ground_a’).
  • ‘Raise Terrain’ and ‘Lower Terrain’ should both be checked.
  • We also want to apply the spline mesh for the rail lines, so click the ‘+’ button to add an ‘Array element’
  • Navigate to the meshes folder in PLE and drag the rail mesh (SM_train_track) into the slot for the mesh.
  • For us, the remaining options are unchanged.
Step 4:

Import the Spline Mesh:

  • Scroll back up to the ‘Import GIS Data’ section of the panel and click ‘Import’.
Step 5:

If you move the camera to ground level and check out the rail spline, you’ll see the landscape needs a little tweaking to accommodate the track.

Modify the ‘Landscape’ actor to blend with the rail spline:

  • Click on the ‘Landscape’ mode icon.
  • Select ‘Manage’.
  • Click on the ‘Selection Tool’ icon to change it to ‘Edit Splines’.
Step 6:

Deform the Landscape to fit the splines you’ve just imported:

  • In ‘Tool Settings’ click ‘All Splines’.
  • The terrain and surface material will be modified to accommodate the spline.
Step 7:

Regenerate the placement of procedural foliage to get rid of any trees on the track:

  • Select ‘Place’ on the ‘Modes’ panel.
  • In the ‘World Outliner’, select the three foliage spawners.
  • Scroll down the ‘Details’ panel and click ‘Resimulate’.

Depending on your system, it might take a little time to resimulate the vegetation to accommodate the new rail line.

Step 8:

You may find that, although the surface texture under the spline has changed to the dirt texture, the grass still remains in places (see above). You can give the PLE grass maps a poke by changing the Landscape material to a different season.

  • Navigate to the landscape materials in PLE.
  • Drag the ‘M_Summer’ material into the landscape’s material slot.

The grass maps will be recreated to fit the new surfaces. Switch it back to ‘M_Spring’ if you like.

Import Road Vectors:

The process is the same for roads as rail but with slightly different values and different meshes, so rather than repeat all the steps, I’ll just show you where the differences are. Note that at present there is no functionality to enhance the intersections or end points of roads. (We’re looking into the soon.)

Step 1:

With the ‘Landscape’ actor selected, specify the road shape file to import:

  • Specify the edited roads .shp file in the ‘Shape File’ field.
  • It’s a single track road mesh so the road is about 600cm wide. Falloff values we used are 300cm.
  • We’re specifying the ‘Global_ground_a’ dirt texture to replace whatever’s currently where the roads will go in both control point and segment defaults.
  • ‘SM_Roads_a’ is the mesh we applied to the segments.
  • Then ‘Import’ the roads vectors as splines...
Step 2:

Modify the Landscape to account for the roads:

  • Go to the ‘Edit Splines’ tool on the ‘Manage’ tab of the ‘Landscape’ mode and click ‘All splines’.
  • In ‘Place’ mode, select all 3 spawners in the ‘World Outliner’ and ‘Resimulate’ the vegetation.
  • Poke the grass maps to regenerate by changing the Landscape material to a different season.
Import Trail Vectors:

Importing trails is similar to roads/rail, so again I’ll just list the differences. The main difference is that we won’t be using a spline mesh for the trails, just using splines to reveal the ‘Global_ground_a’ dirt texture where the splines appear (this feature can have other uses too).

Step 1:

With the Landscape object selected, specify the trails shape file to import:

  • Select the edited trails .shp file in the ‘Shape File’ field.
  • They’re mountain trails so we’ll set them about 150cm wide. Falloff values are 100cm (50cm either side)
  • We’re specifying the ‘Global_ground_a’ dirt texture to replace whatever’s currently where the trails will go in both control point and segment defaults.
  • ‘SM_train_track’ is the mesh we applied to the segments.
  • Because trails normally conform more to the landscape, we’re going to turn off ‘Raise Terrain’and ‘Lower Terrain’ options for both control points and segments.

[NOTE: We’re only specifying a mesh to force the spline to change the landscape’s ground surface layer below the trail – we can remove the mesh (and/or spline) after.]

Step 2:

Modify the landscape to account for the roads:

  • Go to the ‘Edit Splines’ tool on the ‘Manage’ tab of the ‘Landscape’ mode, select all the trails splines, then click ‘Only Selected’ to modify the terran.
  • In ‘Place’ mode, select all 3 spawners in the ‘World Outliner’ and ‘Resimulate’ the vegetation.
  • Poke the grass maps to regenerate by changing the landscape’s material to a different season.
  • Select the trail splines using the ‘Edit Splines’ tool on the ‘Manage’ tab of the ‘Landscape’ mode and delete them (or reset the mesh to ‘None’).

Et voilà!