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

Detailed Description

The DtCommanderHatchViewUpdater updates the visual aspects of the commander-hatch role. It orients the observer based on state attributes and provides specialized visual effects such as binocular zoom and night vision goggles.

The following parameters are available for configuration in the role file:

  • "observerName": Name of the observer to control (defaults to "Observer 1")
  • "partAttachment": DIS enumeration for the vehicle part to attach the eyepoint (defaults to -1, which represents the base part/vehicle itself)
  • "attachedLocationOffset": Vector offset from attachment point in meters (coordinates: +x right, +y front, +z up)

#include <commanderHatchViewUpdater.h>

Inheritance diagram for makVre::DtCommanderHatchViewUpdater:
[legend]

Public Member Functions

 DtCommanderHatchViewUpdater ()
 
virtual ~DtCommanderHatchViewUpdater () override
 
virtual bool initialize (DtPlayerStation *player, DtInitTable &config) override
 
virtual void tick (double dt) override
 
void updateBinocularsState (double dt)
 
void updateNVGState ()
 
virtual void shutdown () override
 
virtual const char * type () const override
 
- Public Member Functions inherited from makVre::DtObserverUpdater
 DtObserverUpdater ()
 
virtual ~DtObserverUpdater () override
 
virtual bool postInitialize () override
 
virtual void addChannelToUpdate (const std::string &windowName, const std::string &channelName)
 
virtual void removeChannelToUpdate (const std::string &windowName, const std::string &channelName, bool restoreInitialSettings=true)
 
- Public Member Functions inherited from makVre::DtPlayerComponent
 DtPlayerComponent ()
 
virtual ~DtPlayerComponent ()
 
virtual void setName (const std::string &name)
 
virtual const std::string & name ()
 
virtual DtPlayerStationplayer ()
 
virtual DtAttributeHandleplayerAttributeStore ()
 
virtual const DtAttributeHandleplayerAttributeStore () const
 

Protected Member Functions

