VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
exampleWindowObjectHud

Table of Contents

Overview

Shows how to create and manipulate DtWindowObjects in VR-Vantage.

Example details

The VR-Vantage Control Toolkit lets you create 2D window objects such as lines, polygons and textboxes.

This example demonstrates an aircraft Head-Up Display (HUD), built using these window objects.

It gets the view orientation information from the observer to update a heading tape, pitch ladder, and horizon line.

The heading tape indicates the observer's heading from 0 to 360 degrees, and loops around when constantly moving in a circle.

The pitch ladder displays the observer pitch from -40 to + 40 degrees.

You can see the HUD moving by holding down the right mouse button and moving the observer view around. To roll the observer view, press 9 on the NUMPAD of the keyboard. To reset the view, press 5 on the NUMPAD of the keyboard.

Building the Example

VR-Vantage includes pre-built versions of the example plug-in. To build it yourself, follow the instructions at Building VR-Vantage Examples, Applications, and Plug-ins.

Running the Example

This example is a plug-in. You can run it by running ./bin/exampleWindowObjectHud_stealth.bat (on Windows from cmd.exe) or ./bin64/exampleWindowObjectHud_stealth.sh (on Linux). For more information about running examples, please see Running Applications and Examples.

Example Source Files


DtWindowObjectHudDriver.h

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#pragma once
#include <matrix/vlVector.h>
namespace makVrv
{
class DtWindowEllipseAgent;
class DtPitchLadder;
class DtHeadingTape;
class DtObserver;
class DtWindowObjectHudDriver : public DtDriver
{
public:
DtWindowObjectHudDriver( DtAgentManager& agentManager, const std::string& instanceName );
virtual const std::string& className() const;
protected:
virtual bool onStart();
virtual bool onStop();
virtual bool onTick();
DtWindowEllipseAgent* myCenterDot;
DtPitchLadder* myPitchLadder;
DtHeadingTape* myHeadingTape;
};
}

DtWindowObjectHudDriver.cxx

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#include <vrvCore/DtDe.h>
#include <vrvCore/DtObserverObjectAgent.hpp>
#include <vrvCore/DtWindowObjectAgent.hpp>
#include <vrvCore/DtWindowPolygonAgent.hpp>
#include <vrvCore/DtWindowLineAgent.hpp>
#include <vrvCore/DtWindowTextAgent.hpp>
#include <vrvCore/DtWindowSurfaceAgent.hpp>
#include <vrvCore/DtWindowEllipseAgent.hpp>
#include "DtPitchLadder.h"
#include "DtHeadingTape.h"
#include "DtHudConstants.h"
#include <matrix/vlQuaternion.h>
#include <iostream>
namespace makVrv
{
DtAgentManager& agentManager, const std::string& instanceName )
: DtDriver( agentManager, instanceName )
, myPitchLadder(0)
, myHeadingTape(0)
, myCenterDot(0)
{
// Tell the driver to start automatically when added to the DE
setAutoStart( true );
// This driver can't be started or stopped from the GUI; myUserControllableFlag sets this property
myUserControllableFlag = false;
}
DtWindowObjectHudDriver::~DtWindowObjectHudDriver()
{
}
const std::string& DtWindowObjectHudDriver::className() const
{
// name must be static, since it's returned by reference
static std::string name( "DtWindowObjectHudDriver" );
return name;
}
bool DtWindowObjectHudDriver::onStart()
{
// Iterate through displays
DtDisplayConfigurations::const_iterator displayCurIter = myAgentManager.de().deConfiguration().displayConfigurations().begin();
DtDisplayConfigurations::const_iterator displayEndIter = myAgentManager.de().deConfiguration().displayConfigurations().end();
std::string dName;
for ( ; displayCurIter != displayEndIter; ++displayCurIter )
{
DtDisplayConfiguration* dec = *displayCurIter;
dName = dec->name();
// Iterate through all the windows
DtWindowConfigurations::const_iterator viewCurIter = dec->windowConfigurations().begin();
DtWindowConfigurations::const_iterator viewEndIter = dec->windowConfigurations().end();
for ( ; viewCurIter != viewEndIter; ++viewCurIter )
{
DtWindowConfiguration* wc = *viewCurIter;
std::string wName = wc->name();
if ( wName == "Window 1" )
{
wc->setSize( 1000, 1000 );
DtDisplayProxySP display = myAgentManager.de().findDisplay( dName );
if ( display )
{
DtWindowProxySP window = display->findWindow( wName );
if ( window )
{
display->modifyWindow( window, *wc );
}
}
}
}
}
// Create center dot
myCenterDot = DtWindowEllipseAgent::create( myAgentManager );
myCenterDot->setPosition( 0.5, 0.5 );
myCenterDot->setNumVertices( 20 );
myCenterDot->setDimensions( 0.005, 0.005 );
myCenterDot->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
DtObserver* observer = myAgentManager.de().driverManager().inputDriver().findObserverByName(
"Observer 1" );
if ( observer )
{
observer->agent().resetAttachment();
observer->agent().level();
myPitchLadder = new DtPitchLadder( myAgentManager.de(), *observer );
myHeadingTape = new DtHeadingTape( myAgentManager.de(), *observer );
myPitchLadder->init();
myHeadingTape->init();
}
return true ;
}
bool DtWindowObjectHudDriver::onStop()
{
if( myCenterDot )
{
delete myCenterDot;
myCenterDot = 0;
}
if( myPitchLadder )
{
delete myPitchLadder;
myPitchLadder = 0;
}
if( myHeadingTape )
{
delete myHeadingTape;
myHeadingTape = 0;
}
return true;
}
bool DtWindowObjectHudDriver::onTick()
{
if( myPitchLadder )
{
myPitchLadder->tick();
}
if( myHeadingTape )
{
myHeadingTape->tick();
}
return true;
}
}

