This example demonstrates how to use the vrvControlToolkit to send view control messages to an instance of VR-Vantage.
When running this example, type 'w' (and press enter) into the example's console window and it will send a view control message to Vantage telling it to toggle wireframe mode on or off (the first message enables wireframe, further messages toggle). In order for Vantage to listen and respond to the view control messages, make sure "Listen for View Controls" is checked in the connection's configuration page. Typing 'q' will shut down the example.
Building the Example
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.
Running the Example
This example is an application. You can run it by running ./bin/exampleSendControl<protocol>.exe (on Windows) or ./bin/exampleSendControl<protocol> (on Linux). For more information about running examples, please see Running Applications and Examples.
Example Source Files
sendControl.cxx
#include <vl/dataInter.h>
#include <vrvControl/DtVrlinkDataInterMarshaller.h>
#include <vrvControl/vrvControlToolkitDataTypes.h>
#include <vl/exerciseConn.h>
#include <vl/exConnInit.h>
#include <vlutil/vlKeyboard.h>
using namespace vrvControlToolkit;
DtTime dt = 0.05;
int keyTick()
{
char *keyPtr = DtPollBlockingInputLine();
if (keyPtr && (*keyPtr == 'q' || *keyPtr == 'Q'))
{
return -1;
}
if (keyPtr && (*keyPtr == 'w' || *keyPtr == 'W'))
{
return 1;
}
return 0;
}
int main(int argc, char** argv)
{
bool wireframeState=false;
appInit.parseCmdLine();
DtExerciseConn exConn(appInit);
exConn.setApplicationId(3, 5);
DtTime simTime = 0;
while (true)
{
int key = keyTick();
if (key == -1)
{
break;
}
else if (key == 1)
{
wireframeState=!wireframeState;
DtWireframe_v1 cmd;
cmd.myState=wireframeState;
DtDataInteraction data;
DtVrlinkDataInterMarshaller<DtDataInteraction> marshall;
marshall.encode(&cmd, &data);
#ifdef DtDIS
data.setExerciseId(1);
#endif
exConn.send(data);
}
clock->setSimTime(simTime);
exConn.drainInput();
DtTime sleeptime = ( simTime += dt ) - clock->elapsedRealTime();
DtSleep( sleeptime );
}
}