VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
5 - The Display Engine

This section describes the role of the display engine, display management, and distributed rendering.

4.1 - The Display Engine

A VR-Vantage application, such as the VR-Forces front-endcan be defined as any application that has a display engine in it. A display engine contains almost all of the major systems and subsystems that are described in this manual. Among the systems that the display engine owns are:

4.1.1 Channels, Windows, and Displays

A display (DtDisplay) owns and manages windows. A display can own zero or more windows. Windows can own zero or more channels.

To see a rendered scene, you need a display configured with at least one channel inside a window. A channel is a area on the screen onto which a camera's view of the scene is rendered. Channels live inside windows. VR-Forces has the following types of windows:

4.1.1.1 Creating a Display Configuration

You specify the number and organization of displays, windows and channels in a display engine by creating a display configuration. You can create a display configuration programmatically and then have it created by a display engine.

Display configurations must have unique names. The display engine will not implement configurations with duplicate names. For an example of creating a display configuration programmatically, please see the exampleConfiguration example.

4.1.2 Channel Keywords

Channel keyword objects are objects that are created due to the presence of a keyword in a channel's configuration. Possible types of channel keyword objects might include compasses, logos, cockpit displays, message logs, and so on. When a channel gets created, any objects specified by the associated keywords get created, such as a compass, or can be created, such as a cockpit display. If the keyword is removed from a channel by a user, the object gets removed from the scene.

Channel keyword objects are managed by the DtChannelKeywordObject, DtChannelKeywordObjectFactory, and DtChannelKeywordObjectManager classes.

4.1.2.1 DtChannelKeywordObject

DtChannelKeywordObject is an abstract class that provides a common interface for channel keyword objects.

DtChannelKeywordObjects are created in a factory using DtChannelKeywordObjectCreators. DtChannelKeywordObjectCreator has a create() method that takes the same arguments as DtChannelKeywordObject, except for the keyword parameter. The creator class itself provides a keyword to the DtChannelKeywordObject constructor via a static keyword() method. In this way, the keywords are tied to the creator objects, rather than just being "magic strings" that appear in the system. For details about this class's methods, please see DtChannelKeywordObjectCreator.

4.1.2.2 DtChannelKeywordObjectFactory

The DtChannelKeywordObjectFactory is a singleton class that allows you to register channel keyword object creators, and which is used by the DtChannelKeywordObjectManager to create channel keyword objects. For details about this class's methods, please see DtChannelKeywordObjectFactory.

4.1.2.3 DtChannelKeywordObjectManager

The DtChannelKeywordObjectManager is a singleton object with an instance() accessor. The instance() accessor uses a registered creator to create the manager (registered in vrvCore.cxx). DtDe instantiates the class after initialization (and before postInitialize) so that it exists before any channels are realized.

Note
The manager assumes it will exist by the time the first channel is created - it does not search for existing channels when it is constructed.

The DtChannelKeywordObjectManager listens to the display engine's signal_channelConfigurationModified, signal_channelToBeDestroyed, and signal_windowConfigurationModified as well as the DtChannelManagerSignaler's signal_channelCreated signals to manage the display of channel keyword objects within VR-Forces.

When a channel is added, DtChannelKeywordObjectManager looks for keywords in the configuration for which there are entries in the DtChannelKeywordObjectFactory and if they exist, creates a channel keyword object for that channel.

When a channel configuration is modified, DtChannelKeywordObjectManager determines if the channel needs a channel keyword object added or removed. If channel keyword objects already exist for that channel, the objects will be notified via their channelConfigurationModified() methods. If an object is to be removed, DtChannelKeywordObjectManager calls the object's objectToBeDestroyed() method and then deletes or removes it. Additionally, it checks to see if the channel name has changed. If it has, it adjusts the manager's maps for looking up the channel keyword objects on a channel by display/window/channel name.

When a channel is destroyed, DtChannelKeywordObjectManager determines if it has any channel keyword objects for that for that channel and if so, destroy them.