exampleWindowObjectHudPluginInit.h

/******************************************************************************
** Copyright (c) 2020 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#pragma once
// Get proper local export symbol
// Setup proper plugin export symbol
#define DT_DE_PLUGIN_EXPORT_MACRO DT_DLL_EXAMPLEWINDOWOBJECTHUD
// Declare & export the plugin initialization function (bool initDeModule(DtDe* de))
namespace makVrv { class DtDe; }
// Work function for the plugin initialization

exampleWindowObjectHudPluginInit.cxx

/******************************************************************************
** Copyright (c) 2020 MAK Technologies, Inc.
** All rights reserved.
******************************************************************************/
#include <vrvCore/DtDe.h>
#include <boost/bind.hpp>
#include <string>
using namespace makVrv;
void init( DtDe& de )
{
// Ensure that init only gets called once
// (not strictly necessary here, but this is good practice in general)
// We only want to create the accessory if we're running in master mode:
if ( de.isInMasterMode() )
{
// The accessory must be created after the DE's initialization is
// finished, to make sure all the objects it uses exist.
}
}
{
// Setup the plugin
init( *de );
return true;
}
{
&loadDriver, de ) );
DtWindowObjectHudDriver* driver = new DtWindowObjectHudDriver( de->agentManager(), "winowObjectHudDriver" );
de->driverManager().addDriver( driver );
}

DtHeadingTape.h

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#pragma once
#include <vector>
// Use the VR-Vantage namespace.
// All classes in VR-Vantage are in this namespace.
namespace makVrv
{
class DtDe;
class DtWindowObjectAgent;
class DtWindowSurfaceAgent;
class DtObserver;
class DtHeadingTape
{
public:
DtHeadingTape( DtDe& de, DtObserver& observer );
virtual ~DtHeadingTape();
virtual void init();
virtual void tick();
protected:
typedef std::vector<DtWindowObjectAgent*> DtWindowObjects;
protected:
DtDe& myDe;
DtObserver& myObserver;
DtWindowObjectAgent* myHeadingTapeLowObject;
DtWindowObjectAgent* myheadingTapeHighObject;
DtWindowSurfaceAgent* mySurface;
};
}

