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

Detailed Description

DtLookAroundInputLogic provides the capability to look around as a human observer from a point of view on a vehicle (i.e., an open hatch) with options for binoculars and night vision. It handles inputs for view orientation, equipment toggling, and mouse/joystick controls.

Input handler details (for configuring in an SMS input configuration file):

  • Input group: "look-around"
  • Handler functions: "yaw", "pitch", "joystickYaw", "joystickPitch", "toggle-binoculars", "toggle-nvg", "reset-view", "enable-free-look"

#include <lookAroundInputLogic.h>

Inheritance diagram for makVre::DtLookAroundInputLogic:
[legend]

Public Member Functions

 DtLookAroundInputLogic (makVrv::DtDe &de, DtLookAroundObserverUpdater &updater)
 
virtual ~DtLookAroundInputLogic () override
 
virtual void initialize () override
 
virtual void shutdown () override
 
virtual void tick (double dt)
 
virtual void yaw (double val)
 
virtual void pitch (double val)
 
virtual void joystickYaw (double val)
 
virtual void joystickPitch (double val)
 
virtual void toggleBinoculars (double val)
 
virtual void setBinocularsControls (bool enabled)
 
virtual void zoomOut (double value)
 
virtual void zoomIn (double value)
 
virtual void zoom (double value)
 
virtual void toggleNVG (double val)
 
virtual void toggleMouseControl (float val)
 
virtual void enableMouseControl (float val)
 
virtual makVre::DtVreMessageResult handleFocusMessage (makVre::DtVreMessage *message)
 
virtual void setMouseControlEnabled (bool enabled)
 
virtual bool isMouseControlEnabled ()
 
virtual bool isMouseControlSupportAllowed () const
 
virtual void setMouseControlSupportAllowed (bool enable)
 
virtual void returnToInitialView (float value)
 
virtual void freeLook (double val)
 
- Public Member Functions inherited from makVre::DtInputLogic
 DtInputLogic ()
 
virtual ~DtInputLogic ()
 
virtual bool loadInputConfig (const std::string &config, const std::string &group, bool alwaysOnTop=false, bool alwaysEnabled=false)
 
virtual void unloadInputConfig (const std::string &category, const std::string &group)
 
virtual void addActionHandler (const std::string &group, const std::string &action, const DtActionDelegate &handler)
 
virtual void removeActionGroup (const std::string &group)
 
virtual void setRawInputHandler (const DtInputDelegate &inputDelegate)
 
virtual void removeRawInputHandler ()
 
virtual void removeActionHandler (const std::string &group, const std::string &action)
 

Protected Member Functions

virtual DtVreMessageResult handleMenuMessage (makVre::DtVreMessage *msg)
 
void onBinocularsChanged (bool usingBinoculars)
 

Protected Attributes

std::string myEntityName
 
makVrv::DtDe & myDe
 
std::string myClassName
 
std::string myInputConfigFile
 
bool myMouseControlEnabled
 
bool myMouseControlSupportAllowed
 
DtLookAroundObserverUpdatermyUpdater
 
float myMouseYawInput
 
float myMousePitchInput
 
float myJoystickYawInput
 
float myJoystickPitchInput
 
bool myJoystickMoving
 
DtAttributeCallbackManager myAttributeCallbacks
 
- Protected Attributes inherited from makVre::DtInputLogic
DtVreInputManagermyInputManager
 
std::vector< std::pair< std::string, std::string > > myInputConfigurations
 
std::unordered_map< std::string, std::vector< std::string > > myActionGroups
 
bool myHandlingRawInput
 

Constructor & Destructor Documentation

◆ DtLookAroundInputLogic()

makVre::DtLookAroundInputLogic::DtLookAroundInputLogic ( makVrv::DtDe & de,
DtLookAroundObserverUpdater & updater )

Constructor for DtLookAroundInputLogic.

Parameters
deReference to the distributed environment
updaterReference to the associated observer updater

Initializes input state with default values and establishes connection with the corresponding observer updater

References de().

◆ ~DtLookAroundInputLogic()

virtual makVre::DtLookAroundInputLogic::~DtLookAroundInputLogic ( )
overridevirtual

Virtual destructor for DtLookAroundInputLogic.

Member Function Documentation

◆ initialize()

virtual void makVre::DtLookAroundInputLogic::initialize ( )
overridevirtual

Initializes the look-around input component.

Sets up message handlers, loads input configurations, configures input action handlers, and enables mouse control by default

Reimplemented from makVre::DtInputLogic.

◆ shutdown()

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

Shuts down the look-around input component.

Removes message handlers, cleans up input configurations, and disables mouse control