When a window configuration changes, DtChannelKeywordObjectManager notifies any channel keyword objects in that window by calling their windowConfigurationChanged() methods. It also checks to see if the window's name has changed. If it has, it adjusts the manager's maps for looking up the channel keyword objects on a channel by display/window/channel name.

DtChannelKeywordObjectManager maintains an std::map of channelName :: windowName :: displayName to keyword / DtChannelKeywordObject pairs for each channel keyword object created. Given a channelName :: windowName :: displayName, the map provides a list of DtChannelKeywordObjects, one for each keyword that exists. It will also maintain a map of displayName::windowName to a list of channelName :: windowName :: displayName strings. This map makes it possible to get all the channel keys for channels that have channel keyword objects on them, given a window key.

4.2 - Distributed Rendering

The VR-Vantage Toolkit, and applications built on it, such as VR-Forces,support distributed rendering. Distributed rendering is the process of rendering a single scene simultaneously on two or more computers. Distributed rendering is managed by a Control Interface running in a display engine in a VR-Vantage application. The Control Interface takes input from drivers and manages its rendering system as well as those of external display engines.

Note
VR-Forces does not support use of remote VR-Vantage Display Engines. However, the display engine in the front-end uses the distributed rendering architecture described in this section.

In distributed rendering, the display engine sends commands to its Rendering System and to connected display engines, which execute them. Since each external display engine executes the same commands, they each display the exact same scene as the master and the objects perform the same actions in the same order. Since the scenes are synchronized across all display engines, the rendering of the scene is also synchronized. However, the scenes are only loosely synchronized, as only the scene itself is synchronized, not the rendering of the scene. VR-Forces does not support low-level rendering synchronization such as frame locking, which ensures that each channel renders at the same frame rate, or Genlock, which ensures that each monitor refreshes the image at the same time.

The commands sent by the display engine are really just function calls. The Toolkit makes it easy to make a function call to a single C++ class instance and have that call get made on one or more objects, existing on one or more display engines.

4.2.1 Proxies

The master display engine contains the complete state of all connected display engines. However the master does not have an actual copy of all objects on the display engines. Instead, it has proxy objects. For example, there is a DtWindow object for each window. To represent a window on a distributed display engine the master display engine has a DtWindowProxy object, which is a proxy representation of the real object. Calls made on a proxy object are distributed to the display engine that has the real object, which behaves as if the call had been made directly to it.

The communication from a proxy object to a real object is performed by an agent object. An agent instance exists for each proxy/class pair. The master display engine makes calls to an agent and the agent distributes those calls automatically.

4.2.2 Distributed Objects and Agents

Objects that exist in display engines are called distributed objects. Each object in the scene is composed of an agent object and a distributed object. When the master display engine creates an agent, each external display engine simultaneously creates the distributed object that the agent will control.

An agent is created with an appropriate subset of the methods that the actual object has. For example, if a distributed object has a setLocation() method, then its agent could have it. On the master, you would call a method on the agent, as follows:

agent->setLocation(x,y,z);

The distributed rendering architecture handles all the data marshalling (encoding, transport, and decoding) and the corresponding object on each display engine has the setLocation() method called.

Note
Each display engine owns an Object Manager. This is a container of distributed objects. At any given time the contents of the Distributed Object Manager on the master display engine and on each of the external display engines is the same.

4.2.3 Distributed Rendering Transport

The GUI APIprovides mechanisms for implementing communications over any protocol or medium. It uses a TCP socket connection. Once a display engine is connected, most rendering will be distributed unless the application is explicitly designed not to use the distributed rendering functionality.

4.2.4 Example of Using an Agent

The following pseudo code demonstrates use of agents. Suppose you want to add a traffic light to your scene. You want to be able to programmatically change its state from green to yellow to red.

  1. Create the TrafficLightObject. This is the object that will get created in each of the display engines and will make changes to the scene graph.

    class TrafficLightObject
    {
    public:
    ...
    void setState(int state)
    {
    myState = state;
    changeState();
    }
    void changeState()
    {
    // change the geometry in the scene graph to reflect
    // the traffic lights new state.
    }
    int state() const
    {
    return myState;
    }
    };

  2. Generate an agent. (For details about generating agents, please see 4.3 - Generating Code for Agents.) The agent will have a similar API to your object.

    class TrafficLightAgent : public DtDistributedObjectAgent
    {
    public:
    ...
    void setState(int state);
    };

  3. Create an instance of the agent in a master display engine's driver:

    TrafficLightAgent* agent = TrafficLightAgent::create();

    This causes TrafficLightObjects to get created on each display engine (the master display engine also) and added to the Distributed Object Manager.

  4. You can now make calls on the agent to set its state and each object's setState() method will get called.

    agent->setState(State_Red);

