VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
6.3 - Terrain Structure

Table of Contents

A terrain (DtTerrain) in VR-Forces is a facade around a set of DtTerrainPatch and DtFeatureLayer objects.

The terrain maintains records of each operation performed on it (such as adding or removing a terrain patch), which are saved and loaded to MTF files. The DtTerrain is not a distributed object, so it exists only on the master display engine. If you are using external display engines, each display engine must have the same terrain files on its local computer.

6.3.1 Terrain Patches

A DtTerrainPatch is a facade around a DtTerrainPatchObject , which is a distributed object that combines the functionality of a model and a scene object. The terrain patch maintains a history of operations performed on it, such as extracting props or adding an overlay image. This history is included when the terrain is saved and executed when it is loaded. Each DtTerrainPatchObject has a model definition that specifies where to find the geometry (typically through the filename parameter) and a coordinate system (through the terrainCoordinateSystem and terrainCoordinateSystemParameters parameters).

Note
The coordinate system of the most recently loaded terrain patch is always used as the coordinate system of the entire scene. In contrast to other scene objects, a DtTerrainPatchObject has no position or orientation, since all other objects in the scene are transformed in its coordinate system. This may cause undesired behavior if multiple terrain patches with different coordinate systems are loaded into the same scene.

Terrain patches are located in the scene graph under the terrain root node. They are included in intersection tests for ground clamping and navigation, but excluded for selection.

6.3.2 Feature Layers

A DtFeatureLayer is a facade around a collection of DtProp objects, which represent distinct terrain-like features such as lampposts and buildings. Feature layers are created in VR-Forces by:

6.3.3 Loading Point Features

VR-Forces provides the convenience class DtPropAdder to load point features from files. The prop adder finds point features that match a rule specified by a DtAddPropsRuleRecord. Then it creates a prop at the location of each point feature, using the model definition specified in the rule. In order for the feature layer to correctly maintain its state, the DtPropAdder should not be used directly. Use the DtFeatureLayer's addProps() method, which makes the correct calls on the DtPropAdder for you. For instance, suppose you wanted to add SpeedTrees at the sites of tree point features in a GDB file. You could:

  1. Add the GDB to the DtTerrain as a feature layer (DtTerrain::addFeatureLayer()).
  2. Create a DtAddPropsRuleRecord that maps a tree type to an appropriate model definition (for example, EC030 to TreesEuropeanWhiteBirchST).
  3. Pass it to the feature layer (DtFeatureLayer::addProps()).

6.3.4 Extracting Geometry

A DtTerrainPatch can find nodes in its scene graph and move them into DtModel objects. The DtModel for each prop must be created in the driver to be distributed to all display engines, but creating them requires knowledge of the scene graph. Therefore, basic prop extraction happens in a multi-step process:

  1. The DtTerrainPatch makes a call to extract nodes out of the scene graph and into a list on each display engine. (The nodes must match a search expression.)
  2. The master display engine signals the DtTerrainPatch with the number of extracted nodes.
  3. The DtTerrainPatch creates that number of props (including DtModels), and passes each model's object ID along with an index back to the display engines.
  4. The display engines create local model instances for each model and move the extracted node with the corresponding index into each one.
  5. The node search expressions check the name, filename, and description fields of each node for a match. They can use either regular expressions or plain search strings.

[<< Models, Model Instances, and Model Definitions ] [Home] [Top of Page] [Environmental Effects and the Lighting Model >>]


Document ID: Generated on Tue Sep 24 19:28:17 EDT 2024 from SVN revision 269799
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)