![]() |
VR-Vantage 2.5 API Documentation
|
This example explains what an agent is and how to create and use one. The application creates a geometry (cube), adds the geometry to the scene and rotates it. Of particular interest in this tutorial is the use of agents to load and manage the geometry.
VR-Vantage uses agents to create and synchronize scene objects among all display engines in the configuration. The master creates and owns agents which causes scene objects to be created locally and simultainiously sends messages to the distributed systems to manage their own copies of the same scene object. Agents in VR-Vantage take the same name as the objects they manage with the added suffix 'Agent'. Because agents are used to send messages to distributed system (and not receive back replies), they are one-way communication objects. Their APIs expose the write-only interface of the objects they manage.
This example shows how to create an agent for an object and create an instance of the agent in a driver. DtDriver objects registered with the display engine have the benefit of being called when the simulation starts, when the simulation stops, and every simulation time-update at regular intervals.
The custom DtDriver in this application creates a new agent object, MyObjectAgent when the simulation starts (in its 'onStart()' function), and destroys the object when the simulation stops (in its 'onStop()' function). During the simulation time-updates, the custom DtDriver's onTick() function is called, where it updates the geometry. For more information on Drivers see The Driver Layer.
The agent classes are generated by the Distributed Code Generator(dcgen) using an ocdx file. An ocdx file specifies the object structure which is constructed on each system by the agent in a distributed simulation environment.
The setupTree script automatically finds the ocdx files and generates the agent classes for you during the build. However if you wish to generate these files manually, the following description gives more information on how to do it.
To generate the agent classes using dcgen interface as follows:
To generate the agent classes from command line as follows:
Then give the following command :
./dcgen.exe -a -S "path_to_source_file_directory" -H "path_to_header_output_directory" -A "path_to_relative_include_directory" "path_to_ocdx_file"
where
-a : Generate all of the classes.
-S : The directory to write source files to.
-H : The directory to write header files to.
-A : The root directory that generated include statements are relative to.
We create a distributed object, MyObject, that loads the geometry and rotates it using an agent.
The object is defined as follows:Derived from a DtDriver is a custom driver used to load and manipulate the geometry.
When the custom DtDriver is notified that the simulation is starting it creates a new agent object and loads the geometry.
During the running simulation, drivers get ticked every frame. In our driver's tick method, we will tell the agent to rotate to a certain degree:
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.
This example is an application. You can run it by running ./bin64/exampleSimpleAgent.exe (on Windows) or ./bin64/exampleSimpleAgent (on Linux). For more information about running examples, please see Running Applications and Examples.