VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtVirtualRealityLogic Class Reference

Detailed Description

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>

Inheritance diagram for makVre::DtVirtualRealityLogic:
[legend]

Classes

struct  ControllerIdentifier
 

Public Types

using ControllerStateMap = makVrv::DtVirtualRealityEventManager::ControllerStateMap
 
using Bitfield = makVrv::DtVirtualRealityControllerState::Bitfield
 
using ControllerId = makVrv::DtVirtualRealityControllerState::ControllerId
 
using DtVector2f = makVrv::DtVirtualRealityControllerState::DtVector2f
 
using ControllerState = makVrv::DtVirtualRealityControllerState
 

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 DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () 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 ControllerStatefindController (ControllerIdentifier &identifier, const ControllerStateMap &controllers)
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

makVrv::DtVirtualRealityDriver * myVrDriver
 
DtVirtualRealityEventProcessor * myEventProcessor
 
DtActionMenuLogicmyMenuLogic
 
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
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Member Typedef Documentation

◆ ControllerStateMap

Type alias for a map of controller IDs to controller state pointers.

◆ Bitfield

Type alias for controller type bitfield values.

◆ ControllerId

◆ DtVector2f

Type alias for 2D vector used in controller inputs.

◆ ControllerState

Type alias for virtual reality controller state.

Constructor & Destructor Documentation

◆ DtVirtualRealityLogic()

makVre::DtVirtualRealityLogic::DtVirtualRealityLogic ( )

Constructor for DtVirtualRealityLogic.

Initializes the component with default settings for controller identification and tracking state

◆ ~DtVirtualRealityLogic()

virtual makVre::DtVirtualRealityLogic::~DtVirtualRealityLogic ( )
overridevirtual

Virtual destructor for DtVirtualRealityLogic.

Member Function Documentation

◆ initialize()

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

Initializes the virtual reality logic component.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing VR settings
Returns
True if initialization succeeded, false otherwise

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().

◆ tick()

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

Called every frame to update the VR state.

Parameters
dtDelta time since the last frame in seconds

Monitors VR enabled state changes, updates controller tracking, and manages overlay visibility

Implements makVre::DtPlayerComponent.

◆ shutdown()

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

Shuts down the virtual reality logic component.

Stops VR mode, disconnects message handlers, and performs cleanup operations

Reimplemented from makVre::DtPlayerComponent.

◆ type()

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

Returns the type identifier for this component.

Returns
The type string for DtVirtualRealityLogic

Implements makVre::DtPlayerComponent.

Referenced by makVre::DtVirtualRealityLogic::ControllerIdentifier::ControllerIdentifier().

◆ processControllerStates()

virtual void makVre::DtVirtualRealityLogic::processControllerStates ( const ControllerStateMap & controllers)
virtual

Processes the current state of all tracked VR controllers.

Parameters
controllersMap of controller IDs to their current state

Handles controller discovery/loss events, processes button presses and thumbstick movements, and translates them into simulation actions

◆ resetHeadPos()

virtual void makVre::DtVirtualRealityLogic::resetHeadPos ( )
virtual

Resets the HMD head position tracking.

Calls the VR driver to reset the head position and orientation reference

◆ handleResetHeadPosInput()

virtual void makVre::DtVirtualRealityLogic::handleResetHeadPosInput ( int val)
virtual

Input handler for resetting head position.

Parameters
valInput value (1 to trigger reset)

Handles the reset head position input action from bound controls

◆ startVr()

virtual void makVre::DtVirtualRealityLogic::startVr ( )
protectedvirtual

Starts VR mode.

Assigns observers to the HMD, sets up event handlers, configures post-processing, and updates state attributes

◆ stopVr()

virtual void makVre::DtVirtualRealityLogic::stopVr ( )
protectedvirtual

Stops VR mode.

Removes event handlers, cleans up resources, and resets channel render orders

◆ handleResetVrHeadPos()

virtual makVre::DtVreMessageResult makVre::DtVirtualRealityLogic::handleResetVrHeadPos ( makVre::DtVreMessage * msg)
protectedvirtual

Handles reset VR head position message.

Parameters
msgThe reset head position message
Returns
Message handling result indicating if the message was handled

Processes request to reset the VR headset position tracking

◆ handleToggleMixedReality()

virtual makVre::DtVreMessageResult makVre::DtVirtualRealityLogic::handleToggleMixedReality ( makVre::DtVreMessage * msg)
protectedvirtual

Handles toggle mixed reality message.

Parameters
msgThe toggle mixed reality message
Returns
Message handling result indicating if the message was handled

Toggles between normal VR and mixed reality mode

◆ handleEnterPlayerState()

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

Handles player entering a state.

Parameters
msgThe enter player state message
Returns
Message handling result indicating if the message was handled

Processes state changes, particularly disabling VR when entering the menu state

◆ handleExitPlayerState()

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

Handles player exiting a state.

Parameters
msgThe exit player state message
Returns
Message handling result indicating if the message was handled

Processes state changes, particularly re-enabling VR when exiting the menu state if VR was previously enabled

◆ findController()

virtual const ControllerState * makVre::DtVirtualRealityLogic::findController ( ControllerIdentifier & identifier,
const ControllerStateMap & controllers )
protectedvirtual

Finds a controller in the controller state map.

Parameters
identifierController identifier to find and update with current ID
controllersMap of controller IDs to their current state
Returns
Pointer to the controller state if found, nullptr otherwise

Locates a controller either by cached ID or by searching for a matching type, updating the identifier's controllerId if found

Member Data Documentation

◆ myVrDriver

makVrv::DtVirtualRealityDriver* makVre::DtVirtualRealityLogic::myVrDriver
protected

Pointer to the VR driver for hardware interaction.

◆ myEventProcessor

DtVirtualRealityEventProcessor* makVre::DtVirtualRealityLogic::myEventProcessor
protected

Processor for VR controller events.

◆ myMenuLogic

DtActionMenuLogic* makVre::DtVirtualRealityLogic::myMenuLogic
protected

Menu logic component for handling VR menu interactions.

◆ myVrOverlay

makVrv::DtSubmitOverlayCallback* makVre::DtVirtualRealityLogic::myVrOverlay
protected

Callback for submitting overlay graphics to VR display.

◆ myVrEnabled

bool makVre::DtVirtualRealityLogic::myVrEnabled
protected

Flag indicating if VR is currently enabled.

◆ myVrWasEnabled

bool makVre::DtVirtualRealityLogic::myVrWasEnabled
protected

Flag indicating if VR was enabled before entering a menu.

◆ myRightHanded

bool makVre::DtVirtualRealityLogic::myRightHanded
protected

Flag indicating if the player uses right hand as dominant.

◆ myDidHaveHandMotion

bool makVre::DtVirtualRealityLogic::myDidHaveHandMotion
protected

Flag tracking if hand motion was detected in the current frame.

◆ myHeadId

ControllerIdentifier makVre::DtVirtualRealityLogic::myHeadId
protected

Identifier for the HMD controller.

◆ myLeftHandId

ControllerIdentifier makVre::DtVirtualRealityLogic::myLeftHandId
protected

Identifier for the left hand controller.

◆ myRightHandId

ControllerIdentifier makVre::DtVirtualRealityLogic::myRightHandId
protected

Identifier for the right hand controller.

◆ myFramesSinceMenu

int makVre::DtVirtualRealityLogic::myFramesSinceMenu
protected

Counter for frames elapsed since menu interaction.

◆ myVirtualDpad

DtVirtualDpad makVre::DtVirtualRealityLogic::myVirtualDpad
protected

Virtual D-pad for converting analog input to digital directions.

◆ myInputLogic

DtInputLogic makVre::DtVirtualRealityLogic::myInputLogic
protected

Input logic for mapping actions to VR functions.

◆ myLastMainChannelRenderOrder

int makVre::DtVirtualRealityLogic::myLastMainChannelRenderOrder
protected

Cached render order for the main channel to restore when exiting VR.


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