virtual makVre::DtVreMessageResult handlePlayerCreated (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handlePlayerReset (makVre::DtVreMessage *msg)
 
virtual void setupObserver ()
 
- Protected Member Functions inherited from makVre::DtObserverUpdater
virtual void initializeStateAttributes () override
 
virtual void onSensorModeChanged (std::string sensorMode)
 
virtual void onObserverModeChanged (std::string observerMode)
 
virtual void addDefaultChannels ()
 
virtual void addVrChannels ()
 
virtual bool findChannelConfiguration (const std::string &windowName, const std::string &channelName, makVrv::DtChannelConfiguration &config)
 
virtual void updateAllChannels ()
 
virtual void setShowCockpits (bool show)
 
virtual bool applyConfigurationToChannel (const std::string &windowName, const std::string &channelName, const makVrv::DtChannelConfiguration &newConfig)
 
bool firstWindowAndChannelNames (std::string &windowName, std::string &channelName)
 
virtual void updateStateAttributes ()
 

Protected Attributes

int myPartAttachment
 
DtVector myAttachedLocationOffset
 
DtQuaternion myAttachedRotationOffset
 
makVre::DtLinearInterpolator< double > * myZoomInterpolator
 
makVrv::DtObserver * myObserver
 
bool myLimitObserverRange
 
ObserverRange myYawRange
 
ObserverRange myPitchRange
 
bool myLastNVGState
 
- Protected Attributes inherited from makVre::DtObserverUpdater
makVre::DtInstrumentPanelManagermyInstrumentPanelManager
 
ChannelConfigMap myChannelsToUpdate
 
bool myForceChannelUpdate
 
double myVerticalFOV
 
double myHorizontalFOV
 
makVrv::DtWindow * myWindow
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Additional Inherited Members

- Protected Types inherited from makVre::DtObserverUpdater
using WindowAndChannelName = std::pair<std::string, std::string>
 
using ChannelConfigMap = std::map<WindowAndChannelName, makVrv::DtChannelConfiguration>
 

Constructor & Destructor Documentation

◆ DtCommanderHatchViewUpdater()

makVre::DtCommanderHatchViewUpdater::DtCommanderHatchViewUpdater ( )

Constructor for DtCommanderHatchViewUpdater.

Initializes the component with default values including identity rotation offset and no zoom interpolator.

◆ ~DtCommanderHatchViewUpdater()

virtual makVre::DtCommanderHatchViewUpdater::~DtCommanderHatchViewUpdater ( )
overridevirtual

Virtual destructor for DtCommanderHatchViewUpdater.

Member Function Documentation

◆ initialize()

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

Initializes the component with configuration from Lua.

Reads configuration values including observer name, part attachment ID, and attached location offset. Caches a pointer to the observer and adds handlers for PlayerCreatedMessage and ResetMessage.

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::DtObserverUpdater.

References makVre::DtPlayerComponent::player().

◆ tick()

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

Updates the visual aspects of the commander view.

Reads "observerYaw" and "observerPitch" state attributes and updates the observer's attached orientation accordingly. Calls updateBinocularsState() to handle zoom effects and updateNVGState() to handle night vision mode switching.

Parameters
dtDelta time in seconds since the last tick

Reimplemented from makVre::DtObserverUpdater.

◆ updateBinocularsState()

void makVre::DtCommanderHatchViewUpdater::updateBinocularsState ( double dt)

Updates binocular zoom effects.

Checks the "viewMagnification" state attribute and manages the zoom interpolator to create smooth transitions between zoom levels. Creates the interpolator when needed, updates its endpoint if the target zoom changes, and applies the interpolated value to the observer's view magnification.

Parameters
dtDelta time in seconds since the last tick

◆ updateNVGState()

void makVre::DtCommanderHatchViewUpdater::updateNVGState ( )

Updates night vision goggles state.

Checks the boolean "NVG" state attribute and, if it has changed since the last update, sets the observer's sensor mode accordingly. When NVG is activated, uses the VR-Engage sensor mode mapper to find the appropriate VR-Vantage sensor mode.

◆ shutdown()

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

Shuts down the component.

Removes message handlers for PlayerCreatedMessage and ResetMessage.

Reimplemented from makVre::DtObserverUpdater.

◆ type()

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

Returns the component type identifier.

Returns
The component type string

Reimplemented from makVre::DtObserverUpdater.

◆ handlePlayerCreated()

virtual makVre::DtVreMessageResult makVre::DtCommanderHatchViewUpdater::handlePlayerCreated ( makVre::DtVreMessage * msg)
protectedvirtual

Handles player created messages.

Called when a player is created in the simulation. Calls setupObserver() to configure the observer attachment details.

Parameters
msgThe player created message
Returns
HANDLED to indicate the message was processed

◆ handlePlayerReset()

virtual makVre::DtVreMessageResult makVre::DtCommanderHatchViewUpdater::handlePlayerReset ( makVre::DtVreMessage * msg)
protectedvirtual

Handles reset messages.

This method currently has no implementation (TODO in the code).

Parameters
msgThe reset message
Returns
HANDLED to indicate the message was processed

◆ setupObserver()

virtual void makVre::DtCommanderHatchViewUpdater::setupObserver ( )
protectedvirtual

Sets up observer attachment configuration.

Configures the observer with AttachTypeMimic, attaching it to the player's element with the part and location/rotation offsets specified in the role config file.

Member Data Documentation

◆ myPartAttachment

int makVre::DtCommanderHatchViewUpdater::myPartAttachment
protected

DIS enumeration for the vehicle part to attach the eyepoint to.

Defaults to -1, which represents the base part (the vehicle itself).

◆ myAttachedLocationOffset

DtVector makVre::DtCommanderHatchViewUpdater::myAttachedLocationOffset
protected

Offset vector from the attachment point in meters.

Coordinates are: +x right, +y front, +z up

◆ myAttachedRotationOffset

DtQuaternion makVre::DtCommanderHatchViewUpdater::myAttachedRotationOffset
protected

Rotation offset quaternion from the attachment point.

Defaults to identity quaternion (1,0,0,0) - no rotation

◆ myZoomInterpolator

makVre::DtLinearInterpolator<double>* makVre::DtCommanderHatchViewUpdater::myZoomInterpolator
protected

Interpolator for smooth zoom transitions.

Created as needed when zoom level changes and deleted when transition completes

◆ myObserver

makVrv::DtObserver* makVre::DtCommanderHatchViewUpdater::myObserver
protected

Cached pointer to the observer being controlled.

◆ myLimitObserverRange

bool makVre::DtCommanderHatchViewUpdater::myLimitObserverRange
protected

Flag indicating whether observer rotation is constrained.

When true, observer yaw and pitch are clamped to the ranges defined by myYawRange and myPitchRange. Set to true if either pitchRange or yawRange configuration parameters are provided.

◆ myYawRange

ObserverRange makVre::DtCommanderHatchViewUpdater::myYawRange
protected

Yaw range limits in radians.

◆ myPitchRange

ObserverRange makVre::DtCommanderHatchViewUpdater::myPitchRange
protected

Pitch range limits in radians.

◆ myLastNVGState

bool makVre::DtCommanderHatchViewUpdater::myLastNVGState
protected

Tracks the last known state of night vision goggles.

Used to detect changes in NVG state to avoid unnecessary sensor mode changes


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