Reimplemented from makVre::DtInputLogic.

◆ tick()

virtual void makVre::DtLookAroundInputLogic::tick ( double dt)
virtual

Called every frame to update view orientation based on input.

Parameters
dtDelta time since the last frame in seconds

Updates state attributes "observerYaw" and "observerPitch" based on mouse and joystick inputs, applying appropriate scaling based on delta time and view magnification

◆ yaw()

virtual void makVre::DtLookAroundInputLogic::yaw ( double val)
virtual

Handles mouse-based yaw (horizontal rotation) input.

Parameters
valInput value for yaw rate (-1.0 to 1.0)

Caches the yaw input value to be applied during tick(), but only if the player is not a spectator and look-around mode is active

◆ pitch()

virtual void makVre::DtLookAroundInputLogic::pitch ( double val)
virtual

Handles mouse-based pitch (vertical rotation) input.

Parameters
valInput value for pitch rate (-1.0 to 1.0)

Caches the pitch input value to be applied during tick(), but only if the player is not a spectator and look-around mode is active

◆ joystickYaw()

virtual void makVre::DtLookAroundInputLogic::joystickYaw ( double val)
virtual

Handles joystick-based yaw (horizontal rotation) input.

Parameters
valInput value for yaw rate (-1.0 to 1.0)

Caches the joystick yaw input value to be applied during tick()

◆ joystickPitch()

virtual void makVre::DtLookAroundInputLogic::joystickPitch ( double val)
virtual

Handles joystick-based pitch (vertical rotation) input.

Parameters
valInput value for pitch rate (-1.0 to 1.0)

Caches the joystick pitch input value to be applied during tick()

◆ toggleBinoculars()

virtual void makVre::DtLookAroundInputLogic::toggleBinoculars ( double val)
virtual

Toggles binoculars on or off.

Parameters
valInput value (1.0 to toggle binoculars)

If incoming value is 1.0, toggles binoculars on/off:

  • If toggled on, sets zoom level to "maxViewMagnification" state attribute
  • If toggled off, sets zoom level to 1.0
  • Disables NVG if it is enabled when binoculars are toggled on
  • New zoom level is sent in a BinocularsZoomToMessage

◆ setBinocularsControls()

virtual void makVre::DtLookAroundInputLogic::setBinocularsControls ( bool enabled)
virtual

Enables or disables binocular-specific input controls.

Parameters
enabledTrue to enable binocular controls, false to disable

Loads or unloads binocular-specific input configuration based on the enabled state

◆ zoomOut()

virtual void makVre::DtLookAroundInputLogic::zoomOut ( double value)
virtual

Decreases binocular zoom level.

Parameters
valueAmount to decrease zoom by

Sends a BinocularsZoomByMessage with a negative zoom value

◆ zoomIn()

virtual void makVre::DtLookAroundInputLogic::zoomIn ( double value)
virtual

Increases binocular zoom level.

Parameters
valueAmount to increase zoom by

Sends a BinocularsZoomByMessage with a positive zoom value

◆ zoom()

virtual void makVre::DtLookAroundInputLogic::zoom ( double value)
virtual

Handles continuous zoom level input.

Parameters
valueInput value (-1.0 to 1.0) for zoom direction and speed

Calls zoomIn for positive values or zoomOut for negative values

◆ toggleNVG()

virtual void makVre::DtLookAroundInputLogic::toggleNVG ( double val)
virtual

Toggles night vision goggles (NVG) on or off.

Parameters
valInput value (1.0 to toggle NVG)

If incoming value is 1.0, toggles NVG on/off:

  • If toggled on, disables binoculars if they are active and sets "NVG" attribute to true
  • If toggled off, sets "NVG" attribute to false
  • Has no effect if NVG is not enabled in the component configuration

◆ toggleMouseControl()

virtual void makVre::DtLookAroundInputLogic::toggleMouseControl ( float val)
virtual

Toggles mouse control on or off.

Parameters
valInput value (1.0 to toggle mouse control)

Inverts the current mouse control state if the input value is 1.0

◆ enableMouseControl()

virtual void makVre::DtLookAroundInputLogic::enableMouseControl ( float val)
virtual

Enables mouse control.

Parameters
valInput value (1.0 to enable mouse control)

Enables mouse control if it's not already enabled and the input value is 1.0

◆ handleFocusMessage()

virtual makVre::DtVreMessageResult makVre::DtLookAroundInputLogic::handleFocusMessage ( makVre::DtVreMessage * message)
virtual

Handles focus state change messages.

Parameters
messageThe focus state message
Returns
Message handling result indicating if the message was handled

