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

Detailed Description

DtHumanObserverUpdater manages the observer (camera) behavior for the human role, including handling different view modes, player postures, attachments, and special effects like NVG and flashlights. It handles positioning, orientation, and updates of the observer based on the player state.

#include <humanObserverUpdater.h>

Inheritance diagram for makVre::DtHumanObserverUpdater:
[legend]

Classes

struct  Offset
 

Public Member Functions

 DtHumanObserverUpdater ()
 
virtual ~DtHumanObserverUpdater () override
 
virtual bool initialize (DtPlayerStation *player, DtInitTable &config) override
 
virtual bool postInitialize () override
 
virtual void tick (double dt) override
 
virtual void shutdown () override
 
virtual const char * type () const override
 
virtual ObserverAttachMode getAttachMode ()
 
- Public Member Functions inherited from makVre::DtObserverUpdater
 DtObserverUpdater ()
 
virtual ~DtObserverUpdater () 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

void updateAttachmentOffset (double dt)
 
double getPitch ()
 
double getYaw ()
 
DtVector getCameraOffset ()
 
virtual void updateZoomLevel ()
 
DtVector rotateVector (const DtVector &localSpineToCamera, double pitch, double yaw=0.0)
 
void updateObserverPositionAndOrientation ()
 
void updateScopeObserver (makVrv::DtObserver *observer)
 
void updateObserverViewMagnification (double dt)
 
virtual void setDestinationOffset (ObserverAttachMode mode, HumanPosture posture)
 
virtual void updateFlashlightState ()
 
virtual void updateCompassState ()
 
virtual void onNVGChanged (bool nvg)
 
virtual bool observerPitchCheck ()
 
virtual void updateStateAttributes () override
 
virtual void slot_observerModeSettingChanged (int mode, int setting)
 
int buildOffsetKey (ObserverAttachMode mode, HumanPosture posture)
 
- 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)
 

Protected Attributes

makVrv::DtObserver * myObserver
 
makVrv::DtUniqueID myPlayerElementID
 
bool myObserverIsAttached
 
DtVector mySpineEndPosition
 
DtVector mySpineToCameraVector
 
double myCutToFirstPersonDist
 
double myPostureChangeSpeed
 
double myAttachModeSpeed
 
double myThirdPersonAimSpeed
 
std::map< int, OffsetmyOffsets
 
Offset myPriorOffset
 
Offset myCurrentOffset
 
Offset myDestinationOffset
 
bool myPostureChanged
 
double myTargetZoom
 
makVre::DtLinearInterpolator< double > * myZoomInterpolator
 
bool myLastFlashlightState
 
bool myLastCompassState
 
bool myLastNVGState
 
double myLastFlashlightPitch
 
double myLastFlashlightYaw
 
bool myUsingVr
 
makVre::DtLinearInterpolator< DtVector > * myFirstPersonModelTranslationOffsetInterpolator
 
makVre::DtLinearInterpolator< DtVector > * myFirstPersonModelRotateOffsetInterpolator
 
bool myWasAiming
 
std::string myScopeChannelName
 
double myScopeWalkingPitch
 
double myMaxObserverPitch
 
std::string myNightVisionSensorMode
 
- 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

◆ DtHumanObserverUpdater()

makVre::DtHumanObserverUpdater::DtHumanObserverUpdater ( )

Default constructor.

◆ ~DtHumanObserverUpdater()

virtual makVre::DtHumanObserverUpdater::~DtHumanObserverUpdater ( )
overridevirtual

Virtual destructor.

Member Function Documentation

◆ initialize()

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

Initializes the observer updater component.

Parameters
playerPointer to the player station
configConfiguration settings for initialization
Returns
True if initialization was successful, false otherwise

Reimplemented from makVre::DtObserverUpdater.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

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

Performs post-initialization setup.

Returns
True if post-initialization was successful, false otherwise

Reimplemented from makVre::DtObserverUpdater.

◆ tick()

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

Updates the observer for the current frame.

Parameters
dtDelta time since the last frame in seconds

Reimplemented from makVre::DtObserverUpdater.

◆ shutdown()

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

Cleans up resources when the component is being shut down.

Reimplemented from makVre::DtObserverUpdater.

◆ type()

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

Returns the component type identifier.

Returns
The component type string

Reimplemented from makVre::DtObserverUpdater.

◆ getAttachMode()

virtual ObserverAttachMode makVre::DtHumanObserverUpdater::getAttachMode ( )
virtual

Gets the current observer attachment mode.

Returns
Current observer attachment mode

◆ updateAttachmentOffset()

void makVre::DtHumanObserverUpdater::updateAttachmentOffset ( double dt)
protected

