The Create Parameter Database Dynamically example adds a number of entries to the parameter database without initially reading the vrfSim.opd file. It will then create entities and assign them a task based on those entries to show they have been created successfully. This example can be used as a starting point for populating the parameter database with entries not defined in the vrfSim.opd file or from another source other than the vrfSim.opd file.
This example demonstrates how to programmatically create a parameter database and use it in a standalone CGF application.
A platoon consisting of 4 tanks will move to a waypoint in column formation.
#ifdef WIN32
#include <winsock2.h>
#include <windows.h>
#endif
#include <vl/exerciseConn.h>
#include <vlutil/vlPrint.h>
#include <vlutil/vlProcessControl.h>
#include <vl/hostStructs.h>
int main(int argc, char *argv[])
{
DtSimulationAddress simAddress(1, 3005);
#if DtHLA
double rprFomVersion = 1.0;
DtExerciseConn* exerciseConn = new DtExerciseConn(execName, federateName,
new DtRprFomMapper(rprFomVersion));
#else //DIS
int port = 3923;
int exerciseId = 1;
DtExerciseConn* exerciseConn = new DtExerciseConn(port, exerciseId,
simAddress.siteId(), simAddress.applicationId());
#endif
cgf->
init(exerciseConn, &creator);
cgf->
newScenario(
"../data/terrain/Ground-db/Cgf/Ground-db.gdb");
parameterDb->
add(platoonParameters->
objectType(), platoonParameters);
parameterDb->
add(waypointParameters->
objectType(), waypointParameters);
parameterDb->
add(routeParameters->
objectType(), routeParameters);
forceLevelAggregateParameters);
DtVector initialPosition(900.0, 900.0, 0.0);
DtReal initialHeading = 0.0;
bool createSubordinates = true;
DtForceFriendly,
DtVector(1100.0, 1100.0, 0.0), initialHeading,
createSubordinates);
int counter;
for(counter = 0; counter < 2; counter++)
{
}
"Alpha");
bool assignedTask = false;
while (1)
{
if(!assignedTask)
{
assignedTask = true;
}
if (keyPtr && *keyPtr == 'q')
{
break;
}
DtSleep(0.01);
}
delete cgf;
delete exerciseConn;
return 0;
}