Updates mouse control based on application focus state

◆ setMouseControlEnabled()

virtual void makVre::DtLookAroundInputLogic::setMouseControlEnabled ( bool enabled)
virtual

Sets the mouse control enabled state.

Parameters
enabledTrue to enable mouse control, false to disable

Sends a ToggleMouseControlMessage with the new state

◆ isMouseControlEnabled()

virtual bool makVre::DtLookAroundInputLogic::isMouseControlEnabled ( )
virtual

Checks if mouse control is currently enabled.

Returns
True if mouse control is enabled, false otherwise

◆ isMouseControlSupportAllowed()

virtual bool makVre::DtLookAroundInputLogic::isMouseControlSupportAllowed ( ) const
virtual

Checks if mouse control support is allowed.

Returns
True if mouse control support is allowed, false otherwise

This differs from isMouseControlEnabled() in that it determines whether mouse control is supported at all, not just whether it's currently active

◆ setMouseControlSupportAllowed()

virtual void makVre::DtLookAroundInputLogic::setMouseControlSupportAllowed ( bool enable)
virtual

Sets whether mouse control support is allowed.

Parameters
enableTrue to allow mouse control support, false to disallow

Controls whether mouse control functionality is available at all

◆ returnToInitialView()

virtual void makVre::DtLookAroundInputLogic::returnToInitialView ( float value)
virtual

Returns the view to its initial orientation.

Parameters
valueInput value (1.0 to reset view)

If the input value is 1.0, resets the observer view to its initial orientation

◆ freeLook()

virtual void makVre::DtLookAroundInputLogic::freeLook ( double val)
virtual

Enables or disables free-look mode.

Parameters
valInput value (1.0 to enable, 0.0 to disable)

Controls whether the player can freely look around, and resets input values when free-look is disabled

◆ handleMenuMessage()

virtual DtVreMessageResult makVre::DtLookAroundInputLogic::handleMenuMessage ( makVre::DtVreMessage * msg)
protectedvirtual

Handles menu action messages.

Parameters
msgThe menu action message
Returns
Message handling result indicating if the message was handled

If the incoming message action is "toggleBinoculars", calls toggleBinoculars(1)

◆ onBinocularsChanged()

void makVre::DtLookAroundInputLogic::onBinocularsChanged ( bool usingBinoculars)
protected

Callback for changes to the usingBinoculars attribute.

Parameters
usingBinocularsNew value of the usingBinoculars attribute

Updates the currentEquipment attribute and binoculars controls based on the new binoculars state

Member Data Documentation

◆ myEntityName

std::string makVre::DtLookAroundInputLogic::myEntityName
protected

Name of the entity this component is controlling.

◆ myDe

makVrv::DtDe& makVre::DtLookAroundInputLogic::myDe
protected

Reference to the distributed environment.

◆ myClassName

std::string makVre::DtLookAroundInputLogic::myClassName
protected

Class name for logging and identification.

◆ myInputConfigFile

std::string makVre::DtLookAroundInputLogic::myInputConfigFile
protected

Path to the input configuration file.

◆ myMouseControlEnabled

bool makVre::DtLookAroundInputLogic::myMouseControlEnabled
protected

Flag indicating if mouse control is currently enabled.

◆ myMouseControlSupportAllowed

bool makVre::DtLookAroundInputLogic::myMouseControlSupportAllowed
protected

Flag indicating if mouse control is supported at all.

◆ myUpdater

DtLookAroundObserverUpdater& makVre::DtLookAroundInputLogic::myUpdater
protected

Reference to the associated look-around observer updater.

Used to communicate with the observer component that this input logic controls

◆ myMouseYawInput

float makVre::DtLookAroundInputLogic::myMouseYawInput
protected

Cached mouse yaw input value.

◆ myMousePitchInput

float makVre::DtLookAroundInputLogic::myMousePitchInput
protected

Cached mouse pitch input value.

◆ myJoystickYawInput

float makVre::DtLookAroundInputLogic::myJoystickYawInput
protected

Cached joystick yaw input value.

◆ myJoystickPitchInput

float makVre::DtLookAroundInputLogic::myJoystickPitchInput
protected

Cached joystick pitch input value.

◆ myJoystickMoving

bool makVre::DtLookAroundInputLogic::myJoystickMoving
protected

Flag indicating if joystick input is currently active.

◆ myAttributeCallbacks

DtAttributeCallbackManager makVre::DtLookAroundInputLogic::myAttributeCallbacks
protected

Member-scope instance of Attribute callback manager.

Used to manage Attribute change callback connections and ensure that all callbacks are unregistered when this class instance is destroyed.


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