Updates the observer attachment offset based on current state.

Parameters
dtDelta time since the last frame in seconds

◆ getPitch()

double makVre::DtHumanObserverUpdater::getPitch ( )
protected

Gets the current pitch angle of the player.

Returns
Current pitch angle in radians

◆ getYaw()

double makVre::DtHumanObserverUpdater::getYaw ( )
protected

Gets the current yaw angle of the player.

Returns
Current yaw angle in radians

◆ getCameraOffset()

DtVector makVre::DtHumanObserverUpdater::getCameraOffset ( )
protected

Gets the current camera offset from the player.

Returns
Camera offset vector

◆ updateZoomLevel()

virtual void makVre::DtHumanObserverUpdater::updateZoomLevel ( )
protectedvirtual

Updates the target zoom level based on current observer state and equipment.

This function calculates and sets the appropriate zoom level based on the current observer attach mode, aiming state, and equipped weapon type. When aiming from first person view (and not using VR), it applies equipment-specific zoom levels:

  • Guns: Uses currentGunZoomLevel attribute (default 2.2x if not set)
  • Launchers: Uses viewMagnification attribute (default 1.0x if not set) When not aiming or not in first person mode, zoom is reset to 1.0x.
Note
This function modifies the myTargetZoom member variable
VR mode disables zoom functionality
Gun zoom levels are now configured per weapon via currentGunZoomLevel attribute

◆ rotateVector()

DtVector makVre::DtHumanObserverUpdater::rotateVector ( const DtVector & localSpineToCamera,
double pitch,
double yaw = 0.0 )
protected

Rotates a vector by the specified pitch and yaw angles.

Parameters
localSpineToCameraVector to rotate
pitchPitch angle in radians
yawYaw angle in radians
Returns
Rotated vector

◆ updateObserverPositionAndOrientation()

void makVre::DtHumanObserverUpdater::updateObserverPositionAndOrientation ( )
protected

Updates the observer position and orientation based on current state.

◆ updateScopeObserver()

void makVre::DtHumanObserverUpdater::updateScopeObserver ( makVrv::DtObserver * observer)
protected

Updates the scope observer properties.

Parameters
observerPointer to the scope observer to update

◆ updateObserverViewMagnification()

void makVre::DtHumanObserverUpdater::updateObserverViewMagnification ( double dt)
protected

Updates the observer view magnification (zoom)

Parameters
dtDelta time since the last frame in seconds

◆ setDestinationOffset()

virtual void makVre::DtHumanObserverUpdater::setDestinationOffset ( ObserverAttachMode mode,
HumanPosture posture )
protectedvirtual

Sets the destination offset for the observer.

Parameters
modeObserver attachment mode
postureCurrent human posture

◆ updateFlashlightState()

virtual void makVre::DtHumanObserverUpdater::updateFlashlightState ( )
protectedvirtual

Updates the flashlight state based on current player state.

◆ updateCompassState()

virtual void makVre::DtHumanObserverUpdater::updateCompassState ( )
protectedvirtual

Updates the compass display state.

Updates DisplayCompass state attribute in the DtObserverModeManager, with value of the makVre::DtState attribute "compass". This shows/hides the built-in VR-Vantage compass widget.

◆ onNVGChanged()

virtual void makVre::DtHumanObserverUpdater::onNVGChanged ( bool nvg)
protectedvirtual

Handles changes in night vision goggles state.

Parameters
nvgTrue if NVG is enabled, false otherwise

◆ observerPitchCheck()

virtual bool makVre::DtHumanObserverUpdater::observerPitchCheck ( )
protectedvirtual

Checks if the observer pitch is at an angle above the terrain.

Returns
True if the observer pitch is above the threshold (0.8), false otherwise

◆ updateStateAttributes()

virtual void makVre::DtHumanObserverUpdater::updateStateAttributes ( )
overrideprotectedvirtual

Updates state attributes based on current observer state.

Reimplemented from makVre::DtObserverUpdater.

◆ slot_observerModeSettingChanged()

virtual void makVre::DtHumanObserverUpdater::slot_observerModeSettingChanged ( int mode,
int setting )
protectedvirtual

Handles observer mode setting changes.

Parameters
modeObserver mode that changed
settingSetting that changed

Called when an observer mode's setting changes; if it's the mode our observer is using and the setting is DisplayCompass, update corresponding state attribute.

◆ buildOffsetKey()

int makVre::DtHumanObserverUpdater::buildOffsetKey ( ObserverAttachMode mode,
HumanPosture posture )
inlineprotected

Builds a lookup key for the offset map from posture and mode.

Parameters
modeObserver attachment mode
postureHuman posture
Returns
Combined integer key for offset lookup

