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

Detailed Description

DtScopeSimLogic manages zoom functionality for weapon scopes, handling both discrete zoom level changes and observer view mode adjustments when aiming. The component responds to zoom increase/decrease messages and automatically configures VR-specific settings such as head orientation smoothing when in VR mode. It also enforces first-person view when aiming through a scope and manages the transition between aiming and non-aiming states.

#include <vreScopeSimLogic.h>

Inheritance diagram for makVre::DtScopeSimLogic:
[legend]

Public Member Functions

 DtScopeSimLogic ()
 
virtual ~DtScopeSimLogic () 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 makVre::DtVreMessageResult handleScopeIncreaseZoom (makVre::DtVreMessage *msg)
 
virtual makVre::DtVreMessageResult handleScopeDecreaseZoom (makVre::DtVreMessage *msg)
 
virtual void onAimingChanged (bool aiming)
 
virtual void onViewMagnificationChanged (double mag)
 
- 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 Attributes

double myMaxViewMagnification
 
makVrv::DtVirtualRealityDriver * myVrDriver
 
bool myMrWasActive
 
ObserverAttachMode myLastObserverAttachMode
 
bool myHmdSmoothingEnabled
 
double myHmdSmoothingAlpha
 
double myHmdSmoothingThreshold
 
- Protected Attributes inherited from makVre::DtPlayerComponent
std::string myName
 
DtInitTable myConfig
 
DtPlayerStationmyPlayer
 
makVrv::DtDe * myDe
 
DtEntityResolvermyResolver
 
DtAttributeCallbackManager myAttributeCallbacks
 

Additional Inherited Members

- Protected Member Functions inherited from makVre::DtPlayerComponent
virtual void initializeStateAttributes ()
 

Constructor & Destructor Documentation

◆ DtScopeSimLogic()

makVre::DtScopeSimLogic::DtScopeSimLogic ( )

Constructor for DtScopeSimLogic.

Parameters
classNameClass name for identification, defaults to "DtScopeSimLogic"

Initializes the component with default zoom and smoothing settings

◆ ~DtScopeSimLogic()

virtual makVre::DtScopeSimLogic::~DtScopeSimLogic ( )
overridevirtual

Virtual destructor for DtScopeSimLogic.

Member Function Documentation

◆ initialize()

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

Initializes the scope simulation logic component.

Parameters
playerPointer to the player station this component belongs to
configConfiguration table containing scope settings
Returns
True if initialization succeeded, false otherwise

Reads configuration values for HMD smoothing settings, registers message handlers for scope zoom messages, and sets up attribute callbacks for aiming state and view magnification changes

Reimplemented from makVre::DtPlayerComponent.

References makVre::DtPlayerComponent::player().

◆ postInitialize()

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

Performs post-initialization after all components are initialized.

Returns
True if post-initialization succeeded, false otherwise

Sets up VR-specific configurations if applicable, including configuring the VR driver's orientation smoothing settings

Reimplemented from makVre::DtPlayerComponent.

◆ tick()

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

Called every frame to update the component state.

Parameters
dtDelta time since the last frame in seconds

Current implementation is empty as updates occur through message handlers and attribute change callbacks

Implements makVre::DtPlayerComponent.

◆ shutdown()

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

Shuts down the scope simulation logic component.

Removes message handlers and attribute change callbacks

Reimplemented from makVre::DtPlayerComponent.

◆ type()

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

Returns the type identifier for this component.

Returns
The type string for DtScopeSimLogic

Implements makVre::DtPlayerComponent.

◆ handleScopeIncreaseZoom()

virtual makVre::DtVreMessageResult makVre::DtScopeSimLogic::handleScopeIncreaseZoom ( makVre::DtVreMessage * msg)
virtual

Handles messages to increase scope zoom level.

Parameters
msgThe scope increase zoom message
Returns
Message handling result indicating the message was handled

Increases the zoom index and updates the view magnification to the next higher zoom level from the configured scopeZoomLevels array

◆ handleScopeDecreaseZoom()

virtual makVre::DtVreMessageResult makVre::DtScopeSimLogic::handleScopeDecreaseZoom ( makVre::DtVreMessage * msg)
virtual

Handles messages to decrease scope zoom level.

Parameters
msgThe scope decrease zoom message
Returns
Message handling result indicating the message was handled

Decreases the zoom index and updates the view magnification to the next lower zoom level from the configured scopeZoomLevels array

◆ onAimingChanged()

virtual void makVre::DtScopeSimLogic::onAimingChanged ( bool aiming)
virtual

Callback for when the aiming state changes.

Parameters
aimingNew aiming state (true when aiming, false otherwise)

When entering aiming state, sets initial zoom level, disables third person view, and forces first person observer mode. When exiting aiming state, restores the previous observer attach mode.

◆ onViewMagnificationChanged()

virtual void makVre::DtScopeSimLogic::onViewMagnificationChanged ( double mag)
virtual

Callback for view magnification attribute changes.

Parameters
magNew magnification value

Current implementation is empty

Member Data Documentation

◆ myMaxViewMagnification

double makVre::DtScopeSimLogic::myMaxViewMagnification
protected

Maximum allowed view magnification value.

◆ myVrDriver

makVrv::DtVirtualRealityDriver* makVre::DtScopeSimLogic::myVrDriver
protected

Pointer to the VR driver if available.

◆ myMrWasActive

bool makVre::DtScopeSimLogic::myMrWasActive
protected

Flag indicating if mixed reality was active before entering aiming mode.

◆ myLastObserverAttachMode

ObserverAttachMode makVre::DtScopeSimLogic::myLastObserverAttachMode
protected

The observer attach mode used before entering aiming mode.

Stored when entering aiming mode so it can be restored when exiting

◆ myHmdSmoothingEnabled

bool makVre::DtScopeSimLogic::myHmdSmoothingEnabled
protected

Flag indicating if HMD orientation smoothing is enabled.

◆ myHmdSmoothingAlpha

double makVre::DtScopeSimLogic::myHmdSmoothingAlpha
protected

Smoothing alpha parameter for HMD orientation smoothing.

Note
Higher values (closer to 1.0) produce more smoothing

◆ myHmdSmoothingThreshold

double makVre::DtScopeSimLogic::myHmdSmoothingThreshold
protected

Threshold parameter for HMD orientation smoothing in degrees per second.

Note
Rotation speeds below this threshold will be smoothed

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