VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Environmental Process Example

Some sample code to demonstrait the usage of Environmental Process Objects in VR-Link.

Environmental Process objects represent things happening in the simulated environment like chemical clouds, chaff, or vapor trails.

Environmental Process Objects are implemented in four main classes

Here is a function which creates and publishes an Environmental Process Object

#include "PointRec.h"
#include "Point2Rec.h"
#include <iostream>
void publishEnvPro(DtExerciseConn *exConn)
{
// Create publishers
// Hold on to its state repository, where we can set data
DtEnvironmentProcessRepository &esr = *pub.epsr();
// Fill in unrealistic sample data
DtEntityIdentifier entId("1:3:1");
envType.setClassOfEnv(1);
envType.setKind(2);
envType.setDomain(3);
envType.setCategory(4);
envType.setSubCategory(5);
envType.setSpecific(6);
envType.setExtra(7);
esr.setEnvironmentType(envType);
int size = (sizeof(Point1GeometryData) - sizeof(DtNetEnvironmentalRecord))*8;
if (esr.setRecordBitSize(0, size) && esr.setRecordBitSize(1, size) &&
esr.setRecordBitSize(2, size))
{
std::cout<< "Setting size was successful" << std::endl;
}
else
{
std::cout<< "Setting size was unsucessfull" << std::endl;
}
for ( int i = 0; i < esr.numberOfEnvironmentalRecords(); i++)
{
rec->myIndex = i;
rec->pos[0] = i*10 + 10;
rec->pos[1] = i*10 + 10;
rec->pos[2] = i*10 + 10;
}
}

Sample code to listen for Environmental Process objects can be found here:

#include <vl/fom.h>
// A callback for when a DtReflectedEnvironmentProcess object is updated.
void printEnvProc(DtReflectedEnvironmentProcess* obj, void* userData)
{
obj->epsr()->printData();
}
// A callback for when a new DtReflectedEnvironmentProcess object is added.
void envProcAddedCb(DtReflectedEnvironmentProcess* obj, void* userData)
{
// register a callback for when an existing object is updated.
obj->addPostUpdateCallback(printEnvProc, userData);
}
// Create a reflected list and register interest in object creation.
void listenEnvProc(DtExerciseConn *exConn)
{
rel.addEnvironmentProcessAdditionCallback(envProcAddedCb, NULL);
}

Document ID: Generated on Mon Feb 6 18:36:34 EST 2017 from SVN revision 173107
Copyright © 2005-2016 VT MÄK. All Rights Reserved (www.mak.com)