|
VR-Engage
2.2
|
This component shows how to:
The component inherits from DtPlayerComponent and is registered with the player station's component factory for role-based instantiation. It works in conjunction with a QML overlay (configured separately) that displays the vehicle damage information.
Integration Pattern: This component creates attribute store entries that QML files can bind to using the VR-Engage QML bridge. The QML overlay reads these attributes reactively and updates the UI when values change.
Message Handling: Uses the legacy delegate-based message handling pattern. For new code, consider using the lambda-based subscription pattern shown in other examples.
#include <driverQmlHudComponent.h>
Public Member Functions | |
| DtDriverQmlHudComponent () | |
| virtual | ~DtDriverQmlHudComponent () override=default |
| 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 |
| virtual makVre::DtVreMessageResult | handleSimState (makVre::DtVreMessage *msg) |
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 Attributes | |
| makVre::DtAttributeHandle | myVehicleDamageState |
Protected Attributes inherited from makVre::DtPlayerComponent | |
| std::string | myName |
| DtInitTable | myConfig |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
Additional Inherited Members | |
Protected Member Functions inherited from makVre::DtPlayerComponent | |
| virtual void | initializeStateAttributes () |
| DtDriverQmlHudComponent::DtDriverQmlHudComponent | ( | ) |
Constructs the driver QML HUD component.
Default constructor. Actual initialization is deferred to the initialize() method following the VR-Engage component lifecycle pattern.
|
overridevirtualdefault |
Destructor (compiler-generated).
|
overridevirtual |
Initializes the component with player station and configuration.
This method demonstrates the standard VR-Engage component initialization pattern:
Pattern Note: Attribute store access should be done in postInitialize() to ensure all components have been constructed and basic initialization is complete.
| player | The player station instance this component belongs to |
| config | Configuration table containing role parameters (unused in this example) |
Reimplemented from makVre::DtPlayerComponent.
References makVre::DtPlayerComponent::player().
|
overridevirtual |
Completes initialization after all components are initialized.
This method demonstrates the proper phase for attribute store setup:
Design Pattern: Use postInitialize() for cross-component dependencies and attribute store manipulation, as all components are guaranteed to exist at this point.
Reimplemented from makVre::DtPlayerComponent.
|
inlineoverridevirtual |
Per-frame update callback.
Empty implementation - this component is purely message-driven and does not require per-frame updates. All state changes happen in response to SimulationStateMessage.
| dt | Elapsed time since last tick in seconds (unused) |
Implements makVre::DtPlayerComponent.
|
overridevirtual |
Cleanup and resource release.
Unregisters message handlers to prevent callbacks after component destruction. This is critical for avoiding dangling pointers when the component is destroyed.
Reimplemented from makVre::DtPlayerComponent.
|
overridevirtual |
Returns the component type identifier string.
Used by the VR-Engage framework for component identification and factory registration.
Implements makVre::DtPlayerComponent.
|
virtual |
Handles simulation state messages to update vehicle damage status.
This message handler demonstrates:
Message Pattern: Uses the legacy delegate-based handler pattern. The handler is registered in initialize() and unregistered in shutdown().
| msg | The simulation state message containing entity appearance data |
|
protected |
Handle to the vehicle damage state attribute hierarchy.
This attribute contains two boolean child attributes:
QML overlays bind to these attributes to reactively display damage state in the UI. The handle is obtained in postInitialize() and updated in handleSimState().