3D Game Programming All in One (Course Technology PTR Game Development Series)

You've already seen in Chapter 12 how to create a terrain using height maps. Torque also has a built-in Terrain Editor that you can use to manually modify the terrain height map and square properties.

Terrain editing is done using a Terrain brush. The brush is a selection of terrain points centered on the mouse cursor in either a circular or square configuration of different selectable sizes, as you can see in Figure 18.18.

Figure 18.18: Terrain brush.

The brush can also be either a hard brush that has a uniform effect across the surface of the brush or a soft brush whose influence on terrain diminishes toward the edges of the brush. You can adjust the soft brush fall-off rate in the Terrain Editor Settings dialog box, found under the menu Edit, Terrain Editor Settings.

  1. Run your sample game, and when you have spawned into the game, press F8 to switch to fly mode.

  2. Fly up a fair bit to get a good overview of the surrounding terrain.

  3. Press F11 to switch to the Editor GUI.

  4. Choose Window, Terrain Editor.

  5. Wave your cursor over the terrain, and notice the Terrain brush marked on the terrain.

  6. Drag your mouse up and down after clicking over some area of terrain. You will see your terrain change to conform.

  7. Experiment with using different actions to see how the Terrain Editor works.

    Tip

    Every now and then while in the Terrain Editor, press Alt+L to redo the lighting. The cursor will freeze for a few moments while the lighting is done.This will cause the new terrain changes you've made to properly generate shadows.

  8. Every now and then remember to save your work.

Table 18.3 describes the Terrain Editor functions that are available in the Action menu.

Table 18.3: Terrain Editor Functions

Function

Description

Select

Selects grid points that will be painted with the brush.

Adjust Selection

Raises or lowers the currently selected grid points as a group.

Add Dirt

Adds "dirt" to the center of the brush.

Excavate

Removes "dirt" from the center of the brush.

Adjust Height

Drags the brush selection to raise or lower it.

Flatten

Sets the area bounded by the brush surface to be a flat plane.

Smooth

Smoothes, within the bounds of the brush, rough areas of varying terrain height.

Set Height

Sets the terrain within the brush to a constant height as specified in the Terrain Editor settings.

Set Empty

Converts the squares covered by the brush into holes in the terrain.

Clear Empty

Makes the squares covered by the brush solid.

Paint Material

Paints the current terrain texture material with the brush.

Table 18.4 describes the functions of the Terrain Terraform Editor (see also Figure 18.19), the one we used in Chapter 12 dealing with height maps.

Table 18.4: Terrain Terraform Editor Functions

Function

Description

fBm Fractal

Creates bumpy hills.

Rigid Multifractal

Creates ridges and sweeping valleys.

Canyon Fractal

Creates vertical canyon ridges.

Sinus

Creates overlapping sine wave patterns with different frequencies useful for making rolling hills.

Bitmap

Imports an existing 256 by 256 bitmap as a heightfield.

Turbulence

Perturbs another operation on the stack.

Smoothing

Smoothes another operation on the stack.

Smooth Water

Smoothes water.

Smooth Ridges/Valleys

Smoothes an existing operation on edge boundaries.

Filter

Filters an existing operation based on a curve.

Thermal Erosion

Erodes an existing operation using a thermal erosion algorithm.

Hydraulic Erosion

Erodes an existing operation using a hydraulic erosion algorithm.

Blend

Blends two existing operations according to a scale factor and mathematical operator.

Terrain File

Loads an existing terrain file onto the stack.

Figure 18.19: Terrain Terraform Editor.

Категории