![]() |
VR-Vantage 1.4.1 API Class Documentation
|
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();
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.
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.
// /****************************************************************************** // ** Copyright (c) 2008 MAK Technologies, Inc. // ** All rights reserved. // ******************************************************************************/ // /****************************************************************************** // ** $RCSfile: exampleHla13Connection.cxx,v $ $Revision: 1.13 $ $State: Exp $ // ******************************************************************************/ #include <vrvCore/DtVrvApplication.h> #include <vrvCore/DtDe.h> #include <vrvCore/DtAgentManager.h> #include <vrvCore/DtDriverManager.h> #include <vrvHla13/DtHla13Driver.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(); }