# hog :: trainz terrain generator

#### user's manual

## requirements.

In order to make the best use out of the terrain generator, you'll need following additional software and data files:

- MICRODEM. a mapping program written by Professor Peter Guth of the Oceanography Department, U.S. Naval Academy.
- any graphics program capable of image cropping and saving 24-bit uncompressed .tga images.
- DEM data files. DEM data for various parts of the globe are available on the 'net; some of it for free. For U.S. DEM data check GIS Data Depot and MapMart.
- optionally, DLG or TIGER data files. Free TIGER data can be obtained from U.S. Census Bureau. DLG data is available at EROS Data Center.

## setup.

The terrain generator can be put in any directory. Make sure there's enough free space for output files -- at least a hundred MBs is a safe margin.

If you're planning to use generator's texturing ability, unpack the content of archive textures.zip located in "presets" sub-folder of the terrain generator, to "... \ World \ Custom \ ground" sub-folder in the root directory of Trainz.

## workflow.

Note: the steps marked bluish-grey are optional. You should follow them only if you intend to use DLG/TIGER data for your route. If that's not the case, just skip them.

1. Launch MICRODEM.

2. Load the DEM data you want to use as source for Trainz layout.[if necessary, for detailed informations how to manipulate DEM data consult MICRODEM help file]

3. For most accurate results:

   - Modify > Display Parameter > Elevation.
   - Modify > Elevation > Colors; in "Elevation Map Options" window select Display colors: Chroma depth colors and check Interpolate within grid.
   - Modify > Grid; in "Grid Options" window set Grid: Neither.
   - Info; in the Information window note "Screen pixel size". The goal is to bring this parameter to 10 m.
   - To do that, close Information window and select Modify > Map area > Zoom In. In the Input Real Number window enter zoom factor, calculated by dividing "Screen Pixel Size" by 10 m.

     For 10 m DEM data instead of above step just select Modify > Map area > 1 : 1 view.

4. Use Analyze > Elevation histograms command. In the "Histogram statistics" window find line describing DEM data "Range". Write down both "Range" numbers.

   Range can be defined in many different units, depending on the source DEM. The unit used [metres, feet, decimeters etc] can be found from other histogram windows. In order to get accurate results from the terrain generator, you'll have to convert Range values to metres.

   feet -> metres: multiply feet by 0.3048
   decims -> metres: divide decims by 10

5. Click right mouse button on generated image and select Copy to clipboard.

6. Launch your graphics program and paste data from the clipboard into a new image.

7. Go back to MICRODEM. Use Overlay > Vector Outlines to add DLG/TIGER data to your terrain image.

   Clicking right mouse button on generated image and selecting TIGER options will invoke window with options you can use to adjust what vector data is displayed, and how. Also, you can remove information about elevation of terrain by selecting Modify > Display Parameter > Blank.

8. Click right mouse button on generated image and select Copy to clipboard.

9. Paste data from the clipboard as new layer.

10. In the graphics program, crop the image to right size -- this is 72×72 pixels per board, plus 2 pixels wide edge around the whole rectangular area you want to generate.

    E.g.: for 10×8 boards area, the image should be (10*72)+4 × (8*72)+4 pixels, i.e. 724×580 pixels big.

11. Cut the vector data layer from the image, and paste it into a separate image.

12. Save your cropped terrain elevation picture to the folder where you have the terrain generator installed, as uncompressed 24-bit .tga image.

13. Save the vector data image to the same folder.

14. Launch Trainz. Create a blank layout and save it under any name you find suitable.

    If possible, try to not use spaces in the layout name.

15. Open the shell [MS-DOS Prompt] window. Navigate to the folder where you have installed the terrain generator. Enter following command:

    HOG source.tga min_range max_range layout

    - source.tga: the name of terrain elevation picture you used in step #12.
    - min_range: the lower of two numbers obtained in step #4, converted to metres.
    - max_range: the higher of two numbers obtained in step #4, converted to metres.
    - layout: optional parameter, the name of your blank Trainz layout.

    To utilize your vector data image, use the following command instead:

    HOG -Mmap.tga source.tga min_range max_range layout

    - map.tga: the name of vector data image you used in step #13.
16. Copy created .gnd file to the folder with your blank route, overwriting the .gnd file which is already there.

    Typically, it's the "... \ World \ Custom \ Maps \ name_of_your_blank_layout" sub-folder in the root directory of Trainz.

Your new layout is now ready to be loaded in Surveyor and edited further.

## advanced functions.

Aside from simple generation of blank .gnd files, the terrain generator is also capable of painting its creations with predefined textures. This ability can be used in a number of ways:

- To paint terrain with basic colours, in accordance with supplied satellite photos.
- To overlay vector data on the layout, not just in the mini map window.
- To cover selected areas of the generated terrain with specified Trainz textures.

While painting, the textures can be randomized -- automatically scaled and rotated to remove the 'tiling' appearance which commonly occurs on hand-painted layouts.

The painting function is invoked with following switch:

-Pguide.tga for painting with randomized textures or:

