Protected Member Functions

Detailed Description

The vtTerrain class represents a terrain, which is a part of the surface of the earth.

It is generally described by a set of parameters such as elevation, vegetation, and time of day. These terrain parameters are contained in the class TParams.

To create a new terrain, first construct a vtTerrain and set its parameters with SetParams() or SetParamFile(). You can also set many properties of the terrain directly, which is useful if you want to set them from memory instead of from disk. These include:

Customizing your Terrain

To extend your terrain beyond what is possible with the terrain parameters, you can create a subclass of vtTerrain and implement the method CreateCustomCulture(). Here you can create anything you like, and add it to the terrain. Generally you should add your nodes with AddNode(), or AddNodeToStructGrid() if it is a structure that should be culled in the distance. You can also add your nodes with GetScaledFeatures()->addChild(), if they are 'flat' like GIS features or contour lines, which should be scaled up/down with the vertical exaggeration of the terrain.

How it works

The terrain is implemented with a scene graph with the following structure. When you call SetShadows() or SetFog(), a vtShadow or vtFog node (but not both) may be inserted between the container and the main terrain group.

Adds a node to the terrain. The node will be added to the Structure LOD Grid of the terrain, so it will be culled when it is far from the viewer. This is usually desirable when the models are complicated or there are lot of them.

There is another form of this method which takes a vtGeode node instead.

See Also

AddNode

bool vtTerrain::AddNodeToVegGrid

(

osg::Node *

pNode

)

Adds a node to the terrain. The node will be added to the Vegetation LOD Grid of the terrain, so it will be culled when it is far from the viewer. This method is used by the terrain vegetation methods, and you can also use it directly if you have your own vegetation nodes to add.

Return the center of the bounding sphere that encloses the terrain's dynamic geometry.

bool vtTerrain::GetGeoExtentsFromMetadata

(

)

For this terrain, look at its elevation source, and determine the extents of that data, in geographic coords. This is done without actually doing a full load of the data, to quickly describe the terrain's location on the earth.

Return the heightfield grid for this terrain. During the construction of the terain, this may be a source vtElevationGrid. Later, at runtime, it is likely to be one of the dynamic geometry (CLOD) grids.

Loads an external 3D model as a movable node. The file will be looked for on the Terrain's data path, and wrapped with a vtTransform so that it can be moved.

To add the model to the Terrain's scene graph, use AddModel or AddModelToLodGrid. To plant the model on the terrain, use PlantModel or PlantModelAtPoint.

You should also make sure that your model is displayed at the correct scale. If the units are of the model are not meters, you should scale the correct factor so that it matches the units of the Terrain:

Set the array of colors to be used when automatically generating the terrain texture from the elevation values. This is the color map which is used for automatic generation of texture from elevation, when the terrain is built normally with the "Derived" texture option. The colors brackets go from the lowest elevation value to the highest.

Parameters

colors

A pointer to a colormap. The terrain takes ownership of the ColorMap object so it will be deleted when the terrain is deleted.

This method sets the terrain's color map to a series of white and black bands which indicate elevation contour lines. This is the color map which is used for automatic generation of texture from elevation, when the terrain is built normally with the "Derived" texture option.

You can use this function either before the terrain is built, or afterwards if you intend to re-build the textures.

Given a time value, convert it to the LT (local time) of the center of this terrain from GMT. Local time is defined precisely by longitude, e.g. at noon local time, the sun is exactly halfway across the sky.

Note that this is different that the "standard time" of a given place, which involves finding out what time zone is in effect (complicated!)

Given a time value, convert it from the LT (local time) of the center of this terrain to GMT. Local time is defined precisely by longitude, e.g. at noon local time, the sun is exactly halfway across the sky.

Note that this is different that the "standard time" of a given place, which involves finding out what time zone is in effect (complicated!)

void vtTerrain::UpdateElevation

(

)

If you have told vtTerrain to preserve a copy of the original elevation grid in memory, you can modify that grid, then call this method to update the CLOD surface. This can take up a few seconds, depending on the size of your grid.