VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
8 - 2D Rendering

Table of Contents

VR-Vantage draws 2D content – HUD elements, informational overlays, compass ribbons, map readouts – on top of the 3D scene through a single overlay pipeline.

This chapter documents the low-level primitives that make up an overlay, the higher-level Window Object API that most applications use, and the two composite overlays VR-Vantage ships on top of that foundation.

8.1 - Overlay Primitives

An overlay is a 2D scene that is drawn on top of a 3D scene. The 2D scene can contain any number of the 2D primitives, which include: makVrv::DtLineSegment, makVrv::DtQuad, makVrv::DtFilledPolygon, and makVrv::DtOutlinedPolygon. The class that implements the overlay concept is the makVrv::DtOverlayRenderer. The makVrv::DtOverlayRenderer does the actual drawing of the graphical primitives.

To draw an overlay you must add a makVrv::DtOverlayDrawable to the scene. The makVrv::DtOverlayDrawable is responsible for telling overlays (instances of makVrv::DtOverlayRenderer) to render themselves at the appropriate time.

The makVrv::DtOverlayDrawable is told which makVrv::DtOverlayRenderer it should draw. During the render phase, the makVrv::DtOverlayDrawable tells the makVrv::DtOverlayRenderer to render itself and the graphics primitives are then rendered.

The exampleLogo example shows how to create an overlay.

8.2 - 2D Window Object API

The window object API supports the drawing of multiple 2D graphical objects and text on screen.

The API implements a parenting system similar to a scene graph, and is maintained outside of OSG in vrvCore.

All of the window objects described have agent implementations. exampleWindowObjects and exampleWindowObjectHud show how to use them.

8.2.1 Objects

DtWindowObject - is the base class for all of the following window objects. It has no OSG implementation.

8.2.2 Parenting

A DtWindowObject holds a child list of DtUniqueIDs, all of the above window objects can be attached to each other using addChild. Although DtWindowObject has no OSG implementation, one can be created to hold a number of objects for control through a single object; this is also the concept behind surfaces.

DtWindowObject::needsUpdate processes its own child list, and calls needsUpdate on them. It also gets information from its own parent that it needs to update specific member variables, more on this below.

8.2.3 Surfaces

The concept of surfaces is that 2D objects can be drawn "on" them, when really they inherit from DtWindowObject and behave like any other window object with a few exceptions.

DtWindowSurface defines a section of the screen that window objects can render within. This is done by setting a clipBox that will clip window object vertices that extend past the edges of the box. Clip boxes are defined in normalised screen coordinates on a per channel basis using two coordinates, a bottom left 2D Vector and top right 2D vector (setClipBox method).

Surfaces should be top level objects. In DtWindowObject::needsUpdate an object will get the clipBox information from its parent and set it to its own myClipBox member variable; this way the information is passed down through the hierarchy.

virtual void setSurfaceCoordinateExtents( float minU, float minV, float maxU, float maxV );

The UV coordinates passed into setSurfaceCoordinateExtents allow for a sub coordinate system "on" the surface. For example: the screen is 0.0->1.0, the surface clipbox can be from 0.25->0.75 but you may wish to represent the 0.25->0.75 as 0.0->1.0. The scale and origin or position of the surface uses these values (from the setClipBox method):

scaleX = ( TopRight.x - BottomLeft.x ) / ( MaxU - MinU )
scaleY = ( TopRight.y - BottomLeft.y ) / ( MaxV - MinV )
originX = BottomLeft.x - ( MinU * scaleX)
originY = BottomLeft.x - ( MinV * scaleY)

A DtWindowEntityAttachedSurface allows for surfaces to move around the screen and track an entity's position. A user can set the entity ID on the surface, and the surface will update its own clipBox information in needsUpdate(). As the clip box is constantly updating, the clipbox is specified as a width and height in normalised screen coordinates (setSurfaceWidthHeight). A user can also set offsets from the entity position that are added to the entity position before the position is projected to the screen (setOffsets).

Note that for a DtWindowEntityAttachedSurface a user must set the channel that the surface is to be located by either using - setChannel( DtChannel* channel ) or setChannelOverlay( std::string displayName, std::string windowName, std::string channelName )

8.2.4 Channels

By default all channels are ceated with the "showRemoteGraphics" keyword, any window objects created will be shown on all channels with this keyword. When removing the keyword from channels, is it recommended to save the display settings as a .dcx file, and restart vrVantage.

In order to render specific objects on specific channels, a user must remove this keyword from the channel, and call setChannelOverlay. Note that this does not work for remote displays.

setChannelOverlay only needs to be called on the top level parent object, it will traverse the child list and update their channels too.

8.2.5 Transforms

Each window object has a position, rotation and scale, these are combined into a transform matrix (relative transform) in needsUpdate. If the object has no parent, this transform is set as myWindowTransform, the final transform for the object. If the object has a parent the relative transform matrix is multiplied by the parent objects myWindowTransform, to give its own final window transform.

Non-uniform scales are supported. However, if a user sets a surface as a base level window object, with non-uniform scales, then proceeds to attach children and rotate the child, they will get shear/skewing of the child object. This is a product of parent / child matrice hierarchies. This limitation is expected.