DtHeadingTape.cxx

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#include "DtHeadingTape.h"
#include "DtHudConstants.h"
#include <vrvCore/DtDe.h>
#include <vrvCore/DtObserverObjectAgent.hpp>
#include <vrvCore/DtWindowObjectAgent.hpp>
#include <vrvCore/DtWindowPolygonAgent.hpp>
#include <vrvCore/DtWindowLineAgent.hpp>
#include <vrvCore/DtWindowTextAgent.hpp>
#include <vrvCore/DtWindowSurfaceAgent.hpp>
#include <vrvCore/DtWindowEllipseAgent.hpp>
#include <sstream>
namespace makVrv
{
DtHeadingTape::DtHeadingTape( DtDe& de, DtObserver& observer )
: myDe(de)
, myWindowAgents()
, mySurface(0)
, myHeadingTapeLowObject( 0 )
, myheadingTapeHighObject( 0 )
, myObserver(observer)
{
}
DtHeadingTape::~DtHeadingTape()
{
DtWindowObjects::iterator iter = myWindowAgents.begin();
DtWindowObjects::iterator endIter = myWindowAgents.end();
for ( ; iter != endIter; ++iter )
{
DtWindowObjectAgent* toDelete = *iter;
delete toDelete;
toDelete = 0;
}
myWindowAgents.clear();
myHeadingTapeLowObject = 0;
myheadingTapeHighObject = 0;
mySurface = 0;
}
{
mySurface = DtWindowSurfaceAgent::create( myDe.agentManager() );
if ( mySurface )
{
// Screen is (0.0,0.0) bottom left corner to (1.0,1.0) top right corner
mySurface->setPosition( 0.5, 0.85 );
mySurface->setScale( 1.0, 0.25 );
// This clip box will automatically clip any object outside it, provided
// that the object is a child of this surface object
mySurface->setClipBox( 0.4, 0.805, 0.6, 0.95 );
myWindowAgents.push_back( mySurface );
}
else
{
return;
}
DtWindowPolygonAgent* headingArrow = DtWindowPolygonAgent::create( myDe.agentManager() );
headingArrow->setVertex( 0, 0.0, 0.075 );
headingArrow->setVertex( 1, 0.005, 0.045 );
headingArrow->setVertex( 2, 0.00, 0.095 );
headingArrow->setVertex( 3, -0.005, 0.045 );
headingArrow->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
headingArrow->setFill( true );
mySurface->addChild( headingArrow->uniqueId() );
myWindowAgents.push_back( headingArrow );
// These low and high heading objects are used to control the tapes
// in the tick method. All of other heading lines are attached to these
// as children. The heading lines are specified in the coordinate system
// of these objects
myHeadingTapeLowObject = DtWindowLineAgent::create( myDe.agentManager() );
myHeadingTapeLowObject->setPosition( 0.0, 0.0 );
myWindowAgents.push_back( myHeadingTapeLowObject );
mySurface->addChild( myHeadingTapeLowObject->uniqueId() );
myheadingTapeHighObject = DtWindowLineAgent::create( myDe.agentManager() );
myheadingTapeHighObject->setPosition( 0.0, 0.0 );
myWindowAgents.push_back( myheadingTapeHighObject );
mySurface->addChild( myheadingTapeHighObject->uniqueId() );
for ( int i = 0; i <= 36; ++i )
{
DtWindowLineAgent* lowHeadingLine = DtWindowLineAgent::create( myDe.agentManager() );
// Line every 5 degrees
double xOffset = (HeadingScreenUnitsPerDegree * 5) * i;
// 0 - 180 line
lowHeadingLine->setVertex( 0, 0.0, 0.1 );
lowHeadingLine->setVertex( 1, 0.0, 0.175 );
lowHeadingLine->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
lowHeadingLine->setWidth( 3 );
lowHeadingLine->setPosition( xOffset, 0.0 );
myHeadingTapeLowObject->addChild( lowHeadingLine->uniqueId() );
myWindowAgents.push_back( lowHeadingLine );
// 180 - 0 line
DtWindowLineAgent* highHeadingLine = DtWindowLineAgent::create( myDe.agentManager() );
highHeadingLine->setVertex( 0, 0.0, 0.1 );
highHeadingLine->setVertex( 1, 0.0, 0.175 );
highHeadingLine->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
highHeadingLine->setWidth( 3 );
highHeadingLine->setPosition( -xOffset, 0.0 );
myheadingTapeHighObject->addChild( highHeadingLine->uniqueId() );
myWindowAgents.push_back( highHeadingLine );
if ( i % 2 == 0 ) // every second line
{
float textXOffset = (float)-0.005;
float textYOffset = (float)0.05;
DtWindowTextAgent* lowHeadingText = DtWindowTextAgent::create( myDe.agentManager() );
lowHeadingText->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
lowHeadingText->setTopLeftCorner( (float)textXOffset, (float)textYOffset );
std::ostringstream ss;
ss << i / 2;
std::string onScreenStr = ss.str();
if ( i < 20 )
{
// pad a 0 for text str < 10
onScreenStr = "0" + onScreenStr;
}
lowHeadingText->setText( onScreenStr );
lowHeadingText->setFont( "FreeMono.otf", HudFontSize );
lowHeadingText->setVisible( true );
lowHeadingText->setAlignment( 0 );
lowHeadingLine->addChild( lowHeadingText->uniqueId() );
myWindowAgents.push_back( lowHeadingText );
DtWindowTextAgent* highHeadingText = DtWindowTextAgent::create( myDe.agentManager() );
highHeadingText->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
highHeadingText->setTopLeftCorner( (float)textXOffset, (float)textYOffset );
if ( i == 0 )
{
onScreenStr = "00";
}
else
{
ss.str( std::string() );
int headingOutput = (36 - (i / 2));
ss << headingOutput;
onScreenStr = ss.str();
}
highHeadingText->setText( onScreenStr );
highHeadingText->setFont( "FreeMono.otf", HudFontSize );
highHeadingText->setVisible( true );
highHeadingText->setAlignment( 0 );
highHeadingLine->addChild( highHeadingText->uniqueId() );
myWindowAgents.push_back( highHeadingText );
}
}
}
void DtHeadingTape::tick()
{
double curPhi, curTheta, curPsi;
myObserver.getTopographicOrientation( curPhi, curTheta, curPsi );//ypr
double xPos = 0.0;
double yPos = 0.0;
// The tapes are spilt in two so we do not need an endless tape. Imagine we are flying
// in a circle, or rotating in a hover, when the tape comes back around to 00 we slot
// the 0->180 tape onto the end of 180->360.
if ( myHeadingTapeLowObject )
{
DtWindowObject* lowHeadingTape = myHeadingTapeLowObject->findObject();
if ( lowHeadingTape )
{
lowHeadingTape->getPosition( xPos, yPos );
if ( DtDeg2Rad( -180.0 ) < curPhi && curPhi < DtDeg2Rad( -135.0 ) )
{
// 0.015 = screen units per degree of rotation
// the tape is 180 * 0.015 = 2.7
// Tapes are centered on 0.0
xPos = ((-180.0 - DtRad2Deg( curPhi )) * HeadingScreenUnitsPerDegree) - 2.7;
}
else
{
xPos = (DtRad2Deg( curPhi ) * (-HeadingScreenUnitsPerDegree));
}
myHeadingTapeLowObject->setPosition( xPos, yPos );
}
}
if ( myheadingTapeHighObject )
{
DtWindowObject* highHeadingTape = myheadingTapeHighObject->findObject();
if ( highHeadingTape )
{
highHeadingTape->getPosition( xPos, yPos );
if ( DtDeg2Rad( 135.0 ) < curPhi && curPhi < DtDeg2Rad( 180.0 ) )
{
// 0.015 = screen units per degree of rotation
// the tape is 180 * 0.015 = 2.7 long
// Tapes are centered on 0.0
xPos = ((180.0 - DtRad2Deg( curPhi )) * HeadingScreenUnitsPerDegree) + 2.7;
}
else
{
xPos = (DtRad2Deg( curPhi ) * (-HeadingScreenUnitsPerDegree));
}
myheadingTapeHighObject->setPosition( xPos, yPos );
}
}
}
}