The distributed object framework guarantees that the calls will happen in the order in which you make them. For example, if you make the following calls in your driver:

trafficLightAgent1->setState(State_Red);
trafficLightAgent2->setState(State_Green);

Each display engine will execute them in order:

trafficLightObject1->setState(State_Red);
trafficLightObject2->setState(State_Green);

Some drivers are written to run asynchronously in a separate thread. These drivers each have their own interface for setting messages from agents to the implementation. These commands are executed in the order in which they are called, however they may be interspersed with commands generated in the main thread or in other threads. For example, the agent might call functions in the following order:

Thread A: fooAgent->doSomething();
Thread A: fooAgent->doSomethingElse();
Main Thread: barAgent->doSomething();
Main Thread: barAgent->doSomethingElse();

The functions might be executed in the following order:

bar->doSomething();
foo->doSomething();
foo->doSomethingElse();
bar->doSomethingElse();

4.3 - Generating Code for Agents

Every object needs an agent to manage its creation on the master display engine and external display engines. Since the generic functioning of agents is the same regardless of the object, it is possible to automate the process of creating them. VR-Forces includes a tool, the Distributed Code Generator, that generates source code for agent classes from object classes so that they can be easily integrated into drivers.

The Distributed Code Generator generates an agent class, an agent implementation class, a definition class, and a creator class. Most of the time, you will only need to know about the agent class. However, the following is a brief description of all of the generated classes:

The exampleDistributedObject example has generated agent classes. Please see exampleDistributedObject for a description of the object class, generating agent classes, and adding the agent to a driver.

4.3.1 The Object Class Definition

The Distributed Code Generator generates code based on the information in an object class definition (OCD). An OCD contains all the information the Distributed Code Generator needs to generate the agent classes, such as the object class name, namespace, functions, and comments. The functions that the agent will have are called distributed functions, because these function calls will be distributed to objects in display engines.

You create an OCD in the Distributed Code Generator's graphical user interface. You save the OCD in an object class definition file (extension .ocdx).

Once you create the OCD, you can build the classes from the Distributed Code Generator's GUI, from the command-line, or from within Visual Studio.

4.3.2 Distributed Code Generator Limitations

The Distributed Code Generator has the following limitations:

4.3.3 Starting the Distributed Code Generator

You can start the Distributed Code Generator from the command line. For details, please see 4.3.6 Distributed Code Generator Command-Line Arguments. On Windows, you can also start it from the Start menu.

4.3.4 Creating an Object Class Definition

To see an example of an object class definition, load ./examples/exampleDistributedObject/DtExampleObject.ocdx.

To create an object class definition:

  1. Run ./bin/dcgen.exe. The Distributed Code Generator opens.
  2. Choose Files -> New.
  3. In the Object Class group box, Name text box, type the name of the object class.
  4. Type the namespace that the class is in.
  5. Type the name of the header file for the object class.
  6. Specify the agent functions. For each function:
    1. In the Functions group box, click New. The cursor jumps to the Name column and an empty signature is added.
    2. Type the function name in the name column.
    3. In the Function Arguments group box, click New. The cursor jumps to the Type column.
    4. Type the type of the argument.
    5. Double click the Name field. It becomes editable.
    6. Type the name of the argument.
    7. Type comments for the function in the Function C++ Comments text box.
  7. Optionally, complete other fields in the form.
  8. Choose Files -> Save. The Save Class File dialog box opens.
  9. Navigate to the location where you want to save the OCD file.

    Note
    We recommend that you create a directory for your OCD files, for example, myProject/Object Class Definitions. Then create a subdirectory called generated to store the files generated by the Distributed Code Generator.
  10. Type a name for the file.
  11. Click Save.

