|
VR-Engage
2.2
|
DtVirtualRealityLogic manages the connection between VR hardware (headsets and controllers) and the simulation, processing controller input events and managing the VR view state. It handles controller tracking, head position resetting, menu interactions, and mixed reality mode toggling. This component enables and disables VR mode during player state transitions, such as when entering menus.
#include <virtualRealityLogic.h>
Classes | |
| struct | ControllerIdentifier |
Public Member Functions | |
| DtVirtualRealityLogic () | |
| virtual | ~DtVirtualRealityLogic () override |
| virtual bool | initialize (makVre::DtPlayerStation *player, makVre::DtInitTable &config) override |
| virtual void | tick (double dt) override |
| virtual void | shutdown () override |
| virtual const char * | type () const override |
| virtual void | processControllerStates (const ControllerStateMap &controllers) |
| virtual void | resetHeadPos () |
| virtual void | handleResetHeadPosInput (int val) |
Public Member Functions inherited from makVre::DtPlayerComponent | |
| DtPlayerComponent () | |
| virtual | ~DtPlayerComponent () |
| virtual bool | postInitialize () |
| virtual void | setName (const std::string &name) |
| virtual const std::string & | name () |
| virtual DtPlayerStation & | player () |
| virtual DtAttributeHandle & | playerAttributeStore () |
| virtual const DtAttributeHandle & | playerAttributeStore () const |
Protected Member Functions | |
| virtual void | startVr () |
| virtual void | stopVr () |
| virtual makVre::DtVreMessageResult | handleResetVrHeadPos (makVre::DtVreMessage *msg) |
| virtual makVre::DtVreMessageResult | handleToggleMixedReality (makVre::DtVreMessage *msg) |
| virtual makVre::DtVreMessageResult | handleEnterPlayerState (makVre::DtVreMessage *msg) |
| virtual makVre::DtVreMessageResult | handleExitPlayerState (makVre::DtVreMessage *msg) |
| virtual const ControllerState * | findController (ControllerIdentifier &identifier, const ControllerStateMap &controllers) |
Protected Member Functions inherited from makVre::DtPlayerComponent | |
| virtual void | initializeStateAttributes () |
Protected Attributes | |
| makVrv::DtVirtualRealityDriver * | myVrDriver |
| DtVirtualRealityEventProcessor * | myEventProcessor |
| DtActionMenuLogic * | myMenuLogic |
| makVrv::DtSubmitOverlayCallback * | myVrOverlay |
| bool | myVrEnabled |
| bool | myVrWasEnabled |
| bool | myRightHanded |
| bool | myDidHaveHandMotion |
| ControllerIdentifier | myHeadId |
| ControllerIdentifier | myLeftHandId |
| ControllerIdentifier | myRightHandId |
| int | myFramesSinceMenu |
| DtVirtualDpad | myVirtualDpad |
| DtInputLogic | myInputLogic |
| int | myLastMainChannelRenderOrder |
Protected Attributes inherited from makVre::DtPlayerComponent | |
| std::string | myName |
| DtInitTable | myConfig |
| DtPlayerStation * | myPlayer |
| makVrv::DtDe * | myDe |
| DtEntityResolver * | myResolver |
| DtAttributeCallbackManager | myAttributeCallbacks |
| using makVre::DtVirtualRealityLogic::ControllerStateMap = makVrv::DtVirtualRealityEventManager::ControllerStateMap |
Type alias for a map of controller IDs to controller state pointers.
Type alias for controller type bitfield values.
| using makVre::DtVirtualRealityLogic::ControllerId = makVrv::DtVirtualRealityControllerState::ControllerId |
Type alias for controller identifier values.
| using makVre::DtVirtualRealityLogic::DtVector2f = makVrv::DtVirtualRealityControllerState::DtVector2f |
Type alias for 2D vector used in controller inputs.
Type alias for virtual reality controller state.
| makVre::DtVirtualRealityLogic::DtVirtualRealityLogic | ( | ) |
Constructor for DtVirtualRealityLogic.
Initializes the component with default settings for controller identification and tracking state
|
overridevirtual |
Virtual destructor for DtVirtualRealityLogic.
|
overridevirtual |
Initializes the virtual reality logic component.
| player | Pointer to the player station this component belongs to |
| config | Configuration table containing VR settings |
Sets up the VR driver connection, configures input handlers, and establishes message handlers for VR-related events
Reimplemented from makVre::DtPlayerComponent.
References makVre::DtPlayerComponent::player().
|
overridevirtual |
Called every frame to update the VR state.
| dt | Delta time since the last frame in seconds |
Monitors VR enabled state changes, updates controller tracking, and manages overlay visibility
Implements makVre::DtPlayerComponent.
|
overridevirtual |
Shuts down the virtual reality logic component.
Stops VR mode, disconnects message handlers, and performs cleanup operations
Reimplemented from makVre::DtPlayerComponent.
|
overridevirtual |
Returns the type identifier for this component.
Implements makVre::DtPlayerComponent.
Referenced by makVre::DtVirtualRealityLogic::ControllerIdentifier::ControllerIdentifier().
|
virtual |
Processes the current state of all tracked VR controllers.
| controllers | Map of controller IDs to their current state |
Handles controller discovery/loss events, processes button presses and thumbstick movements, and translates them into simulation actions
|
virtual |
Resets the HMD head position tracking.
Calls the VR driver to reset the head position and orientation reference
|
virtual |
Input handler for resetting head position.
| val | Input value (1 to trigger reset) |
Handles the reset head position input action from bound controls
|
protectedvirtual |
Starts VR mode.
Assigns observers to the HMD, sets up event handlers, configures post-processing, and updates state attributes
|
protectedvirtual |
Stops VR mode.
Removes event handlers, cleans up resources, and resets channel render orders
|
protectedvirtual |
Handles reset VR head position message.
| msg | The reset head position message |
Processes request to reset the VR headset position tracking
|
protectedvirtual |
Handles toggle mixed reality message.
| msg | The toggle mixed reality message |
Toggles between normal VR and mixed reality mode
|
protectedvirtual |
Handles player entering a state.
| msg | The enter player state message |
Processes state changes, particularly disabling VR when entering the menu state
|
protectedvirtual |
Handles player exiting a state.
| msg | The exit player state message |
Processes state changes, particularly re-enabling VR when exiting the menu state if VR was previously enabled
|
protectedvirtual |
Finds a controller in the controller state map.
| identifier | Controller identifier to find and update with current ID |
| controllers | Map of controller IDs to their current state |
Locates a controller either by cached ID or by searching for a matching type, updating the identifier's controllerId if found
|
protected |
Pointer to the VR driver for hardware interaction.
|
protected |
Processor for VR controller events.
|
protected |
Menu logic component for handling VR menu interactions.
|
protected |
Callback for submitting overlay graphics to VR display.
|
protected |
Flag indicating if VR is currently enabled.
|
protected |
Flag indicating if VR was enabled before entering a menu.
|
protected |
Flag indicating if the player uses right hand as dominant.
|
protected |
Flag tracking if hand motion was detected in the current frame.
|
protected |
Identifier for the HMD controller.
|
protected |
Identifier for the left hand controller.
|
protected |
Identifier for the right hand controller.
|
protected |
Counter for frames elapsed since menu interaction.
|
protected |
Virtual D-pad for converting analog input to digital directions.
|
protected |
Input logic for mapping actions to VR functions.
|
protected |
Cached render order for the main channel to restore when exiting VR.