VR-Forces 4.2 Class Documentation
Add Entity

Table of Contents

The Add Entity example demonstrates the following:

As is noted in the documentation, entities are not distinguished by different object classes; they are all DtVrfObjects. They are distinguished in kind by their member subcomponents and, in particular, by their state repositories. Their behaviors are determined by the actuators, controllers, and sensors specified for them in the object parameters database. They may also have configurable parameters that are specific to their entity type.

Therefore, the key tasks for adding a new entity are to:

This example is a simple model of a space entity. It creates a new type of state repository that makes entity-specific state information (maximum hull temperature) available for inspection or modification in any future simulation components we may create. It creates a parameter class so that we can configure the maximum hull temperature in the object parameters database. The example does not add any new behaviors.

Creating a New State Repository Class

This example creates a new state repository class, DtSpaceEntityStateRepository, which is derived from DtVrfMovingObjectStateRepository. Since a space vehicle is a moving object (as opposed to a control object), the DtVrfMovingObjectStateRepository class is the most appropriate class to derive from. All of the other platform-level entities supplied by MAK derive from this class as well. By deriving from DtVrfMovingObjectStateRepository, we inherit such concepts as mass, maximum speed, and fuel efficiency. In our derived class we will add to these a parameter specifying maximum hull temperature.

When creating a scenario that uses this example, it is important that simulation model set data corresponding to the new entity is accessed by the simulation. One way to ensure this during runtime is to open the "Scenario Settings..." section and select data/simulationModelSets/developer_toolkit_examples/addEntity.sms as an "additional SMS file". If you make it the default sms file, you will not be able to create any other entities. Of course, if the new entity were desired to be integrated into the default simulation software, the information in the addEntity SMS directory could be integrated into the default SMS file structure.

Classes

DtSpaceEntityStateRepository Subclasses DtVrfMovingObjectStateRepository to store new variables and save them into the order of battle file.
DtSpaceEntityParameters Subclasses DtMovingObjectParameters that is used to introduce new parameters for the space entity.

Adding the New State Repository and Parameters to VR-Forces

Now that the new state repository and parameter classes for the space entity have been implemented, they must be added to our VR-Forces application. This is done by registering the creator functions of the new classes with the factory. The following code fragment is from the plugin.cxx supplied as part of the addEntity example. To add the new classes, we add calls to the Object Parameters Factory and the Object State Repository Factory after initialization of the VR-Forces application, but before the application's main loop begins:

app->cgf()->factoryManager()->objectParameterFactory()->addCreatorFcn(DtSpaceVehicleParamType, DtSpaceEntityParameters::creator);
app->cgf()->factoryManager()->objectStateRepositoryFactory()-> addCreatorFcn(DtSpaceVehicleSRType, DtSpaceEntityStateRepository::creator);

Editing the Object Parameters Database

The final step in adding this new entity is to create an entry in the object parameters database The process of editing the object parameters database is described in detail in "The Object Parameters Database" in the VR-Forces Configuration Guide. The addEntity example edits the standard object parameters database and renames it addEntity.opd. It also adds a .ope file for the space entity, which specifies that our new state repository and parameter classes should be configured for entities of object type 1 (5, 1, 225, 1, 1, 1, 1) (a generic space platform entity):

(space-entity
   (parameter-type "space-param")
   (object-type 1 (5 1 225 1 1 1 1))
   (category "Space")
   (dr-algorithm Rvw)
   (max-speed 7500.000000)
   (max-hull-temperature 1500)
   (local-objects
      (state-repository "space-vehicle-state-repository")
      (net-interface "individual-local-entity-net-interface")
      (task-manager "local-task-manager")
      (radio "channel-radio")
      (component-manager "component-manager")
   )
   (remote-objects
      (state-repository "space-vehicle-state-repository")
      (net-interface "individual-remote-entity-net-interface")
      (task-manager "")
      (radio "")
      (component-manager "")
   )
...
)

Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application. Please note that you must add a corresponding entry in vrf.ent if you want to create this object using the VR-Forces GUI.

Usage

Select Settings, Plugins... and on the Plugins Editor page, use the combo box at the top of the page to select the plug-in. Then enable the Load Plugin checkbox and re-start VR-Forces. When you create a scenario uaing the new entity, open the "Scenario Settings..." section and select data/simulationModelSets/developer_toolkit_examples/addEntity.sms as an "additional SMS file".

Plugin Entry Points

/*******************************************************************************
** Copyright (c) 2003 MAK Technologies, Inc.
** All rights reserved.
*******************************************************************************/
/*******************************************************************************
** $RCSfile: plugin.cxx,v $ $Revision: 1.4 $ $State: Exp $
*******************************************************************************/
#include "spacePar.h"
#include "spaceSR.h"
#include "spaceTypes.h"
#include "vrfcgf/cgf.h"
extern "C" {
{
info.pluginName = "Add Entity";
info.pluginVersion = "1.00";
info.pluginDescription = "An example of how to add a new type of entity.";
info.pluginCreator = "MAK Technologies";
info.pluginCreatorEmail = "sales@mak.com";
info.pluginContactWebPage = "www.mak.com";
info.pluginContactMailingAddress = "150 Cambridge Park Drive 3rd Floor - Cambridge, MA 02140 USA";
info.pluginContactPhone = "(617) 876 8085";
}
DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf)
{
return true;
}
}

Document ID: Generated on Sun Nov 24 19:49:21 EST 2013 from SVN revision 133924
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)