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

Detailed Description

The DtCommanderObserverUpdater manages the visual aspects of a vehicle commander's view. It handles attachment to specific vehicle parts, orientation control, sensor mode switching, and updates the observer state based on vehicle damage state.

This component supports multiple sensor modes (Visual, NVG, Thermal White/Black) that can be configured in the role file.

#include <commanderObserverUpdater.h>

Inheritance diagram for makVre::DtCommanderObserverUpdater:
[legend]

Public Member Functions

 DtCommanderObserverUpdater ()
 
virtual ~DtCommanderObserverUpdater () override
 
virtual bool initialize (DtPlayerStation *player, DtInitTable &config) override
 
virtual void tick (double dt) override
 
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)
 
void resetObserver ()
 
void updateSensor ()
 
void updateDestroyed ()
 
- 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

bool myAttached
 
makVrv::DtObserver * myObserver
 
DtLinearInterpolator< double > * myZoomInterpolator
 
int myAttachPart
 
DtVector myAttachedOffset
 
DtQuaternion myOriOffest
 
SensorViews myLastSensorViewMode
 
std::map< enum SensorViews, std::string > mySensorModes
 
- 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

◆ DtCommanderObserverUpdater()

makVre::DtCommanderObserverUpdater::DtCommanderObserverUpdater ( )

Constructor for DtCommanderObserverUpdater.

Initializes the component with default values including no attachment, Visual sensor mode, and empty sensor mode map.

◆ ~DtCommanderObserverUpdater()

virtual makVre::DtCommanderObserverUpdater::~DtCommanderObserverUpdater ( )
overridevirtual

Virtual destructor for DtCommanderObserverUpdater.

Member Function Documentation

◆ initialize()

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

Initializes the component with configuration from Lua.

Reads configuration values including attachment part, position/orientation offsets, and available sensor modes. Sets up the observer and message handlers for PlayerCreatedMessage and ResetMessage.

Also populates the mySensorModes map with configured sensor types and their corresponding VR-Vantage sensor names.

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::DtCommanderObserverUpdater::tick ( double dt)
overridevirtual

Updates the observer's position, orientation, and sensor mode.

Called each frame to update the observer position based on entity position, read observer orientation from state attributes, update sensor mode based on the "currentSensor" state attribute, and handle the entity destruction state.

Parameters
dtDelta time in seconds since the last tick

Reimplemented from makVre::DtObserverUpdater.

◆ shutdown()

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

Shuts down the component.

Removes message handlers and resets the observer to default settings. Also switches the observer back to the Visual sensor mode.

Reimplemented from makVre::DtObserverUpdater.

◆ type()

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

Returns the component type identifier.

Returns
The component type string

Reimplemented from makVre::DtObserverUpdater.

◆ handlePlayerCreated()

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

Handles player created messages.

Called when a player is created in the simulation. Calls resetObserver() to re-attach the observer to the entity.

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

◆ handlePlayerReset()

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

Handles reset messages.

Called when a reset message is received. Calls resetObserver() to re-attach the observer to the entity.

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

◆ resetObserver()

void makVre::DtCommanderObserverUpdater::resetObserver ( )
protected

Resets and re-attaches the observer to the entity.

Configures the observer to use AttachTypeMimic, attaches it to the player's element, and sets the part attachment and offset values.

◆ updateSensor()

void makVre::DtCommanderObserverUpdater::updateSensor ( )
protected

Updates the observer's sensor mode.

Checks the "currentSensor" state attribute and updates the observer's sensor mode if it has changed. Also updates the "currentSensorName" state attribute. Uses the VR-Engage sensor mode mapper to convert role-specific sensor names to VR-Vantage sensor names.

◆ updateDestroyed()

void makVre::DtCommanderObserverUpdater::updateDestroyed ( )
protected

Handles entity destruction state changes.

Monitors the "ownship.damageState" attribute. When the entity is destroyed, switches to Visual mode, resets zoom, and changes the attachment type. When the entity is restored, calls resetObserver() to restore normal operation.

Member Data Documentation

◆ myAttached

bool makVre::DtCommanderObserverUpdater::myAttached
protected

Flag indicating if the observer is attached to an entity.

◆ myObserver

makVrv::DtObserver* makVre::DtCommanderObserverUpdater::myObserver
protected

Cached pointer to the observer being controlled.

◆ myZoomInterpolator

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

Interpolator for smooth zoom transitions.

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

◆ myAttachPart

int makVre::DtCommanderObserverUpdater::myAttachPart
protected

DIS part enumeration value for the vehicle part to attach the observer to.

Defaults to 5376 (primary radar system 1, representing commander sensor)

◆ myAttachedOffset

DtVector makVre::DtCommanderObserverUpdater::myAttachedOffset
protected

Position offset from the attachment part.

Vector offset in meters from the attachment point

◆ myOriOffest

DtQuaternion makVre::DtCommanderObserverUpdater::myOriOffest
protected

Orientation offset from the attachment part.

Quaternion representing orientation offset from the attachment point

◆ myLastSensorViewMode

SensorViews makVre::DtCommanderObserverUpdater::myLastSensorViewMode
protected

Last known sensor view mode.

Used to detect changes in sensor mode to avoid unnecessary updates

◆ mySensorModes

std::map<enum SensorViews, std::string> makVre::DtCommanderObserverUpdater::mySensorModes
protected

Map of SensorViews enums to VR-Engage sensor mode names.

This map links the enumerated sensor types (VISUAL, NVG, etc.) to their corresponding VR-Engage sensor mode names configured in the role file.


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