Member Data Documentation

◆ myObserver

makVrv::DtObserver* makVre::DtHumanObserverUpdater::myObserver
protected

Pointer to the managed observer.

◆ myPlayerElementID

makVrv::DtUniqueID makVre::DtHumanObserverUpdater::myPlayerElementID
protected

Unique ID of the player element.

◆ myObserverIsAttached

bool makVre::DtHumanObserverUpdater::myObserverIsAttached
protected

Flag indicating if the observer is currently attached.

◆ mySpineEndPosition

DtVector makVre::DtHumanObserverUpdater::mySpineEndPosition
protected

Position of the spine end point.

These two should really be pulled from the gun/arms model once vrvDiguy can getLinkPosition

◆ mySpineToCameraVector

DtVector makVre::DtHumanObserverUpdater::mySpineToCameraVector
protected

Vector from spine to camera position.

◆ myCutToFirstPersonDist

double makVre::DtHumanObserverUpdater::myCutToFirstPersonDist
protected

Distance threshold for switching to first-person view.

◆ myPostureChangeSpeed

double makVre::DtHumanObserverUpdater::myPostureChangeSpeed
protected

Speed of posture change transition.

◆ myAttachModeSpeed

double makVre::DtHumanObserverUpdater::myAttachModeSpeed
protected

Speed of attachment mode transition.

◆ myThirdPersonAimSpeed

double makVre::DtHumanObserverUpdater::myThirdPersonAimSpeed
protected

Speed of third-person aiming transition.

◆ myOffsets

std::map<int, Offset> makVre::DtHumanObserverUpdater::myOffsets
protected

Map of observer offsets indexed by a combined posture and mode key.

◆ myPriorOffset

Offset makVre::DtHumanObserverUpdater::myPriorOffset
protected

Previous observer offset.

◆ myCurrentOffset

Offset makVre::DtHumanObserverUpdater::myCurrentOffset
protected

Current observer offset.

◆ myDestinationOffset

Offset makVre::DtHumanObserverUpdater::myDestinationOffset
protected

Target destination observer offset.

◆ myPostureChanged

bool makVre::DtHumanObserverUpdater::myPostureChanged
protected

Flag indicating if posture has changed this frame.

◆ myTargetZoom

double makVre::DtHumanObserverUpdater::myTargetZoom
protected

Target zoom level for the observer.

◆ myZoomInterpolator

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

Interpolator for smooth zoom transitions.

◆ myLastFlashlightState

bool makVre::DtHumanObserverUpdater::myLastFlashlightState
protected

Last known state of the flashlight.

◆ myLastCompassState

bool makVre::DtHumanObserverUpdater::myLastCompassState
protected

Last known state of the compass.

◆ myLastNVGState

bool makVre::DtHumanObserverUpdater::myLastNVGState
protected

Last known state of night vision goggles.

◆ myLastFlashlightPitch

double makVre::DtHumanObserverUpdater::myLastFlashlightPitch
protected

Last flashlight pitch angle.

◆ myLastFlashlightYaw

double makVre::DtHumanObserverUpdater::myLastFlashlightYaw
protected

Last flashlight yaw angle.

◆ myUsingVr

bool makVre::DtHumanObserverUpdater::myUsingVr
protected

Flag indicating if using VR mode.

◆ myFirstPersonModelTranslationOffsetInterpolator

makVre::DtLinearInterpolator<DtVector>* makVre::DtHumanObserverUpdater::myFirstPersonModelTranslationOffsetInterpolator
protected

Interpolator for first-person model translation offset.

◆ myFirstPersonModelRotateOffsetInterpolator

makVre::DtLinearInterpolator<DtVector>* makVre::DtHumanObserverUpdater::myFirstPersonModelRotateOffsetInterpolator
protected

Interpolator for first-person model rotation offset.

◆ myWasAiming

bool makVre::DtHumanObserverUpdater::myWasAiming
protected

Flag indicating if the player was aiming in the previous frame.

◆ myScopeChannelName

std::string makVre::DtHumanObserverUpdater::myScopeChannelName
protected

Name of the scope channel.

◆ myScopeWalkingPitch

double makVre::DtHumanObserverUpdater::myScopeWalkingPitch
protected

Scope walking pitch adjustment.

◆ myMaxObserverPitch

double makVre::DtHumanObserverUpdater::myMaxObserverPitch
protected

Maximum allowed observer pitch angle.

◆ myNightVisionSensorMode

std::string makVre::DtHumanObserverUpdater::myNightVisionSensorMode
protected

Name of the observer mode to use for NVG.

DtObserverMode to use for night vision goggles mode


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