|
VR-Engage
2.2
|
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>
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 DtPlayerStation & | player () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () 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< HudImageConfig > | myImages |
| std::vector< HudColorQuadConfig > | myColorQuads |
| std::vector< HudTextConfig > | myTexts |
| 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 |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
|
protected |
| makVre::DtHudUpdater::DtHudUpdater | ( | ) |
Constructor.
Creates a new HUD updater component with default state.
|
overridevirtual |
Virtual destructor.
|
overridevirtual |
Initializes the HUD updater.
| player | Pointer to the player station |
| config | Configuration settings for initialization |
Reimplemented from makVre::DtPlayerComponent.
Reimplemented in makVre::DtDroneHudUpdater, makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.
References makVre::DtPlayerComponent::player().
|
overridevirtual |
Performs post-initialization setup.
Reimplemented from makVre::DtPlayerComponent.
Reimplemented in makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.
|
overridevirtual |
Updates the HUD elements for the current frame.
| dt | Delta time since the last frame in seconds |
Implements makVre::DtPlayerComponent.
Reimplemented in makVre::DtDroneHudUpdater, makVre::DtHumanHudUpdater, and makVre::DtHumanVrHudUpdater.
|
overridevirtual |
Cleans up resources when the component is being shut down.
Reimplemented from makVre::DtPlayerComponent.
Reimplemented in makVre::DtHumanVrHudUpdater.
|
overridevirtual |
Returns the component type identifier.
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.
| void makVre::DtHudUpdater::addItem | ( | makVre::HudItem * | item | ) |
Adds a HUD item to this updater.
| item | Pointer to the HUD item to add |
| void makVre::DtHudUpdater::removeItem | ( | makVre::HudItem * | item | ) |
Removes a HUD item from this updater.
| item | Pointer to the HUD item to remove |
| makVrv::DtOverlayRenderer * makVre::DtHudUpdater::getOverlay | ( | ) | const |
Gets the overlay renderer used by this HUD updater.
|
inline |
Converts normalized x-coordinate to pixel x-coordinate.
| norm | Normalized x-coordinate (0.0 to 1.0) |
|
inline |
Converts normalized y-coordinate to pixel y-coordinate.
| norm | Normalized y-coordinate (0.0 to 1.0) |
|
inline |
Converts normalized width to pixel width.
| norm | Normalized width (0.0 to 1.0) |
|
inline |
Converts normalized height to pixel height.
| norm | Normalized height (0.0 to 1.0) |
|
protected |
Calculates heading angle between observer and target positions.
| geocentricObserverPosition | Geocentric position of the observer |
| geocentricTargetPosition | Geocentric position of the target |
Utility function used by derived classes to calculate heading for HUD elements
|
protectedvirtual |
Starts this HUD updater.
Initializes and shows HUD elements
|
protectedvirtual |
Stops this HUD updater.
Hides and cleans up HUD elements
|
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.
|
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.
|
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.
|
protectedvirtual |
Sets up overlay renderers for HUD elements.
Creates and configures overlay renderers for displaying HUD elements
|
protectedpure virtual |
Updates HUD elements based on visibility.
| visible | Flag 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.
|
protectedvirtual |
Handles channel destruction event.
| displayName | Name of the display |
| windowName | Name of the window |
| channelName | Name of the channel that was destroyed |
|
protectedvirtual |
Handles viewport change events.
Called when the viewport size or properties change
Reimplemented in makVre::DtHumanHudUpdater.
|
protectedvirtual |
Deletes all HUD elements.
Removes all HUD elements managed by this updater
Reimplemented in makVre::DtHumanVrHudUpdater.
|
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.
|
protectedvirtual |
Finds a channel by name.
| channelName | Name of the channel to find, defaults to "Channel 1" |
Looks up a channel by name. Finds the first channel if channelName is blank.
Reimplemented in makVre::DtDroneHudUpdater, and makVre::DtHumanVrHudUpdater.
|
protectedvirtual |
Creates an overlay renderer for the specified channel.
| channel | Pointer to the channel to create the overlay for |
| geodeOut | [out] Reference to the geode that will contain the overlay |
|
protectedvirtual |
Sets up quad elements for the HUD.
Initializes and configures quad elements used in the HUD
|
protected |
Handles channel creation event.
Sets myChannelsUpdated to true. In the next tick call, the updater will check to see if its channel exists.
|
protected |
Handles channel destruction notification.
Called when a channel is about to be destroyed
|
protectedvirtual |
Creates a texture from an image file.
| path | Path to the image file |
|
protectedpure virtual |
Creates all quad elements needed by a derived class.
| overlay | Pointer to the overlay renderer to create quads in |
| configs | Vector 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.
|
protectedvirtual |
Creates a textured quad in the overlay.
| overlay | Pointer to the overlay renderer |
| config | Configuration for the image quad |
Creates a textured quad from the provided configuration. The x and y coordinates are percentages of screen in 0.0 to 1.0 range.
|
protectedvirtual |
Creates a colored quad in the overlay.
| overlay | Pointer to the overlay renderer |
| element | Configuration for the colored quad |
|
protectedvirtual |
Loads image configuration from an initialization table.
| e | Index of the image configuration |
| imageTable | Initialization table containing image configurations |
| imageName | Name of the image configuration |
| loadDimensions | Flag indicating if dimensions should be loaded |
|
protectedvirtual |
Loads text configuration from an initialization table.
| t | Index of the text configuration |
| textTable | Initialization table containing text configurations |
| textName | Name of the text configuration |
|
protectedvirtual |
Loads color quad configuration from an initialization table.
| quadIndex | Index of the color quad configuration |
| colorQuadTable | Initialization table containing color quad configurations |
| colorQuadName | Name of the color quad configuration |
| loadDimensions | Flag indicating if dimensions should be loaded |
|
protectedvirtual |
Loads color configuration from an initialization table.
| colorInfo | Color information to load |
| colorTable | Initialization table containing color configurations |
| colorName | Name of the color configuration |
|
protectedvirtual |
Loads value-color pairs configuration from an initialization table.
| valueColorPairsContainer | Container for value-color pairs |
| hudTable | Initialization table containing HUD configurations |
| valueColorPairsName | Name of the value-color pairs configuration |
|
protectedvirtual |
|
protected |
|
protectedvirtual |
|
protectedvirtual |
|
protectedvirtual |
|
protected |
Map of text items to their proxies.
Maps HUD text items to pairs of the item and its text proxy
|
protected |
Map of image items to their proxies.
Maps HUD image items to pairs of the item and its quad proxy
|
protected |
Flag indicating if this HUD updater is active.
|
protected |
Handle to Attribute indicating if VR mode is currently enabled.
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |