Shows how to use an extended FOM and visualizes the new attribute.
N/A
Simulation developers often extend FOMs to add attributes that are not part of the base FOM. They then want to be able to visualize the new attributes in VR-Vantage. This example shows how to create a VR-Vantage plug-in that listens for the new attributes in an extended FOM. It also shows how to configure VR-Vantage to display the new attribute. Additionally, it shows how to extend a visualizer and listener.
The FOM Mapper example is a plug-in that lets VR-Vantage listen to an extended FOM and visualize its new attributes. The plug-in extends several of VR-Vantage's systems.
The simulation connection (VR-Link) drivers (for DIS and HLA protocols) have two subsystems - a visualizer system and a listener system. The listener system consists of listener objects that listen to network traffic and report on entities and interactions. The visualizer system connects to listeners. It creates and controls distributed objects that display models and effects in the scene. Each object or interaction is visualized using state visualizers, each of which is responsible for visualizing a particular effect or component. For example, one visualizer creates and updates the main model of a tank, while another visualizer creates and updates fire effects based on the tank's flame state.
The addAttrHla1516e_64 example adds an attribute called Mass to the FOM. For VR-Vantage to visualize this attribute, it must listen for it and have a visualizer to affect the scene. This example replaces the default entity state listener with a modified entity state listener that contains the additional attributes defined by the extended FOM. This example also adds a new state visualizer class that listens for the new mass attribute and displays the value as a 2D text label that is attached to the object. An extended listener signaler ( MyEntitySignaler ) is added that allows additional signals to be sent from protocol-dependent listeners to protocol-independent visualizers. MyEntitySignalerCreator is registered in place of VR-Vantage's DtListenerSignalerCreator; when protocol-dependent listeners are created they will create the new signaler instead of the default one.
This example has a protocol-independent visualizer - MassLabelVisualizer. MassLabelVisualizer is necessary for configuring model definitions in the GUI. The MassLabelVisualizer connects to the new signals added in MyEntitySignaler.
Because VR-Vantage has many drivers and they may execute in separate threads, it uses a class called an accessory to extend or modify particular drivers. The exampleHla1516eFomMapper plug-in has an accessory class which will only work with HLA 1516e drivers and is responsible for registering the new listener and visualizer classes with the driver's HLA 1516e DtVrlinkConnection object. This allows the connection object to create the newly registered listener rather than the original listener class and also the protocol-dependent visualizer class rather than the protocol-independent version.
The example includes a model definition, MassInfoWidget, which is used to configure the new visualizer, and is merged into the existing model definitions using the command line option –mergeModelDefs. This new model definition has the following attributes:
| backgroundImage | $YOUR_SHARED_DATA_DIR/Overlays/infoBackground.png |
| font | $YOUR_SHARED_DATA_DIR/fonts/mak_mono.ttf |
| fontSize | 11 |
| height | 18 |
| originX | 100 |
| originY | 0 |
| paddingX | 6 |
| paddingY | -1 |
| textAlignment | Left |
| textColor | 0, 0, 0, 255 |
| width | 140 |
To build the exampleHla1516eFomMapper plug-in, follow the instructions in VR-Vantage Developers Guide.
To use the exampleHla1516eFomMapper plug-in:
The startup command must specify the plug-in and the new model definition, as follows (using VR-Vantage):
vrvStealth –plugin ../examples/plugins/release/exampleFomMapperPlugin.dll –mergeModelDefs ../examples/exampleHla1516eFomMapper/MassInfoWidget.ommx
The entity published by addAttrHla1516e_64 will be located on the Ground_DB II terrain. It is recommended that you load this terrain.
A Visual Definition needs to be added to an Entity Element Definition so that the new MassLabelVisualizer will be created when the entity it will be attached to is created. Since the VR-Link example addAttrHla1516e_64 publishes a Land entity with the new Mass attribute, the following shows how to add this Visual Definition to all Land entities in the 2D Model Set.
Close the Visual Model Editors dialog box.
The addAttrHla1516e_64 example should start publishing an entity. VR-Vantage should discover the entity. Double click on the entity in the object list panel to attach to it. A tank should be visible. Change the observer mode to PVD (2D) to the right of the tank there should be a label indicating the entity's mass.
VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.
This example is a plug-in. You can run it by running ./bin64/exampleHla1516eFomMapper_stealth.bat (on Windows) or ./bin64/exampleHla1516eFomMapper_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.