VR-Forces 5.0.3 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Add Set (addSetSim)

Table of Contents

The Add Set example creates a new "Set" command that allows a user to set an entity's ordered speed and heading.

When the command is initiated, specified and executed in the front-end by the user, a Set message will be sent to an entity-specific controller in the back-end. The larger architecture of set sommands in the VR Forces back-end is described in Tasks, Sets, Commands, and Reports.

The Add Set back-end example demonstrates the following:

Creating and Registering a New Set Command

The DtSetSpeedAndHeadingRequest class is a child of the DtSetDataRequest class, and is the central object defining a set command in the back-end. The DtSetDataRequest contains the netRepSIze(), the setToNet() and setFromNet() methods used to send and receive set commands from the network. The derived class, DtSetSpeedAndHeadingRequest, contains the central parameters of the set command (mySpeed and myHeading) as well as their accessor and mutator methods. It also contains the creator() static method used by the factory to create the object, which is registered in DtInitializeVrfPlugin (plugin.cxx).

Extending Functionality by Overriding Existing Controllers

The series of new controllers classes in this example, MyHumanSetController, MyLocalEntitySetController, MyFixedWingSetController and MyAirVehicleSetController, are derived from the default set controllers DtHumanSetController, DtLocalEntitySetController, DtFixedWingSetController and DtAirVehicleSetController, respectively. They stand with very minor modifications - a processSpeedAndHeading() method that applies the commanded speed and heading to the proper entity SR, and a setSpeedAndHeadingCallback() that is registered with the DtSetDataManager for callbacks. All of the other methods for processing set commands are inherited and retained from the originating class.

The respective entity-specific default set controllers are overridden in the factory with the new set controllers in DtInitializeVrfPlugin (plugin.cxx).

How to Run the Example

Usage

In the Launcher, click the Plug-ins button to bring up the Plug-ins Selection dialog. Enable the plugin.

To view the new behavior:

  1. Start VR-Forces GUI and SIM.
  2. Create a new scenario - e.g. EntityLevel SMS on Ground_DB II terrain.
  3. Create a lifeform entity (e.g. "US Army M16"). Any ground vehicle, air vehicle, and/or lifeform will work with this example.
  4. Right-click on entity and select the new entry 'Set -> Position -> Speed And Heading...' menu item.
  5. In the 'Speed And Heading' dialog, set the desired heading and ordered speed for the entity.
  6. Click OK to close the dialog. The entity will snap to the new heading.
  7. Give the entity a movement task. It will move at the speed specified in the 'Set Heading and Speed' request.

Please note that "speed" refers to "ordered speed," i.e., the speed at which the entity will travel when it is tasked to move. If the entity does not have a destination or move task, setting "speed" to a non-zero value will not make the entity move.

Classes

DtSetSpeedAndHeadingRequestThe subclass of DtSetDataRequest that is used to communicate the new set request.
MyLocalEntitySetControllerThe subclass of DtLocalEntitySetController that is used to implement the new set command.
MyAirVehicleSetControllerThe subclass of DtAirVehicleSetController that is used to implement the new set command.
MyFixedWingEntitySetControllerThe subclass of DtFixedWingEntitySetController that is used to implement the new set command.
MyHumanSetControllerThe subclass of DtHumanSetController that is used to implement the new set command.

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2010 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
#include "vrfcgf/cgf.h"
using namespace vrfAddSetExample;
extern "C" {
{
info.pluginName = "Add Set Sim";
info.pluginDescription = "Back-end plugin to process new Set Speed and Heading command";
info.pluginVersion = "1.00";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "10 Fawcett Street, Suite 204, Cambridge, MA 02138 USA";
info.pluginContactPhone = "(617) 876 8085";
}
DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
{
return true;
}
}

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)