VR-Engage  2.3
Loading...
Searching...
No Matches
makVre::DtCommanderHatchControlLogic Class Reference

Detailed Description

The DtCommanderHatchControlLogic provides the capability to look around as a human observer from a point of view on a vehicle (i.e., an open hatch) with support for binoculars and night vision goggles (NVG). It handles head movement (yaw/pitch) and equipment toggling (binoculars, NVG).

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

This class supports the following input handler functions that may be configured to map to input devices in role input configuration files:

  • "yaw": Controls horizontal head rotation
  • "pitch": Controls vertical head tilt
  • "toggle-binoculars": Toggles binocular use on/off
  • "toggle-nvg": Toggles night vision goggles on/off

The input group name is provided in the role configuration file and is used to distinguish input handlers when multiple handlers are present on the entity. The default input group is "commander-hatch".

#include <commanderHatchControlLogic.h>

Inheritance diagram for makVre::DtCommanderHatchControlLogic:
[legend]

Public Member Functions

 DtCommanderHatchControlLogic ()
 
virtual ~DtCommanderHatchControlLogic () 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
 
virtual void yaw (double val)
 
virtual void pitch (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)
 
- Public Member Functions inherited from makVre::DtEntityControlLogic
 DtEntityControlLogic ()
 
virtual ~DtEntityControlLogic () override
 
virtual void setMouseControlEnabled (bool enabled)
 
virtual bool isMouseControlEnabled ()
 
virtual bool isMouseControlSupportAllowed () const
 
virtual void setMouseControlSupportAllowed (bool enable)
 
virtual const std::vector< std::string > & joystickGroups () const
 
virtual void sendJoystickCommand (const DtEntityIdentifier &id, const std::string &functionGroup, const std::string &function, double val, bool repeat=false)
 
