The Simple Plan example demonstrates the following:
- How to create a CGF
- How to create objects within this CGF
- How to assign a plan to these objects within the CGF
A CGF application differs from the released back-end in that there is not command line options applied to it and it is intended to be used as part of a larger back-end application that does not have a need to interface with the VR-Forces front-end.
How to Run the Example
This example demonstrates how to programatically create a plan for an entity in an embedded CGF application (outside of the context of the vrfSim application).
Usage
(Release) simplePlan
(Debug) simplePland
To run the application:
-
Start vrfGui on port 3000
-
Open the data\terrain\ground-db.mtd terrain database.
-
Start simplePlan from the /vrforces/bin/ directory.
-
Right-click on the entity to view its plan.
Note you will need to join the session or you cannot view the entity's plan.
The simplePlan application simulates a tank with a plan. You can observe the execution of the plan in the entity's 'View Plan' window.
Main Application File
#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, 3001);
#if DtHLA
double rprFomVersion = 1.0;
DtExerciseConn* exerciseConn = new DtExerciseConn(execName, federateName,
new DtRprFomMapper(rprFomVersion));
#else //DIS
int port = 3000;
int exerciseId = 1;
DtExerciseConn* exerciseConn = new DtExerciseConn(port, exerciseId,
simAddress.siteId(), simAddress.applicationId());
#endif
cgf->
newScenario(
"../userData/terrains/Ground-db.mtf");
DtEntityType tankType(1, 1, 225, 1, 1, 3, 0);
DtVector initialPosition(900.0, 900.0, 0.0);
DtReal initialHeading = 0.0;
tankType,
DtForceFriendly,
initialPosition,
initialHeading);
DtList verticies;
verticies.add((void*)&v1);
verticies.add((void*)&v2);
verticies.add((void*)&v3);
verticies.add((void*)&v4);
"Alpha");
"Beta");
moveToAlphaStatement.
setTask(&moveToAlphaTask);
moveToBetaStatement.
setTask(&moveToBetaTask);
createEvaluator(conditionalExpression.
type()));
while (1)
{
if (keyPtr && *keyPtr == 'q')
{
break;
}
DtSleep(0.01);
}
delete cgf;
delete exerciseConn;
return 0;
}