VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtHudUpdater Class Referenceabstract

Detailed Description

DtHudUpdater provides a base framework for creating and managing HUD elements such as text, images, and colored quads. It handles visibility, positioning, and updates of HUD elements based on player state. This class is designed to be extended by specific HUD implementations for different gameplay purposes.

#include <hudUpdater.h>

Inheritance diagram for makVre::DtHudUpdater:
[legend]

Classes

struct  HudColorQuadConfig
 
struct  HudImageConfig
 
struct  HudTextConfig
 
struct  HudValueColorPair
 

Public Member Functions

 DtHudUpdater ()
 
virtual ~DtHudUpdater () override
 
virtual bool initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
 
virtual bool postInitialize () override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
void addItem (makVre::HudItem *item)
 
void removeItem (makVre::HudItem *item)
 
makVrv::DtOverlayRenderer * getOverlay () const
 
float xPixel (const float norm) const
 
float yPixel (const float norm) const
 
float pixelW (const float norm) const
 
float pixelH (const float norm) const
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Types

enum  Layers { HIDDEN = 0 , OVERLAY = 1 , UI = 2 }
 

Protected Member Functions

double headingAngleTo (const DtVector &geocentricObserverPosition, const DtVector &geocentricTargetPosition)
 
virtual void start ()
 
virtual void stop ()
 
virtual void onStart ()=0
 
virtual void onStop ()=0
 
virtual void updateAll ()
 
virtual void setupOverlays ()
 
virtual void updateHudElements (bool visible)=0
 
virtual void channelDestroyed (const std::string &displayName, const std::string &windowName, const std::string &channelName)
 
virtual void onViewportChanged ()
 
virtual void deleteAll ()
 
virtual void onDeleteAll ()=0
 
virtual makVrv::DtOsgChannel * findChannel (const std::string &channelName="Channel 1")
 
virtual makVrv::DtOverlayRenderer * createOverlay (makVrv::DtOsgChannel *channel, osg::Geode *&geodeOut)
 
virtual void setupQuads ()
 
void slot_onChannelCreated ()
 
void slot_onChannelToBeDestroyed ()
 
virtual osg::Texture * createTexture (std::string path)
 
virtual void createQuads (makVrv::DtOverlayRenderer *overlay, const std::vector< HudImageConfig > &configs)=0
 
virtual makVrv::DtQuadProxy * createQuad (makVrv::DtOverlayRenderer *overlay, const HudImageConfig &config)
 
virtual makVrv::DtQuadProxy * createQuadWithColor (makVrv::DtOverlayRenderer *overlay, const HudColorQuadConfig &element)
 
virtual bool loadImageConfig (unsigned int e, makVre::DtInitTable &imageTable, std::string imageName, bool loadDimensions=true)
 
virtual bool loadTextConfig (unsigned int t, makVre::DtInitTable &textTable, std::string textName)
 
virtual bool loadColorQuadConfig (unsigned int quadIndex, makVre::DtInitTable &colorQuadTable, std::string colorQuadName, bool loadDimensions=true)
 
virtual bool loadColorConfig (makVre::DtColor &colorInfo, makVre::DtInitTable &colorTable, std::string colorName)
 
virtual bool loadValueColorPairsConfig (std::vector< HudValueColorPair > &valueColorPairsContainer, makVre::DtInitTable &hudTable, const std::string &valueColorPairsName)
 
virtual bool loadValueColorPairConfig (HudValueColorPair &valueColorPair, makVre::DtInitTable &valueColorPairConfig)
 
makVrv::DtTextProxy * createAndInitTextProxy (double normalizedX, double normalizedY, const std::string &defaultText)
 