virtual makVre::DtVreMessageResult handleSimState (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleReset (makVre::DtVreMessage *message)
 
virtual makVre::DtVreMessageResult handleCreationStatus (makVre::DtVreMessage *message)
 
virtual void reset (float val)
 
virtual void resetInPlace (float val)
 
virtual void toggleMouseControl (float val)
 
virtual void enableMouseControl (float val)
 
virtual makVre::DtVreMessageResult handleFocusMessage (makVre::DtVreMessage *message)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
bool componentReady () const
 
void setComponentReady (bool ready)
 
virtual DtInitTickStatus finalizeInitTick (double dt)
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStation & player ()
 
virtual DtAttributeHandle & playerAttributeStore ()
 
virtual const DtAttributeHandle & playerAttributeStore () const
 
virtual const DtAttributeHandle & ownshipState () const
 
virtual void setExtendedData (const std::string &key, const std::string &value, DtEntityIdentifier entity=DtEntityIdentifier::nullId())
 

Protected Member Functions

virtual DtVreMessageResult handleMenuMessage (makVre::DtVreMessage *msg)
 
void onBinocularsChanged (bool usingBinoculars)
 
- Protected Member Functions inherited from makVre::DtEntityControlLogic
bool requiresControl () const
 
bool isAirborne () const
 
void showNotification (const QString &text, double duration)
 
virtual void takeControlOfPlayerEntity ()
 
virtual void releaseControlOfPlayerEntity ()
 
- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Protected Attributes

DtInputLogic myInputLogic
 
std::string myMainControlGroup
 
float myYawInput
 
float myPitchInput
 
DtAttributeHandleType< double > myViewMagnificationHandle
 
DtAttributeHandleType< double > myObserverYawHandle
 
DtAttributeHandleType< double > myObserverPitchHandle
 
DtAttributeHandleType< double > myMaxViewMagnificationHandle
 
DtAttributeHandleType< Equipment > myCurrentEquipmentHandle
 
DtAttributeHandleType< bool > myUsingBinocularsHandle
 
DtAttributeHandleType< bool > myIsNVGHandle
 
- Protected Attributes inherited from makVre::DtEntityControlLogic
std::vector< std::string > myJoystickFunctionGroups
 
DtInputLogic myCommonInputLogic
 
std::string myInputConfigFile
 
bool myMouseControlEnabled
 
bool myMouseControlSupportAllowed
 
DtAttributeHandle myOwnshipAttr
 
DtAttributeHandleType< bool > myEmbarkedAttr
 
DtAttributeHandleType< DtEntityIdentifier > myEmbarkedHostAttr
 
DtAttributeHandleType< DtEntityType > myEmbarkedHostTypeAttr
 
DtAttributeHandleType< std::string > myEmbarkedHostMarkingAttr
 
DtAttributeHandleType< bool > myEmbarkedOnAircraftAttr
 
DtAttributeHandleType< std::string > myEmbarkedInSlotAttr
 
DtAttributeHandleType< unsigned int > myAppearanceAttr
 
DtAttributeHandleType< DtVector > myPositionAttr
 
DtAttributeHandleType< DtTaitBryan > myOrientationAttr
 
DtAttributeHandleType< double > mySpeedAttr
 
DtAttributeHandleType< DtVector32 > myVelocityAttr
 
DtAttributeHandleType< DtVector32 > myAccelerationAttr
 
DtAttributeHandleType< DtVector32 > myRotVelAttr
 
DtAttributeHandleType< DtEntityType > myEntityTypeAttr
 
DtAttributeHandleType< DtVector32 > myRelativeVelocityAttr
 
DtAttributeHandleType< DtDamageState > myDamageStateAttr
 
DtAttributeHandleType< int > mySimStateUpdateIndexAttr
 
DtAttributeHandleType< bool > myHideOccupantsAttr
 
- Protected Attributes inherited from makVre::DtPlayerComponent
bool myComponentReady = true
 
std::string myName
 
DtInitTable myConfig
 
DtPlayerStation * myPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolver * myResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 
DtVreMessageHandlerGroup myMessageHandlers
 

Constructor & Destructor Documentation

◆ DtCommanderHatchControlLogic()

makVre::DtCommanderHatchControlLogic::DtCommanderHatchControlLogic ( )

Constructor for DtCommanderHatchControlLogic.

Initializes the component with the name "DtCommanderHatchControlLogic" and default values. Also checks out the required VR Engage Ground license.

◆ ~DtCommanderHatchControlLogic()

virtual makVre::DtCommanderHatchControlLogic::~DtCommanderHatchControlLogic ( )
overridevirtual

Virtual destructor for DtCommanderHatchControlLogic.

Member Function Documentation

◆ initialize()

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

Initializes the component with configuration from Lua.

Sets up input handlers for "yaw", "pitch", "toggle-binoculars", and "toggle-nvg". Initializes state attributes for equipment tracking:

  • "isCivilian": Boolean flag for civilian status (defaults to false)
  • "usingBinoculars": Boolean flag for binocular use (defaults to false)
  • "currentEquipment": Equipment enum value (defaults to NONE)
  • "NVG": Boolean flag for night vision goggles (defaults to false)
Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing initialization parameters
Returns
True if initialization succeeds, false otherwise

Reimplemented from makVre::DtEntityControlLogic.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

virtual bool makVre::DtCommanderHatchControlLogic::postInitialize ( )
overridevirtual

Performs post-initialization setup.

Initializes yaw and pitch input to zero to prevent display shaking before any input is applied. Sets up a change callback for the "usingBinoculars" state attribute.

Returns
True if post-initialization succeeds, false otherwise

Reimplemented from makVre::DtEntityControlLogic.

◆ tick()

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

Updates the component state.

Called each frame to update observer yaw and pitch based on input values. Scales input by delta time and current view magnification to maintain consistent control regardless of frame rate or zoom level.

Parameters
dtDelta time in seconds since the last tick

Reimplemented from makVre::DtEntityControlLogic.

◆ shutdown()

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

Shuts down the component.

Removes menu action message handler and usingBinoculars state attribute change callback. Also shuts down the input logic.

Reimplemented from makVre::DtEntityControlLogic.

◆ type()

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

Returns the component type identifier.

Returns
The component type string

Reimplemented from makVre::DtEntityControlLogic.

◆ yaw()

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

Input handler for horizontal head rotation (yaw)

Stores the input value in myYawInput for processing during tick().

Parameters
valThe yaw input value, typically from -1.0 to 1.0

◆ pitch()

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

Input handler for vertical head tilt (pitch)

Stores the input value in myPitchInput for processing during tick().

Parameters
valThe pitch input value, typically from -1.0 to 1.0

◆ toggleBinoculars()

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

Toggles binocular use on or off.

When triggered with a value of 1.0, toggles the "usingBinoculars" state attribute. If binoculars are activated:

  • Sets zoom level to the value of "maxViewMagnification" state attribute
  • Sets "currentEquipment" state attribute to BINOCULARS
  • Disables NVG if active If binoculars are deactivated:
  • Sets zoom level to 1.0
Parameters
valThe input value, a value of 1.0 triggers the toggle

◆ setBinocularsControls()

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

Enables or disables binocular-specific input controls.

When enabled, loads the "binoculars" input configuration and sets up the "zoom" action handler. When disabled, unloads the binoculars input configuration.

Parameters
enabledTrue to enable binocular controls, false to disable

◆ zoomOut()

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

Reduces binocular zoom level.

Sends a BinocularsZoomByMessage with a negative zoom value.

Parameters
valueThe amount to zoom out (positive value)

◆ zoomIn()

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

Increases binocular zoom level.

Sends a BinocularsZoomByMessage with a positive zoom value.

Parameters
valueThe amount to zoom in (positive value)

◆ zoom()

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

Combined input handler for binocular zoom.

Routes to zoomIn or zoomOut based on whether the input value is positive or negative.

Parameters
valueThe zoom input value, positive for zoom in, negative for zoom out

◆ toggleNVG()

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

Toggles night vision goggles (NVG) on or off.

When triggered with a value of 1.0, toggles the "NVG" state attribute. If NVG is activated:

  • Disables binoculars if active
  • Resets zoom level to 1.0
Parameters
valThe input value, a value of 1.0 triggers the toggle

◆ handleMenuMessage()

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

Handles menu action messages.

Processes menu actions, particularly the "toggleBinoculars" action which triggers the toggleBinoculars functionality.

Parameters
msgThe message to process
Returns
HANDLED if the message was processed, IGNORED otherwise

◆ onBinocularsChanged()

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

Callback for changes to the "usingBinoculars" state attribute.

Updates the "currentEquipment" state attribute and enables/disables binocular-specific input controls based on the new value.

Parameters
usingBinocularsThe new value of the usingBinoculars state attribute

Member Data Documentation

◆ myInputLogic

DtInputLogic makVre::DtCommanderHatchControlLogic::myInputLogic
protected

Input handler logic for processing input device events.

◆ myMainControlGroup

std::string makVre::DtCommanderHatchControlLogic::myMainControlGroup
protected

Main control group name from configuration.

Used to identify the function group when sending joystick messages.

◆ myYawInput

float makVre::DtCommanderHatchControlLogic::myYawInput
protected

Current yaw input value.

Stored during input handler calls and applied during tick().

◆ myPitchInput

float makVre::DtCommanderHatchControlLogic::myPitchInput
protected

Current pitch input value.

Stored during input handler calls and applied during tick().

◆ myViewMagnificationHandle

DtAttributeHandleType<double> makVre::DtCommanderHatchControlLogic::myViewMagnificationHandle
protected

Attribute handle storing the current view magnification level for input scaling.

Attribute Store KeyviewMagnification

◆ myObserverYawHandle

DtAttributeHandleType<double> makVre::DtCommanderHatchControlLogic::myObserverYawHandle
protected

Attribute handle storing the observer's current yaw (azimuth) angle in radians.

Attribute Store KeyobserverYaw

◆ myObserverPitchHandle

DtAttributeHandleType<double> makVre::DtCommanderHatchControlLogic::myObserverPitchHandle
protected

Attribute handle storing the observer's current pitch (elevation) angle in radians.

Attribute Store KeyobserverPitch

◆ myMaxViewMagnificationHandle

DtAttributeHandleType<double> makVre::DtCommanderHatchControlLogic::myMaxViewMagnificationHandle
protected

Attribute handle storing the maximum allowed view magnification.

Attribute Store KeymaxViewMagnification

◆ myCurrentEquipmentHandle

DtAttributeHandleType<Equipment> makVre::DtCommanderHatchControlLogic::myCurrentEquipmentHandle
protected

Attribute handle storing the equipment the commander currently has equipped.

Attribute Store KeycurrentEquipment

◆ myUsingBinocularsHandle

DtAttributeHandleType<bool> makVre::DtCommanderHatchControlLogic::myUsingBinocularsHandle
protected

Attribute handle indicating whether the commander is currently using binoculars.

Attribute Store KeyusingBinoculars

◆ myIsNVGHandle

DtAttributeHandleType<bool> makVre::DtCommanderHatchControlLogic::myIsNVGHandle
protected

Attribute handle indicating whether night vision goggles are active.

Attribute Store KeyNVG

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