VR-Engage  2.2
Loading...
Searching...
No Matches
vreBinocularsSimLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreBinocularsSimLogic.h
7//! \brief Component for binoculars zoom and simulation functionality
8//! \ingroup vreCommonComponents
9
10#pragma once
11
15
16namespace makVrv
17{
18class DtVirtualRealityDriver;
19}
20
21namespace makVre
22{
24{
25//! \ingroup RoleConfigParams
26//! \defgroup BinocularsSimLogicRoleParams Binoculars Sim Logic Role Parameters
27//! \roleInherits{PlayerComponentRoleParams}
28//! Configuration Options for binoculars simulation logic role.
29//! @{
30
31//! \vreRoleParam{hmdSmoothingAlpha,double,0.8,binocularsSimLogic,Alpha value for HMD orientation smoothing when using binoculars in VR mode.}
32constexpr const char* hmdSmoothingAlpha = "hmdSmoothingAlpha";
33
34//! \vreRoleParam{hmdSmoothingEnabled,bool,true,binocularsSimLogic,Whether to enable HMD orientation smoothing when using binoculars in VR mode.}
35constexpr const char* hmdSmoothingEnabled = "hmdSmoothingEnabled";
36
37//! \vreRoleParam{hmdSmoothingThreshold,double,60.0,binocularsSimLogic,Threshold angle in degrees for triggering HMD orientation smoothing.}
38constexpr const char* hmdSmoothingThreshold = "hmdSmoothingThreshold";
39
40//! \vreRoleParam{maxViewMagnification,double,10.0,binocularsSimLogic,Maximum zoom magnification level for the binoculars system.}
41constexpr const char* maxViewMagnification = "maxViewMagnification";
42
43//! @}
44} // namespace BinocularsSimLogicConfig
45
46//! \brief Type identifier for DtBinocularsSimLogic component
47constexpr const char* DtBinocularsSimLogicType = "DtBinocularsSimLogic";
48
49//! \brief Component for handling binoculars zoom simulation and VR-specific functionality
50//!
51//! DtBinocularsSimLogic manages binoculars zoom operations, handling zoom messages
52//! and maintaining the current view magnification state. It provides specialized
53//! functionality for VR environments, including head orientation smoothing when
54//! using binoculars. The component supports both direct zoom-to values and
55//! incremental zoom changes.
57{
58public:
59 //! \brief Constructor for DtBinocularsSimLogic
60 //!
61 //! Initializes the component with default zoom and smoothing settings
63
64 //! \brief Virtual destructor for DtBinocularsSimLogic
65 virtual ~DtBinocularsSimLogic() override;
66
67 //! \brief Initializes the binoculars simulation logic component
68 //! \param player Pointer to the player station this component belongs to
69 //! \param config Configuration table containing binoculars settings
70 //! \return True if initialization succeeded, false otherwise
71 //!
72 //! Reads configuration values for maximum view magnification and HMD smoothing
73 //! settings, registers message handlers, and sets up attribute callbacks
75
76 //! \brief Performs post-initialization after all components are initialized
77 //! \return True if post-initialization succeeded, false otherwise
78 //!
79 //! Sets up VR-specific configurations if applicable, including
80 //! configuring the VR driver's orientation smoothing settings
81 virtual bool postInitialize() override;
82
83 //! \brief Called every frame to update the component state
84 //! \param dt Delta time since the last frame in seconds
85 //!
86 //! Current implementation is empty as updates occur through message handlers
87 //! and attribute change callbacks
88 virtual void tick(double dt) override;
89
90 //! \brief Shuts down the binoculars simulation logic component
91 //!
92 //! Removes message handlers and attribute change callbacks
93 virtual void shutdown() override;
94
95 //! \brief Returns the type identifier for this component
96 //! \return The type string for DtBinocularsSimLogic
97 virtual const char* type() const override;
98
99 //! \brief Handles zoom-to messages for binoculars
100 //! \param msg Zoom-to message
101 //! \return Message handling result indicating the message was handled
102 //!
103 //! Sets the view magnification directly to the specified value,
104 //! clamped between 1.0 and the maximum configured magnification
106
107 //! \brief Handles zoom-by messages for binoculars
108 //! \param msg Zoom-by message
109 //! \return Message handling result indicating the message was handled
110 //!
111 //! Adjusts the view magnification incrementally by the specified amount,
112 //! either increasing or decreasing based on the sign of the zoom value
114
115 //! \brief Callback for view magnification attribute changes
116 //! \param mag New magnification value
117 //!
118 //! Updates the usingBinoculars attribute based on the current magnification
119 //! and handles VR-specific state changes, including mixed reality mode management
120 virtual void onViewMagnificationChanged(double mag);
121
122protected:
123 //! \brief Maximum allowed view magnification value
125
126 //! \brief Pointer to the VR driver if available
127 makVrv::DtVirtualRealityDriver* myVrDriver;
128
129 //! \brief Flag indicating if mixed reality was active before entering binoculars mode
131
132 //! \brief Flag indicating if HMD orientation smoothing is enabled
134
135 //! \brief Smoothing alpha parameter for HMD orientation smoothing
136 //! \note Higher values (closer to 1.0) produce more smoothing
138
139 //! \brief Threshold parameter for HMD orientation smoothing in degrees per second
140 //! \note Rotation speeds below this threshold will be smoothed
142};
143} // namespace makVre
double myMaxViewMagnification
Maximum allowed view magnification value.
Definition vreBinocularsSimLogic.h:124
virtual const char * type() const override
Returns the type identifier for this component.
virtual void onViewMagnificationChanged(double mag)
Callback for view magnification attribute changes.
virtual ~DtBinocularsSimLogic() override
Virtual destructor for DtBinocularsSimLogic.
bool myMrWasActive
Flag indicating if mixed reality was active before entering binoculars mode.
Definition vreBinocularsSimLogic.h:130
virtual void tick(double dt) override
Called every frame to update the component state.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the binoculars simulation logic component.
double myHmdSmoothingAlpha
Smoothing alpha parameter for HMD orientation smoothing.
Definition vreBinocularsSimLogic.h:137
bool myHmdSmoothingEnabled
Flag indicating if HMD orientation smoothing is enabled.
Definition vreBinocularsSimLogic.h:133
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
virtual makVre::DtVreMessageResult handleZoomToEvent(makVre::DtVreMessage *msg)
Handles zoom-to messages for binoculars.
DtBinocularsSimLogic()
Constructor for DtBinocularsSimLogic.
virtual makVre::DtVreMessageResult handleZoomByEvent(makVre::DtVreMessage *msg)
Handles zoom-by messages for binoculars.
double myHmdSmoothingThreshold
Threshold parameter for HMD orientation smoothing in degrees per second.
Definition vreBinocularsSimLogic.h:141
virtual void shutdown() override
Shuts down the binoculars simulation logic component.
makVrv::DtVirtualRealityDriver * myVrDriver
Pointer to the VR driver if available.
Definition vreBinocularsSimLogic.h:127
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
DtPlayerComponent()
Constructor.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
constexpr const char * hmdSmoothingAlpha
Definition vreBinocularsSimLogic.h:32
constexpr const char * hmdSmoothingThreshold
Definition vreBinocularsSimLogic.h:38
constexpr const char * hmdSmoothingEnabled
Definition vreBinocularsSimLogic.h:35
constexpr const char * maxViewMagnification
Definition vreBinocularsSimLogic.h:41
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition vreBinocularsSimLogic.h:24
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtBinocularsSimLogicType
Type identifier for DtBinocularsSimLogic component.
Definition vreBinocularsSimLogic.h:47
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
Defines the DtPlayerComponent base class for VR-Engage role components.
Defines the base class for all VREngage messages.