DtPitchLadder.h

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#pragma once
#include <vector>
// Use the VR-Vantage namespace.
// All classes in VR-Vantage are in this namespace.
namespace makVrv
{
class DtDe;
class DtWindowObjectAgent;
class DtWindowSurfaceAgent;
class DtObserver;
class DtPitchLadder
{
public:
DtPitchLadder( DtDe& de, DtObserver& observer );
virtual ~DtPitchLadder();
virtual void init();
virtual void tick();
protected:
virtual void drawHorizon();
virtual void drawPitchLadder();
protected:
typedef std::vector<DtWindowObjectAgent*> DtWindowObjects;
protected:
DtDe& myDe;
DtWindowObjectAgent* myPitchLadderRootObject;
DtWindowSurfaceAgent* mySurface;
DtWindowObjectAgent* myHorizonRootObject;
DtObserver& myObserver;
double lastPhi;
double lastTheta;
double lastPsi;
};
}

DtPitchLadder.cxx

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#include "DtPitchLadder.h"
#include "DtHudConstants.h"
#include <vrvCore/DtDe.h>
#include <vrvCore/DtObserverObjectAgent.hpp>
#include <vrvCore/DtWindowObjectAgent.hpp>
#include <vrvCore/DtWindowPolygonAgent.hpp>
#include <vrvCore/DtWindowLineAgent.hpp>
#include <vrvCore/DtWindowTextAgent.hpp>
#include <vrvCore/DtWindowSurfaceAgent.hpp>
#include <vrvCore/DtWindowEllipseAgent.hpp>
namespace makVrv
{
DtPitchLadder::DtPitchLadder( DtDe& de, DtObserver& observer )
: myDe(de)
, myWindowAgents()
, myPitchLadderRootObject(0)
, mySurface(0)
, lastPhi(0.0)
, lastTheta(0.0)
, lastPsi(0.0)
, myObserver( observer )
, myHorizonRootObject(0)
{
}
DtPitchLadder::~DtPitchLadder()
{
DtWindowObjects::iterator iter = myWindowAgents.begin();
DtWindowObjects::iterator endIter = myWindowAgents.end();
for ( ; iter != endIter; ++iter )
{
DtWindowObjectAgent* toDelete = *iter;
delete toDelete;
toDelete = 0;
}
myWindowAgents.clear();
myPitchLadderRootObject = 0;
mySurface = 0;
}
{
myObserver.getTopographicOrientation( lastPhi, lastTheta, lastPsi );
mySurface = DtWindowSurfaceAgent::create( myDe.agentManager() );
if ( mySurface )
{
// Screen is (0.0,0.0) bottom left corner to (1.0,1.0) top right corner
// This clip box will automatically clip any object outside it, provided
// that the object is a child of this surface object
mySurface->setClipBox( 0.25, 0.2, 0.75, 0.8 );
mySurface->setPosition( 0.5, 0.5 );
// non uni-form scales on surfaces will currently not work]
// if you wish to rotate all the children attached to the
// surface
mySurface->setScale( 1.0, 1.0 );
mySurface->setScaleToClipBox( false );
myWindowAgents.push_back( mySurface );
}
drawPitchLadder();
drawHorizon();
}
void DtPitchLadder::tick()
{
double curPhi, curTheta, curPsi;
myObserver.getTopographicOrientation( curPhi, curTheta, curPsi );//ypr
double x = 0.0;
double y = 0.0;
// Update Pitch Ladder
if ( myPitchLadderRootObject )
{
DtWindowObject* pitchLadderRoot = myPitchLadderRootObject->findObject();
if ( pitchLadderRoot )
{
// current pitch * units per degree between pitch lines
// pitch lines are separated by 0.25 units.
double pTranslatDist = DtRad2Deg( curTheta ) * (PitchScreenUnitsPerDegree * 0.6);
x = -std::sin( curPsi ) * pTranslatDist;
y = std::cos( curPsi ) * pTranslatDist;
myPitchLadderRootObject->setPosition( -x, -y );
myPitchLadderRootObject->setRotation( curPsi );
}
}
// Update Horizon
if ( myHorizonRootObject )
{
DtWindowObject* horizonRoot = myHorizonRootObject->findObject();
if ( horizonRoot )
{
// change in pitch * half height of screen (0.5) * top half fov degrees (22.5)
double pTranslatDist = -DtRad2Deg( curTheta ) * ((0.5) / 22.5);
x = -std::sin( curPsi ) * pTranslatDist;
y = std::cos( curPsi ) * pTranslatDist;
myHorizonRootObject->setPosition( x, y );
}
if (curPsi != lastPsi)
{
myHorizonRootObject->setRotation(curPsi);
}
}
lastPsi = curPsi;
lastTheta = curTheta;
lastPhi = curPhi;
}
void DtPitchLadder::drawHorizon()
{
myHorizonRootObject = DtWindowLineAgent::create( myDe.agentManager() );
myHorizonRootObject->setPosition( 0.0, 0.0 );
myWindowAgents.push_back( myHorizonRootObject );
mySurface->addChild( myHorizonRootObject->uniqueId() );
DtWindowLineAgent* leftHorizon = DtWindowLineAgent::create( myDe.agentManager() );
leftHorizon->setVertex( 0, -0.13, 0.0 );
leftHorizon->setVertex( 1, -0.20, 0.0 );
leftHorizon->setVertex( 2, -0.20, -0.025 );
leftHorizon->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
leftHorizon->setWidth( 3 );
myHorizonRootObject->addChild( leftHorizon->uniqueId() );
myWindowAgents.push_back( leftHorizon );
DtWindowLineAgent* rightHorizon = DtWindowLineAgent::create( myDe.agentManager() );
rightHorizon->setVertex( 0, 0.13, 0.0 );
rightHorizon->setVertex( 1, 0.20, 0.0 );
rightHorizon->setVertex( 2, 0.20, -0.025 );
rightHorizon->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
rightHorizon->setWidth( 3 );
myHorizonRootObject->addChild( rightHorizon->uniqueId() );
myWindowAgents.push_back( rightHorizon );
}
void DtPitchLadder::drawPitchLadder()
{
myPitchLadderRootObject = DtWindowLineAgent::create( myDe.agentManager() );
myPitchLadderRootObject->setPosition( 0.0, 0.0 );
myWindowAgents.push_back( myPitchLadderRootObject );
mySurface->addChild( myPitchLadderRootObject->uniqueId() );
for ( int i = -8; i <= 8; i = i + 1 )
{
DtWindowLineAgent* pitchLine = DtWindowLineAgent::create( myDe.agentManager() );
// 5 Degrees between each line
double totalOffset = PitchScreenUnitsPerDegree * 5 * i;
double invertLine = 0.0;
if ( i < 0 )
{
invertLine = 0.015;
pitchLine->setSegmentStipplePattern( 2, 1, 0x00FF );
}
else if ( i == 0 )
{
invertLine = 0.0075;
}
pitchLine->setVertex( 0, -0.1, (invertLine - 0.0075) + totalOffset );
pitchLine->setVertex( 1, -0.1, 0.0 + totalOffset );
pitchLine->setVertex( 2, -0.1, 0.0 + totalOffset );
pitchLine->setVertex( 3, 0.1, 0.0 + totalOffset );
pitchLine->setVertex( 4, 0.1, (invertLine - 0.0075) + totalOffset );
pitchLine->setVertex( 5, 0.1, 0.0 + totalOffset );
pitchLine->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
pitchLine->setWidth( 3 );
myPitchLadderRootObject->addChild( pitchLine->uniqueId() );
myWindowAgents.push_back( pitchLine );
DtWindowTextAgent* pitchTextRight = DtWindowTextAgent::create( myDe.agentManager() );
pitchTextRight->setColor( 0.0, 1.0, 0.0, 1.0 );
pitchTextRight->setTopLeftCorner( (float)0.105, (float) -0.006 + totalOffset );
std::ostringstream ss;
ss << std::abs( 5 * i );
pitchTextRight->setText( ss.str() );
pitchTextRight->setFont( "FreeMono.otf", HudFontSize );
pitchTextRight->setVisible( true );
pitchTextRight->setAlignment( 0 );
myPitchLadderRootObject->addChild( pitchTextRight->uniqueId() );
myWindowAgents.push_back( pitchTextRight );
DtWindowTextAgent* pitchTextLeft = DtWindowTextAgent::create( myDe.agentManager() );
pitchTextLeft->setColor( HudColorR, HudColorG, HudColorB, HudColorA );
pitchTextLeft->setTopLeftCorner( (float) -0.135, (float) -0.006 + totalOffset );
pitchTextLeft->setText( ss.str() );
pitchTextLeft->setFont( "FreeMono.otf", HudFontSize );
pitchTextLeft->setVisible( true );
pitchTextLeft->setAlignment( 2 ); // right
pitchTextLeft->setTextBoxWidth( 28 );
myPitchLadderRootObject->addChild( pitchTextLeft->uniqueId() );
myWindowAgents.push_back( pitchTextLeft );
}
}
}

DtHudConstants.h

// /******************************************************************************
// ** Copyright (c) 2020 MAK Technologies, Inc.
// ** All rights reserved.
// ******************************************************************************/
#pragma once
#define HudFontSize 16
#define HudColorG 1.0
#define HudColorB 0.0
#define HudColorR 0.0
#define HudColorA 1.0
#define PitchScreenUnitsPerDegree 0.05
#define HeadingScreenUnitsPerDegree 0.015

[<< Examples] [Home] [Top of Page]


Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)