-pguide.tga for painting without trying to mix the textures.[this option is slightly faster, and can be used when 'painting' vector data, e.g.]

- guide.tga: the name of picture which will serve as guide for terrain painting.

The image used as painting guide should have the same dimensions as the primary terrain elevation picture. While creating terrain, the generator will scan each pixel of the image, and look up the closest matching colour in supplied file textures.txt located in terrain generator directory. It'll then paint corresponding part of terrain with texture linked to that particular colour.

The format of textures.txt is as follows:

userid:kuid red,green,blue
userid:kuid red,green,blue
userid:kuid red,green,blue
...
userid:kuid red,green,blue

For example, entry -12:356 0,255,0 means the parts of terrain corresponding with areas painted pure green [0,255,0] in the painting guide picture, should be textured with default Trainz texture Gravel_1. [the KUID for this particular texture is -12:356 and can be found in Trainz Content Creation Procedures]

A special case is entry beginning with -1:-1 It tells the terrain generator to leave parts of layout painted with this colour untextured.

The default file textures.txt supplied with the terrain generator uses special set of textures prepared to match closely satellite images of Earth. For best results when using those, try the following:

- clean up your satellite images with graphics program. In Adobe Photoshop, you'll usually get good results using HighPass filter with maximum value first, and then Auto Contrast followed by slight adjustments of saturation/brightness/colours. Use supplied sample as a guide.
- convert your true colour image to indexed colour mode, with custom palette matching colours available in terrain generator texture set. If you're using Adobe Photoshop, you can use supplied file hog_default64.act located in "presets" sub-folder of terrain generator.
- after conversion, remember to save the image as 24-bit uncompressed .tga file.

When trying to overlay vector data on the layout, it's better to replace default textures.txt file with hog_tiger.txt located in "presets" sub-folder.[remember to rename it to textures.txt] This particular file is configured to match default colours MICRODEM uses to draw TIGER data, and to leave white areas untextured. [if you use Modify > Display Parameter > Blank command in MICRODEM, it'll display only vector data on white background]

## additional notes.

1. TIGER roads: the roads in TIGER data files are broken up into 7 levels of importance.

   - Major roads: Primary Highway With Limited Access. Interstate highways and some toll highways are in this category (A1) and are distinguished by the presence of interchanges. These highways are accessed by way of ramps and have multiple lanes of traffic. The opposing traffic lanes are divided by a median strip. The TIGER/Line files may depict these opposing traffic lanes as two distinct lines in which case, the road is called separated.
   - Level 2 roads: Primary Road Without Limited Access. This category (A2) includes nationally and regionally important highways that do not have limited access as required by category A1. It consists mainly of US highways, but may include some state highways and county highways that connect cities and larger towns. A road in this category must be hard-surface (concrete or asphalt). It has intersections with other roads, may be divided or undivided, and have multi-lane or single-lane characteristics.
   - Level 3 roads: Secondary and Connecting Road. This category (A3) includes mostly state highways, but may include some county highways that connect smaller towns, subdivisions, and neighborhoods. The roads in this category generally are smaller than roads in Category A2, must be hard-surface (concrete or asphalt), and are usually undivided with single-lane characteristics. These roads usually have a local name along with a route number and intersect with many other roads and driveways.
   - Level 4 roads: Local, Neighborhood, and Rural Road. A road in this category (A4) is used for local traffic and usually has a single lane of traffic in each direction. In an urban area, this is a neighborhood road and street that is not a thorough-fare belonging in categories A2 or A3. In a rural area, this is a short-distance road connecting the smallest towns; the road may or may not have a state or county route number. Scenic park roads, unimproved or unpaved roads, and industrial roads are included in this category. Most roads in the Nation are classified as A4 roads.
   - Level 5 roads: Vehicular Trail. A road in this category (A5) is usable only by four-wheel drive vehicles, is usually a one-lane dirt trail, and is found almost exclusively in very rural areas. Sometimes the road is called a fire road or logging road and may include an abandoned railroad grade where the tracks have been removed. Minor, unpaved roads usable by ordinary cars and trucks belong in category A4, not A5.
   - Level 6 roads: Road with Special Characteristics. This category (A6) includes roads, portions of a road, intersections of a road, or the ends of a road that are parts of the vehicular highway system and have separately identifiable characteristics: (a) Cul-de-sac, the closed end of a road that forms a loop or turn-around (b) Traffic circle, the portion of a road or intersection of roads forming a roundabout (c) Access ramp, the portion of a road that forms a cloverleaf or limited-access interchange (d) Service drive, the road or portion of a road that provides access to businesses, facilities, and rest areas along a limited-access highway; this frontage road may intersect other roads and be named (e) Ferry crossing, the representation of a route over water that connects roads on opposite shores; used by ships carrying automobiles or people.
   - Level 7 roads: Road as Other Thoroughfare. A road in this category (A7) is not part of the vehicular highway system. It is used by bicyclists or pedestrians, and is typically inaccessible to mainstream motor traffic except for private-owner and service vehicles. This category includes foot and hiking trails located on park and forest land, as well as stairs or walkways that follow a road right-of-way and have names similar to road names.