4.3.5 Building Agent Classes

You can build agent classes from the Distributed Code Generator GUI, from the command-line, or as part of your build process using Microsoft Visual Studio. For command-line arguments, please see 4.3.6 Distributed Code Generator Command-Line Arguments.

4.3.5.1 Building Agent Classes in the Distributed Code Generator GUI

To build agent classes from the Distributed Code Generator GUI:

  1. Create an object class definition (as described in 4.3.4 Creating an Object Class Definition) or load a previously created OCD.
  2. Choose Build -> Set Output Directory. A directory chooser dialog box opens.
  3. Select the directory in which the Distributed Code Generator should put the generated source code.
  4. Click OK.
  5. Choose Build -> Generate Files.

4.3.5.2 Building Agent Classes in Your IDE

You can integrate creation of agent classes into your build process. This is the recommended way to generate these classes.

Note
This example code in this section procedure is from the exampleDistributedObject example. It assumes that you have created an OCD and saved it to DtExampleObject.ocdx and created a directory called exampleDistributedObject.

To generate the agent files using Microsoft Visual Studio:

  1. Right click on the .ocdx file in the Solution Explorer and examine its Custom Build Step in its properties. It will look something like this:

    Outputs:
    $(InputDir)$(InputName)Agent.hpp;$(InputDir)$(InputName)Agent.cpp
    $(InputDir)$(InputName)Classes.hpp;$(InputDir)$(InputName)Classes.cpp
    Additional Dependencies: ..\..\bin\sceneObjectCompilerd.exe
    Command Line: ..\..\bin\sceneObjectCompilerd.exe "$(InputPath)" -a -S "$(InputDir)/" -H "$(InputDir)/" -A "../../include"

  2. Compile just the DtExampleObject.ocdx file (right click on it and click compile). This generates the following files in the exampleDistributedObject directory:
    • DtExampleObjectClasses.cpp
    • DtExampleObjectClasses.hpp
    • DtExampleObjectAgent.cpp
    • DtExampleObjectAgent.hpp.
  3. Add those files to the generated folder.
  4. Right click on the generated folder and click add existing item.
  5. Select those files and add them.

4.3.6 Distributed Code Generator Command-Line Arguments

You can run the Distributed Code Generator from the command line if you have an object class definition file to input to it. The syntax is:

dcgend.exe input_file [{-i | -a | -p} -A root_dir -H header_dir -S source_dir -o output_dir -- -v -h]

The following table describes the command line arguments.

Distributed Code Generator Command-line Arguments
Argument Description
input_file The Object Class Definition file to process.
(-i | --generateImplementation) Generate all of the implementation classes.
(-a | --generateAll) Generate all of the classes.
(-p | --generateAgent) Generate only the abstract driver class.
(-A | --RelativeIncludeDirectory) root_dir The root directory that generated include statements are relative to.
(-H | --HeaderOutputDirectory) header_dir The directory to write header files to.
(-S | --SourceOutputDirectory) source_dir The directory to write source files to.
(-o | --OutputDirectory) output_dir The directory to write all files to.
(-v | --version) Display version information and exit.
(-h | --help) Display usage information and exit.
(-- | --ignore_rest) Ignore all command-line arguments after this one.

Suppose that you are generating the file testAgent.hpp in the /productRoot/include/test/ directory. However, you want the include statement to look like:

#include <test/testAgent.hpp>

and NOT

#include <testAgent.hpp>

Use the arguments -H /productRoot/include/test -A /productRoot/include to specify the header location and relative include path.

4.4 - Observers

An observer is a special kind of distributed object that is not part of the scene. It controls the camera associated with one or more channels. The input driver is responsible for instantiating observers, because they provide the link between mouse and keyboard input and the cameras that determine how a scene is viewed. For details about how distributed objects are managed, please see 5.1 - The Input Driver.

