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:
-
Open an command line and switch to the VR-Forces "bin" directory.
-
Start the VR-Forces GUI using the command "vrfLauncher –usePredefinedConnection DIS -F"
-
Start simplePlan from the command line as "simplePlanDIS".
-
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 <vl/exerciseConnInitializer.h>
#include <vlutil/vlPrint.h>
#include <vlutil/vlProcessControl.h>
#include <vl/hostStructs.h>
int main(int argc, char *argv[])
{
DtSimulationAddress simAddress(1, 3001);
#if DtDIS
initializer.setDisVersionToSend(7);
#endif
initializer.parseCmdLine();
#if DtDIS
initializer.setSiteId(simAddress.siteId());
initializer.setApplicationNumber(simAddress.applicationId());
#endif
DtExerciseConn* exerciseConn = new DtExerciseConn(initializer);
"../data/simulationModelSets/EntityLevel.sms");
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;
}