![]() |
VR-Forces Development_Version Class Documentation
|
The DtTerrainInterface class (terrainInterface.h) contains the representation of terrain skin and terrain features.
The terrain skin consists of the geometry of the terrain (typically represented as polygons) and its surface characteristics (that is, soil type). Terrain features include natural and man-made items such as trees, rivers, roads, buildings, and so on. Terrain features are represented as a vector network, comprised of points, lines, and areas.
The DtTerrainInterface class uses a pointer to a DtTerrainImplementation to manage the specifics of how each terrain type operates. The DtTerrainInterface maintains a factory of implementation types and chooses the correct type during the terrain loading process. Additionally DtTerrainPassThroughLayers are also terrain implementations, but they pass the calls to an underlying DtTerrainImplementation. Any number of pass through layers can be added on to of a loaded terrain to modify the terrain implementations.
Additionally after a terrain is loaded the DtTerrainCapabilities can be accessed from the terrain interface. This provide information about the terrain that was loaded.
Loading a terrain using VR-inTerra is a simple process. From the DtTerrainInterface class you call the loadTerrain() method.
Once the terrain is loaded, the interface will handle the inner workings of the terrain type and you can move on to performing intersections and line of sight tests.
By default, DTED files are loaded with their altitude referenced to WGS84. If you want the altitude to reference a different vertical datum (most likely EGM96), you must provide a geoid grid file for that vertical datum. If you use a geoid grid file, the altitudes in the DTED file are adjusted based on the information in the grid file.
To use a geoid grid file, set the environment variable MAK_GEOID_GRID to the path of the file.
For information about EGM96 and geoid file, please see the following URL:
http://earth-info.nga.mil/GandG/wgs84/gravitymod/egm96/egm96.html
The DtTerrainInterface class has an interface that lets you query for information about the terrain data. One of the most common queries made to the terrain database is for a terrain intersection. Terrain intersections can be used in ground entity models to determine how to position and orient simulation objects on the terrain surface.
The following e shows how to query the terrain database for an intersection with the terrain surface, returning the location of the intersection only:
You can make more complex queries to the terrain interface, requesting such information as the list of all intersections a given chord makes with the terrain, surface type information at the point of intersection, and intersections with features in the vector network. For more details about terrain intersections, please see 15.3 - Querying the Terrain Interface.
A DtTerrainInterface has a coordinate system, which defines the origin and type of coordinates being used in the database that was loaded. The Coordinate_System class (coordSystem.h) represents the coordinate system for the database. The Coordinate_System class provides methods for transforming a coordinate between the local coordinate system (the coordinate system used in the database) and the geocentric coordinate system. The derived types of Coordinate_System classes include:
The DtTerrainInterface class has methods for setting and retrieving the coordinate system used in the database. It also has methods for transforming from its current coordinate system to any other coordinate system, performing the necessary transformations on loaded terrain data as appropriate.
Terrain pass through layers can be added to the stack of terrain implementations by calling addTerrainPassThroughLayer() on the DtTerrainInterface class. This will instantiate a new pass through layer on the top of the terrain implementation stack. By doing this you now can intercept terrain calls as they are being made to the terrain implementation and modify them if the need arises.
An example pass through is the DtIntersectTimerPassThroughLayer class. This class times the intersect calls as they are being made and reports the average times when asked.
The following code adds the DtIntersectTimerPassThrough.
When querying for an intersection with the terrain a chord terrain intersection record can be returned. One of the important aspects of this record is the DtSurface, which holds the characteristics of a surface, including its color and the nature of the surface. A DtSurface has the following attributes:
Color is an RGB value associated with the surface. This color is used when drawing the terrain database in a graphical display.
The medium, environmental state, and soil type attributes are represented by a set of enumerated types defined in the DtSurface class. Please see surface.h for the complete set of enumerations.
The DtRoughnessSoilType is a classification of terrain surface that is suitable for use in simulators that need to model the effects of soil type on ground vehicle behavior. It is derived from the soil type parameter. (Soil types are automatically mapped to roughness soil types in the DtSurface class.)
DtSurfaces are stored in a DtSurfaceManager, a member of the DtTerrainInterface. Individual triangles and polygons just hold a reference to a DtSurface in the DtSurfaceManager.
After loading a terrain into the terrain interface the DtTerrainCapabilities class is filled out and available from the DtTerrainInterface::TerrainCapabilities() method. The capabilities class contains a list of key value pairs that describe the pertinent information about the terrain.
The most important item that is found in the terrain capabilities class is whether the terrain supports preloading. This is useful with paged terrains and is discussed later in SynchronousandAsynchronousCallswithPagedTerrains.
One of the import aspects of the terrain interface is to set up the file locations that the interface will use when locating configuration files and terrain data. The DtTerrainFileLocations class can be used before the creation of the DtTerrainInterface class to change the default locations of these files. The terrain subsystem is interested in the following directories:
All of these directories can be referenced in file locations by using , , , and in file names and data files. For example you can load a terrain by specifying .mtf, instead of having to specify the path directly.
The DtTerrainFileLocations class can be used to make the substitutions using the replaceString() or replaceAll() methods.
[<< Introduction to the Terrain API] [Home] [Top of Page] [Querying the Terrain Interface >>]