8.2.6 Object Instances

8.3 - Sensor View Overlay

VR-Vantage draws a heads-up-display style overlay on top of any channel configured as a sensor view (a gimbaled sensor payload, an EO/IR camera, a targeting pod). The overlay is composed of independent sections such as a compass ribbon, a reticle, a pitch ladder, and text blocks for platform, target, and display information. Applications that add their own sensor payloads can replace individual sections, add new ones, or start from an empty section list and build the overlay from scratch.

Read this section if you are writing an application or plugin that drives a simulated sensor view and needs to customize what is drawn on top of the sensor image. The overlay is a pure 2D layer built with the primitives described above; nothing here alters the 3D scene.

8.3.1 Core Concepts

8.3.2 Class Roles

8.3.3 Default Section Set

Calling makVrv::DtOsgSensorViewOverlayCreator::defaultOverlaySectionCreators returns creators for the seven sections VR-Vantage ships:

Every section is optional. Building the section-creator list yourself gives you an overlay with exactly the sections you want and no others.

8.3.4 Extending the Overlay

To replace or supplement a section, build your own section-creator list and register it with the overlay creator before any sensor view is created. The overlay creator holds the list by value; every new overlay clones its sections from this list.

// Build a list that keeps the default sections but swaps in a custom
// compass, then register it with the display engine.
sectionCreators.push_back(new MyGimbalCompassOverlaySectionCreator);

To write a new section, derive from makVrv::DtOsgSensorViewOverlaySection, override update to redraw the section from the supplied makVrv::DtOsgObserverObject and makVrv::DtSensorFieldOfViewData, and publish a unique sectionName so the overlay can look you up later. Pair the section class with a matching subclass of makVrv::DtOsgSensorViewOverlaySectionCreator that returns your section from create.

Because the overlay creator matches sections by unique section name, a custom compass section can adopt makVrv::DtOsgSensorViewCompassOverlaySection::SectionName if it is a drop-in replacement, or a fresh name if it is meant to coexist with the default compass.

8.3.5 Complete Example

The exampleGimbalPlugin example demonstrates the full workflow: registering a custom section-creator list, deriving a DtGimbalCompassOverlaySection that replaces the stock compass, creating the overlay through makVrv::DtSensorViewOverlayCreator, and driving it every frame from a scenario driver. It is the recommended starting point for any custom sensor-view integration.

8.3.6 Related Reference

8.4 - Map Information Overlay

VR-Vantage draws a stacked block of informational text on top of a Plan View channel: map scale, mouse cursor world position, mouse cursor bearing and range from the current bullseye. The block is the map information overlay. Each row is an independent section; toolkit developers can add their own rows, remove built-in ones, or restyle the whole overlay from an authored model definition.

Read this section if you are writing an application or plugin that extends a Plan View with additional readouts, or that customizes the look of the overlay from a model definition.

8.4.1 Core Concepts

8.4.2 Class Roles

8.4.3 Wiring and Setup

Nothing special is required to enable the built-in overlay on a standard Plan View: tag the channel with the MapInformationOverlay keyword in the display configuration and put the observer in Plan View. VR-Vantage does the rest.

Section visibility is driven by observer settings. Each built-in section maps to one entry in makVrv::DtObserverSettingsManager::ObserverSetting:

Toggling the corresponding observer setting shows or hides the row; the overlay instance destroys the section visuals when the setting is off and rebuilds them when it is turned back on.

8.4.4 Model Definition Authoring

Font, colors, background, and layout can be authored by declaring a model definition whose myName is MapInformationOverlay and whose parameters follow the schema shipped in factory/schema/Model Definitions.smtx. The overlay picks up the following parameters:

Programmatic setters on makVrv::DtMapInformationOverlayInstance (setFontColor, setBackgroundColor, setFontFile, setFontPointSize) mirror these parameters. Prefer the model definition for anything a scenario or a deployment needs to change without a rebuild; reach for the programmatic API when a runtime event needs to alter the overlay in place.

8.4.5 Adding a Custom Section

Registering a custom section takes two steps. First, derive from makVrv::DtMapInformationSectionOverlay and makVrv::DtMapInformationSectionOverlayCreator. Second, register a modified section-creator map with makVrv::DtMapInformationOverlayInstanceCreator before the first Plan View channel is created.

A new section needs its own entry in makVrv::DtObserverSettingsManager::ObserverSetting so that operator visibility toggles route to it. Values at or above DtObserverSettingsManager::USER_START are reserved for that purpose.

// One-time registration during application startup.
"ShowMyReadout", ShowMyReadout);
// Start from the default section creators, add ours, and register.
creators[static_cast<makVrv::DtObserverSettingsManager::ObserverSetting>(ShowMyReadout)]
= new MyReadoutSectionCreator;

Each section is responsible for reporting its own size through getSize; the parent overlay stacks sections and assigns each one a geometry rectangle through setGeometry. makVrv::DtMapScaleSectionOverlay is a small, self-contained reference implementation to study when writing your own.

8.4.6 Ownership and Threading

8.4.7 Related Reference


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)