virtual makVre::DtVreMessageResult handleEnterPlayerState (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleExitPlayerState (makVre::DtVreMessage *msg)
 
virtual enum Layers overlayGroup ()
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

std::map< const makVre::HudTextItem *, std::pair< makVre::HudTextItem *, makVrv::DtTextProxy * > > myTextItemMap
 
std::map< const makVre::HudImageItem *, std::pair< makVre::HudImageItem *, makVrv::DtQuadProxy * > > myImageItemMap
 
bool myActive
 
DtAttributeHandleType< bool > myUsingVr
 
std::vector< HudImageConfigmyImages
 
std::vector< HudColorQuadConfigmyColorQuads
 
std::vector< HudTextConfigmyTexts
 
makVrv::DtOverlayRenderer * myOverlayInterface
 
makVrv::DtOsgChannel * myChannel
 
float myFontSize
 
makVrv::DtFontInterface * myFont
 
std::string myFontFilePath
 
int myLineHeight
 
osg::Geode * myGeode
 
bool myChannelsUpdated
 
bool myShowOverlays
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Member Enumeration Documentation

◆ Layers

Enumeration of display layers for HUD elements.

Enumerator
HIDDEN 

Hidden layer (not visible)

OVERLAY 

Overlay layer (normal HUD elements)

UI 

UI layer (user interface elements)

Constructor & Destructor Documentation

◆ DtHudUpdater()

makVre::DtHudUpdater::DtHudUpdater ( )

Constructor.

Creates a new HUD updater component with default state.

◆ ~DtHudUpdater()

virtual makVre::DtHudUpdater::~DtHudUpdater ( )
overridevirtual

Virtual destructor.

Member Function Documentation

◆ initialize()

virtual bool makVre::DtHudUpdater::initialize ( makVre::DtPlayerStation * player,
makVre::DtInitTable & config )
overridevirtual

Initializes the HUD updater.

Parameters
playerPointer to the player station
configConfiguration settings for initialization
Returns
True if initialization was successful, false otherwise

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in makVre::DtDroneHudUpdater, makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

virtual bool makVre::DtHudUpdater::postInitialize ( )
overridevirtual

Performs post-initialization setup.

Returns
True if post-initialization was successful, false otherwise

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.

◆ tick()

virtual void makVre::DtHudUpdater::tick ( double dt)
overridevirtual

Updates the HUD elements for the current frame.

Parameters
dtDelta time since the last frame in seconds

Implements makVre::DtPlayerComponent.

Reimplemented in makVre::DtDroneHudUpdater, makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.

◆ shutdown()

virtual void makVre::DtHudUpdater::shutdown ( )
overridevirtual

Cleans up resources when the component is being shut down.

Reimplemented from makVre::DtPlayerComponent.

Reimplemented in makVre::DtHumanVrHudUpdater.

◆ type()

virtual const char * makVre::DtHudUpdater::type ( ) const
overridevirtual

Returns the component type identifier.

Returns
String identifier for this component type

Returns the type identifier string for this component, which is used by the VR-Engage framework for component identification and management. The returned value matches DtHudUpdaterType.

Implements makVre::DtPlayerComponent.

Reimplemented in makVre::DtDroneHudUpdater, makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.

◆ addItem()

void makVre::DtHudUpdater::addItem ( makVre::HudItem * item)

Adds a HUD item to this updater.

Parameters
itemPointer to the HUD item to add

◆ removeItem()

void makVre::DtHudUpdater::removeItem ( makVre::HudItem * item)

Removes a HUD item from this updater.

Parameters
itemPointer to the HUD item to remove

◆ getOverlay()

makVrv::DtOverlayRenderer * makVre::DtHudUpdater::getOverlay ( ) const

Gets the overlay renderer used by this HUD updater.

Returns
Pointer to the overlay renderer

◆ xPixel()

float makVre::DtHudUpdater::xPixel ( const float norm) const
inline

Converts normalized x-coordinate to pixel x-coordinate.

Parameters
normNormalized x-coordinate (0.0 to 1.0)
Returns
Pixel x-coordinate

◆ yPixel()

float makVre::DtHudUpdater::yPixel ( const float norm) const
inline

Converts normalized y-coordinate to pixel y-coordinate.

Parameters
normNormalized y-coordinate (0.0 to 1.0)
Returns
Pixel y-coordinate

◆ pixelW()

float makVre::DtHudUpdater::pixelW ( const float norm) const
inline

Converts normalized width to pixel width.

Parameters
normNormalized width (0.0 to 1.0)
Returns
Pixel width

◆ pixelH()

float makVre::DtHudUpdater::pixelH ( const float norm) const
inline

Converts normalized height to pixel height.

Parameters
normNormalized height (0.0 to 1.0)
Returns
Pixel height

◆ headingAngleTo()

double makVre::DtHudUpdater::headingAngleTo ( const DtVector & geocentricObserverPosition,
const DtVector & geocentricTargetPosition )
protected

Calculates heading angle between observer and target positions.

Parameters
geocentricObserverPositionGeocentric position of the observer
geocentricTargetPositionGeocentric position of the target
Returns
Heading angle in degrees

Utility function used by derived classes to calculate heading for HUD elements

◆ start()

virtual void makVre::DtHudUpdater::start ( )
protectedvirtual

Starts this HUD updater.

Initializes and shows HUD elements

◆ stop()

virtual void makVre::DtHudUpdater::stop ( )
protectedvirtual

Stops this HUD updater.

Hides and cleans up HUD elements

◆ onStart()

virtual void makVre::DtHudUpdater::onStart ( )
protectedpure virtual

Called when this HUD updater is started.

Pure virtual method implemented by derived classes to handle initialization of specific HUD elements when the updater is started

Implemented in makVre::DtDroneHudUpdater, and makVre::DtHumanHudUpdater.

◆ onStop()

virtual void makVre::DtHudUpdater::onStop ( )
protectedpure virtual

Called when this HUD updater is stopped.

Pure virtual method implemented by derived classes to handle cleanup of specific HUD elements when the updater is stopped

Implemented in makVre::DtDroneHudUpdater, and makVre::DtHumanHudUpdater.

◆ updateAll()

virtual void makVre::DtHudUpdater::updateAll ( )
protectedvirtual

Updates all HUD elements.

Updates the state and visibility of all HUD elements managed by this updater

Reimplemented in makVre::DtDroneHudUpdater, and makVre::DtHumanHudUpdater.

◆ setupOverlays()

virtual void makVre::DtHudUpdater::setupOverlays ( )
protectedvirtual

Sets up overlay renderers for HUD elements.

Creates and configures overlay renderers for displaying HUD elements

◆ updateHudElements()

virtual void makVre::DtHudUpdater::updateHudElements ( bool visible)
protectedpure virtual

Updates HUD elements based on visibility.

Parameters
visibleFlag indicating if the reticle is visible

Pure virtual method called during tick to update HUD elements based on visibility. Implemented by derived classes to handle specific HUD element updates.

Implemented in makVre::DtDroneHudUpdater, and makVre::DtHumanHudUpdater.

◆ channelDestroyed()

virtual void makVre::DtHudUpdater::channelDestroyed ( const std::string & displayName,
const std::string & windowName,
const std::string & channelName )
protectedvirtual

Handles channel destruction event.

Parameters
displayNameName of the display
windowNameName of the window
channelNameName of the channel that was destroyed

◆ onViewportChanged()

virtual void makVre::DtHudUpdater::onViewportChanged ( )
protectedvirtual

Handles viewport change events.

Called when the viewport size or properties change

Reimplemented in makVre::DtHumanHudUpdater.

◆ deleteAll()

virtual void makVre::DtHudUpdater::deleteAll ( )
protectedvirtual

Deletes all HUD elements.

Removes all HUD elements managed by this updater

Reimplemented in makVre::DtHumanVrHudUpdater.

◆ onDeleteAll()

virtual void makVre::DtHudUpdater::onDeleteAll ( )
protectedpure virtual

Called when all HUD elements are being deleted.

Pure virtual method implemented by derived classes to handle cleanup of specific HUD elements when all elements are being deleted

Implemented in makVre::DtDroneHudUpdater, and makVre::DtHumanHudUpdater.

◆ findChannel()

virtual makVrv::DtOsgChannel * makVre::DtHudUpdater::findChannel ( const std::string & channelName = "Channel 1")
protectedvirtual

Finds a channel by name.

Parameters
channelNameName of the channel to find, defaults to "Channel 1"
Returns
Pointer to the found channel, or nullptr if not found

Looks up a channel by name. Finds the first channel if channelName is blank.

Reimplemented in makVre::DtDroneHudUpdater, and makVre::DtHumanVrHudUpdater.

◆ createOverlay()

virtual makVrv::DtOverlayRenderer * makVre::DtHudUpdater::createOverlay ( makVrv::DtOsgChannel * channel,
osg::Geode *& geodeOut )
protectedvirtual

Creates an overlay renderer for the specified channel.

Parameters
channelPointer to the channel to create the overlay for
geodeOut[out] Reference to the geode that will contain the overlay
Returns
Pointer to the created overlay renderer

◆ setupQuads()

virtual void makVre::DtHudUpdater::setupQuads ( )
protectedvirtual

Sets up quad elements for the HUD.

Initializes and configures quad elements used in the HUD

◆ slot_onChannelCreated()

void makVre::DtHudUpdater::slot_onChannelCreated ( )
protected

Handles channel creation event.

Sets myChannelsUpdated to true. In the next tick call, the updater will check to see if its channel exists.

◆ slot_onChannelToBeDestroyed()

void makVre::DtHudUpdater::slot_onChannelToBeDestroyed ( )
protected

Handles channel destruction notification.

Called when a channel is about to be destroyed

◆ createTexture()

virtual osg::Texture * makVre::DtHudUpdater::createTexture ( std::string path)
protectedvirtual

Creates a texture from an image file.

Parameters
pathPath to the image file
Returns
Pointer to the created texture, or nullptr if creation failed

◆ createQuads()

virtual void makVre::DtHudUpdater::createQuads ( makVrv::DtOverlayRenderer * overlay,
const std::vector< HudImageConfig > & configs )
protectedpure virtual

Creates all quad elements needed by a derived class.

Parameters
overlayPointer to the overlay renderer to create quads in
configsVector of image configurations to create quads from

Pure virtual method that must be implemented by derived classes to create all quads needed for their specific HUD elements.

Implemented in makVre::DtDroneHudUpdater, and makVre::DtHumanHudUpdater.

◆ createQuad()

virtual makVrv::DtQuadProxy * makVre::DtHudUpdater::createQuad ( makVrv::DtOverlayRenderer * overlay,
const HudImageConfig & config )
protectedvirtual

Creates a textured quad in the overlay.

Parameters
overlayPointer to the overlay renderer
configConfiguration for the image quad
Returns
Pointer to the created quad proxy

Creates a textured quad from the provided configuration. The x and y coordinates are percentages of screen in 0.0 to 1.0 range.

◆ createQuadWithColor()

virtual makVrv::DtQuadProxy * makVre::DtHudUpdater::createQuadWithColor ( makVrv::DtOverlayRenderer * overlay,
const HudColorQuadConfig & element )
protectedvirtual

Creates a colored quad in the overlay.

Parameters
overlayPointer to the overlay renderer
elementConfiguration for the colored quad
Returns
Pointer to the created quad proxy

◆ loadImageConfig()

virtual bool makVre::DtHudUpdater::loadImageConfig ( unsigned int e,
makVre::DtInitTable & imageTable,
std::string imageName,
bool loadDimensions = true )
protectedvirtual

Loads image configuration from an initialization table.

Parameters
eIndex of the image configuration
imageTableInitialization table containing image configurations
imageNameName of the image configuration
loadDimensionsFlag indicating if dimensions should be loaded
Returns
True if loading was successful, false otherwise

◆ loadTextConfig()

virtual bool makVre::DtHudUpdater::loadTextConfig ( unsigned int t,
makVre::DtInitTable & textTable,
std::string textName )
protectedvirtual

Loads text configuration from an initialization table.

Parameters
tIndex of the text configuration
textTableInitialization table containing text configurations
textNameName of the text configuration
Returns
True if loading was successful, false otherwise

◆ loadColorQuadConfig()

virtual bool makVre::DtHudUpdater::loadColorQuadConfig ( unsigned int quadIndex,
makVre::DtInitTable & colorQuadTable,
std::string colorQuadName,
bool loadDimensions = true )
protectedvirtual

Loads color quad configuration from an initialization table.

Parameters
quadIndexIndex of the color quad configuration
colorQuadTableInitialization table containing color quad configurations
colorQuadNameName of the color quad configuration
loadDimensionsFlag indicating if dimensions should be loaded
Returns
True if loading was successful, false otherwise

◆ loadColorConfig()

virtual bool makVre::DtHudUpdater::loadColorConfig ( makVre::DtColor & colorInfo,
makVre::DtInitTable & colorTable,
std::string colorName )
protectedvirtual

Loads color configuration from an initialization table.

Parameters
colorInfoColor information to load
colorTableInitialization table containing color configurations
colorNameName of the color configuration
Returns
True if loading was successful, false otherwise

◆ loadValueColorPairsConfig()

virtual bool makVre::DtHudUpdater::loadValueColorPairsConfig ( std::vector< HudValueColorPair > & valueColorPairsContainer,
makVre::DtInitTable & hudTable,
const std::string & valueColorPairsName )
protectedvirtual

Loads value-color pairs configuration from an initialization table.

Parameters
valueColorPairsContainerContainer for value-color pairs
hudTableInitialization table containing HUD configurations
valueColorPairsNameName of the value-color pairs configuration
Returns
True if loading was successful, false otherwise

◆ loadValueColorPairConfig()

virtual bool makVre::DtHudUpdater::loadValueColorPairConfig ( HudValueColorPair & valueColorPair,
makVre::DtInitTable & valueColorPairConfig )
protectedvirtual

◆ createAndInitTextProxy()

makVrv::DtTextProxy * makVre::DtHudUpdater::createAndInitTextProxy ( double normalizedX,
double normalizedY,
const std::string & defaultText )
protected

◆ handleEnterPlayerState()

virtual makVre::DtVreMessageResult makVre::DtHudUpdater::handleEnterPlayerState ( makVre::DtVreMessage * msg)
protectedvirtual

◆ handleExitPlayerState()

virtual makVre::DtVreMessageResult makVre::DtHudUpdater::handleExitPlayerState ( makVre::DtVreMessage * msg)
protectedvirtual

◆ overlayGroup()

virtual enum Layers makVre::DtHudUpdater::overlayGroup ( )
protectedvirtual

Member Data Documentation

◆ myTextItemMap

std::map<const makVre::HudTextItem*, std::pair<makVre::HudTextItem*, makVrv::DtTextProxy*> > makVre::DtHudUpdater::myTextItemMap
protected

Map of text items to their proxies.

Maps HUD text items to pairs of the item and its text proxy

◆ myImageItemMap

std::map<const makVre::HudImageItem*, std::pair<makVre::HudImageItem*, makVrv::DtQuadProxy*> > makVre::DtHudUpdater::myImageItemMap
protected

Map of image items to their proxies.

Maps HUD image items to pairs of the item and its quad proxy

◆ myActive

bool makVre::DtHudUpdater::myActive
protected

Flag indicating if this HUD updater is active.

◆ myUsingVr

DtAttributeHandleType<bool> makVre::DtHudUpdater::myUsingVr
protected

Handle to Attribute indicating if VR mode is currently enabled.

◆ myImages

std::vector<HudImageConfig> makVre::DtHudUpdater::myImages
protected

◆ myColorQuads

std::vector<HudColorQuadConfig> makVre::DtHudUpdater::myColorQuads
protected

◆ myTexts

std::vector<HudTextConfig> makVre::DtHudUpdater::myTexts
protected

◆ myOverlayInterface

makVrv::DtOverlayRenderer* makVre::DtHudUpdater::myOverlayInterface
protected

◆ myChannel

makVrv::DtOsgChannel* makVre::DtHudUpdater::myChannel
protected

◆ myFontSize

float makVre::DtHudUpdater::myFontSize
protected

◆ myFont

makVrv::DtFontInterface* makVre::DtHudUpdater::myFont
protected

◆ myFontFilePath

std::string makVre::DtHudUpdater::myFontFilePath
protected

◆ myLineHeight

int makVre::DtHudUpdater::myLineHeight
protected

◆ myGeode

osg::Geode* makVre::DtHudUpdater::myGeode
protected

◆ myChannelsUpdated

bool makVre::DtHudUpdater::myChannelsUpdated
protected

◆ myShowOverlays

bool makVre::DtHudUpdater::myShowOverlays
protected

The documentation for this class was generated from the following file: