VR-Vantage API Documentation
exampleHla13Connection

This example shows how to create a very simple application that automatically connects to a HLA1.3 exercise.

The code fragments are from exampleHla13Connection.cxx.

// Step 1: Create the application instance.
// A DtVrvApplication wraps up all the components required to build a complete
// VR-Vantage application (DtDe, DtPluginManager, DtEventLoop, and a
// DtVrvApplicationConfiguration).
DtVrvApplication application;

// Step 2: Initialize the application instance.
// This causes the plugin manager to load plugins, cause a Display Configuration
// to be realized, creates the default environment, etc.
application.initialize(argc, argv);

//Step 3: Create the HLA 1.3 driver.
DtHla13Driver* driver = new DtHla13Driver(application.de().agentManager(), std::string("MyHla13Driver"));

// Step 4: Create the HLA Connection and add it to the HLA driver.
DtExerciseConnInitializer exConnInitializer;
exConnInitializer.setExecName("VR-Link");
exConnInitializer.setFederateType("VR-Vantage HLA 1.3 Driver");
exConnInitializer.setFedFileName("VR-Link.fed");
exConnInitializer.setRprFomVersion(1);
exConnInitializer.setUseAdvisories(true);
exConnInitializer.setUseGeographicDdm(false);
driver->setExerciseSettings(exConnInitializer);

// Step 5: Add the HLA driver to the display engine.
// The driver is now owned by the display engine. Do not delete it.
application.de().driverManager().addDriver(driver);

// Step 6: Start the driver which listens to the HLA network and creates agents.
application.de().driverManager().startDriver(driver);

// Step 7: Creates an event loop and begin running it, causing the creation of frames.
application.run();

Building the Example

VR-Vantage includes pre-built versions of the example application. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.

Running the Example

This example is an application. You can run it by running ./bin/exampleHla13Connection.exe (on Windows) or ./bin/exampleHla13Connection (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


exampleHla13Connection.cxx

/******************************************************************************
* Copyright (c) 2012 MAK Technologies, Inc.
* All rights reserved.
*****************************************************************************/
#include <vrvCore/DtDe.h>
#include <vl/exConnInit.h>
// Use the VR-Vantage namespace. All classes in VR-Vantage are in this namespace.
using namespace makVrv;
int main(int argc,char** argv)
{
// Step 1: Create the application instance.
// A DtVrvApplication wraps up all the components required to build a complete
// VR-Vantage application (DtDe, DtPluginManager, DtEventLoop, and a
// DtVrvApplicationConfiguration).
DtVrvApplication application;
// Step 2: Initialize the application instance.
// This causes the plugin manager to load plugins, cause a Display Configuration
// to be realized, creates the default environment, etc.
application.initialize(argc, argv);
//Step 3: Create the HLA 1.3 driver.
DtHla13Driver* driver = new DtHla13Driver(application.de().agentManager(), std::string("MyHla13Driver"));
// Step 4: Create the HLA Connection and add it to the HLA driver.
DtExerciseConnInitializer exConnInitializer;
exConnInitializer.setExecName("VR-Link");
exConnInitializer.setFederateType("VR-Vantage HLA 1.3 Driver");
exConnInitializer.setFedFileName("VR-Link.fed");
exConnInitializer.setRprFomVersion(1);
exConnInitializer.setUseAdvisories(true);
exConnInitializer.setUseGeographicDdm(false);
driver->setExerciseSettings(exConnInitializer);
// Step 5: Add the HLA driver to the display engine.
// The driver is now owned by the display engine. Do not delete it.
application.de().driverManager().addDriver(driver);
// Step 6: Start the driver which listens to the HLA network and creates agents.
application.de().driverManager().startDriver(driver);
// Step 7: Creates an event loop and begin running it, causing the creation of frames.
application.run();
}


Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)