Observers that control OSG cameras are implemented by the DtOsgObserverAgent and DtOsgObserverObjects, which are derived from the DtObserverAgent and DtObserverObject classes respectively. The DtObserver class provides a renderer-independent interface for creating and controlling observer objects. The renderer creates and maintains an Observer Object Manager (DtObserverObjectManager).

Note
The DtObserverAgent and DtOsgObserverAgent classes are generated. They do not have header files and are not in the API documentation.

When the input driver creates an observer object (through the DtObserver class), the observer is registered with the renderer's Observer Object Manager. Channels can then use the Observer Object Manager to look up the observers that have been designated as their controllers. The linkage between channels and observers is made by observer name. Each channel is given the name of the observer that it should use to position its camera. The observer name is specified in the channel configuration (default "Observer 1"). For details about creating observers, please see 5.1 - The Input Driver.

There are several Boost signals associated with observers. Signals that indicate the creation and destruction of observers are available using the DtInputDriverSignaler (since the input driver creates and owns all observers). You can also connect to the signals raised by individual observers. The following table describes these signals.

Observer Signals
Signal Description
signal_objectAttached Called when the observer attaches to an object. Includes the observer name and the unique ID of the object attached to.
signal_objectsDetached Called when the observer detaches from all. Includes the observer name.
signal_linearScaledSpeedGainChanged Called when the scaled linear speed gain is changed. Includes a pointer to the observer and the new gain.
signal_linearUnscaledSpeedGainChanged Called when the unscaled linear speed gain is changed. Includes a pointer to the observer and the new gain.
signal_rotationSpeedGainChanged Called when the rotation speed gain is changed. Includes a pointer to the observer and the new gain.
signal_orbitSpeedGainChanged Called when the orbit speed gain is changed. Includes a pointer to the observer and the new gain.
signal_gainPrecisionChanged Called when the gain precision is changed. Includes a pointer to the observer and the new gain.
signal_terrainConstraintChanged Called when terrain constraint is turned on or off. Includes a pointer to the observer and a boolean indicating whether terrain constraint is on or off.
signal_speedScalingChanged Called when speed scaling is turned on or off. Includes a pointer to the observer and a boolean indicating whether speed scaling is on or off.

4.5 - The Observer API

Application code can access an observer by:

Both of these mechanisms result in a pointer to a DtObserver.

The DtObserver class is a facade for the DtObserverObjectAgent, which is itself the interface for the distributed DtObserverObjects it controls. Calls to DtObserverObjectAgent methods are distributed to all of the agent's DtObserverObjects. The DtObserver class is intended to simplify some operations on observers. However, it is always possible to access the agent itself from the DtObserver and make calls directly. There are many methods that you can call to control an observer.

4.5.1 Controlling the Observer

DtObserverObjects are controlled in the local (database) coordinate system. Given a pointer to an observer, pObserver, a call to set a DtObserverObject's location would look like:

pObserver->setLocation( desiredX, desiredY, desiredZ );

You can specify orientation using Tait-Bryan angles or quaternions:

pObserver->setOrientation( desiredPsi, desiredTheta, desiredPhi );
pObserver->setOrientation( xQuat, yQuat, zQuat, wQuat );

You can specify the observer location with the following:

pObserver->setLocation( databaseLocationX, databaseLocationY, databaseLocationZ );

The observer uses the database coordinates. VR-Vantage customers who need to work in geocentric coordinates should use a geocentric database. If you need to convert a geocentric location to a non-geocentric database location use:

myDe.sharedState().coordinateSystem().netToLocalPos( geocentricLocation, databaseLocation );

Methods also exist for setting attachments, attach modes, and all the parameters typically associated with those modes.

The keyboard-based navigation code does not set the location and orientation of the observer directly. It uses commands to start and stop observer movement. These methods are not part of the DtObserver facade. You can call them directly on the DtObserverObjectAgent. For example:

pObserver->agent()->startMoveObserverForward();
pObserver->agent()->stopMoveObserverForward();

You can retrieve information about the observer's location, orientation, current attachments and modes, and so on. Please see DtObserver and DtObserverObject for all the methods available

This section describes the role of the display engine, display management, and distributed rendering.


Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)