![]() |
VR-Forces 4.0.4 Class Documentation
|
The Add Attribute example demonstrates the following:
The Add Attribute example adds a new member (mass) to the entity state repository. It also adds encoders and decoders to send/receive that information over the network. When running the example, make sure to copy the VrfExtend.fed to the binHLA13 or binHLA1516 directory. When running in HLA1516, make sure RTI_forceFullCompliance is not on in your rid.mtl and that you're not turning it on using the RTI Assistant. On the command line, add the -x VrfExtend and -F VrfExtend.fed to load the .fed file
Since this example is loaded as a plugin, it can be used in conjunction with the released VR-Forces application
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 with the command line options -x VrfExtend and -F VrfExtend.fed.
To view the new behavior:
The new attribute, 'Mass' will appear under this tab.
/******************************************************************************* ** Copyright (c) 2003 MAK Technologies, Inc. ** All rights reserved. *******************************************************************************/ /******************************************************************************* ** $RCSfile: plugin.cxx,v $ $Revision: 1.4 $ $State: Exp $ *******************************************************************************/ #include "myEsr.h" #include "configFomMap.h" #include "myIndRemNetIf.h" #include "myIndLclNetIf.h" //VR-Forces includes #include "vrfcgf/vrfPluginExtension.h" #include "vrfobjcore/vrfNetIfTypes.h" #include "vrfcgf/cgf.h" #include "vrfcgf/factoryMgr.h" //VR-Link includes #include <vrfExtObjects/vrfEntityPub.h> #include <vl/exerciseConn.h> #include <vrfExtObjects/reflExtEnt.h> extern "C" { DT_VRF_DLL_PLUGIN void DtPluginInformation(DtVrfPluginInformation& info) { info.pluginName = "addAttrSim"; info.pluginDescription = "This is an example of how to add an attribute to the entity repository and publish it on the network. Note that only one plugin can add an attribute."; info.pluginVersion = "1.00"; info.pluginCreator = "MAK Technologies"; info.pluginCreatorEmail = "sales@mak.com"; info.pluginContactWebPage = "www.mak.com"; info.pluginContactMailingAddress = "68 Moulton Street - Cambridge, MA 02138"; info.pluginContactPhone = "(617) 876 8085"; } DT_VRF_DLL_PLUGIN bool DtInitializeVrfPlugin(DtCgf* cgf) { cgf->factoryManager()->objectNetInterfaceFactory()->addCreatorFcn( DtVrfIndividualRemoteEntityNetInterfaceType, MyIndividualRemoteEntityNetInterface::creator); cgf->factoryManager()->objectNetInterfaceFactory()->addCreatorFcn( DtSimIndividualLocalEntityNetInterfaceType, MyIndividualLocalEntityNetInterface::creator); //Call configFomMapper to register functions to handle the new attribute //and parameter. configFomMapper(cgf->exerciseConn()->fomMapper()); return true; } //Need to set the creator here so it does not get overwritten by the default creators at VRF level DT_VRF_DLL_PLUGIN bool DtPostInitializeVrfPlugin(DtCgf* cgf) { //Tell reflected entity and entity publisher that they should create //instances of MyEntityStateRep rather than the base //DtEntityStateRepository to store state of objects. DtReflectedEntity::setStateRepCreator((DtReflectedEntity::DtStateRepCreator)MyEntityStateRep::create); DtEntityPublisher::setStateRepCreator((DtEntityPublisher::DtStateRepCreator)MyEntityStateRep::create); return true; } }