VR-Forces 5.0.1 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Extent Terrain Implementation (extentTerrainImplementation)

Table of Contents

The Extent Terrain Implementation example demonstrates the following:

Creating a Terrain Implementation

The out of the box VR-Forces terrain loaders can load many types of terrains, but a user may want to create a new terrain implementation to:

To acheive these goals, a user needs to create a new class derived from DtTerrainImplementation, and register it with the DtTerrainInterface's addTerrainImplementation function.

The source and project files for this example are in ./examples/extentTerrainImplementation. A sample MTF file set up to load the new implementation is included in the same directory.

The example creates a new derived DtTerrainImplementation. The new terrain implementation implements a Flat Earth extent at alt = 0.

When actual triangles are needed by B-HAVE, they are generated.

The general process for creating a controller is as follows:

  1. Derive a new class from the appropriate parent class.
  2. Implement the following member functions:
    • loadTerrain(): use this function to load terrain specified in a MTF file.
    • create(): a static function that returns a new instance of the class.
    • chordIntersect(): returns the first terrain intersection from the start of the chord to the end of the chord.
    • allIntersectsAlongChord(): returns all terrain intersections from the start of the chord to the end of the chord.
    • sphereIntersect(): returns whether the given sphere intersects with the terrain.
    • vectorNetwork(): returns a pointer to the vector network, if one exists.
    • intersectVectorNetwork(): returns the first intersection of the chord with the vector network.
    • terrainCapabilities(): returns the capabilities of the given terrain (for example, whether the terrain can "pre-load" geometry based on future predicted entity locations.
    • processTrianglesInArea(): get list of triangles inside "box", call "func" on each of those triangles, then call "finalize".
  3. Configure your entities object parameter databases to make proper use of your component.

Configuring the MTF File

To get the derived terrain implementation to be created, you need to load an MTF file with the appropriate generic record. The "type" for the generic record should be "simTerrain-extent". See the following excerpt from the example MTF:

<myGenericRecords class_id="14" tracking_level="0" version="0"> <count>1</count> <item_version>1</item_version> <Type>simTerrain-extent</Type> <Parameters class_id="5" tracking_level="0" version="0"> <ParameterMap class_id="6" tracking_level="0" version="0"> <count>0</count> <item_version>0</item_version> </ParameterMap> </Parameters> </myGenericRecords>

Look at extentImplementation.mtf for a full mtf file that is set up in this way.

How to Run the Example

Usage

To install the plugin, copy the extentTerrainImplementation.dll into the proper subdirectory /bin64/terrainImplementations/debug or release/ (depending on what is being run). Any dll in this directory will be loaded by the VR-Forces sim and its DtRegisterTerrainImplementation function will be called.

Also copy the extentImplementation.mtf into the /SharedData/.../TerrainData/TerrainConfiguration/ . The .mtf file ships in the example directory.

To run the application:

  1. Start VR-Forces GUI and SIM through the Launcher.
  2. Create a new scenario using extentImplementation.mtf file as the terrain.
  3. The gui will load the Flat Earth world terrain, and the sim engine will load the extent dll.
  4. Place some entities e.g. M1A2 and task the entities to move to location.
  5. Run the scenario.
  6. The entities will all drive around at altitude = 0.

Classes

DtExtentTerrainImplementationThis subclass of DtTerrainImplementation implements a Flat Earth extent at altitude 0.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2011 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/

//Example includes
#include "extentTerrainImplementation.h"

//VRF includes
#include "vrfcgf/vrfPluginExtension.h"
#include "terrainInterface/terrainInterface.h"

extern "C" {

   bool DT_VRF_DLL_PLUGIN DtRegisterTerrainImplementation(DtTerrainInterface* terrainIf)
   {
      //Install the terrain Implementation.
      terrainIf->addTerrainImplementation("simTerrain-extent", DtExtentTerrainImplementation::create);
      return true;
   }

};

Document ID: Generated on Mon Jun 20 00:38:30 EDT 2022 from SVN revision 244029
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)