VR-Engage  2.3
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
17
18namespace makVrv
19{
20class DtVirtualRealityDriver;
21}
22
23namespace makVre
24{
26{
27//! \ingroup RoleConfigParams
28//! \defgroup BinocularsSimLogicRoleParams Binoculars Sim Logic Role Parameters
29//! \roleInherits{PlayerComponentRoleParams}
30//! Configuration Options for binoculars simulation logic role.
31//! @{
32
33//! \vreRoleParam{hmdSmoothingAlpha,double,0.8,binocularsSimLogic,Alpha value for HMD orientation smoothing when using binoculars in VR mode.}
34constexpr const char* hmdSmoothingAlpha = "hmdSmoothingAlpha";
35
36//! \vreRoleParam{hmdSmoothingEnabled,bool,true,binocularsSimLogic,Whether to enable HMD orientation smoothing when using binoculars in VR mode.}
37constexpr const char* hmdSmoothingEnabled = "hmdSmoothingEnabled";
38
39//! \vreRoleParam{hmdSmoothingThreshold,double,60.0,binocularsSimLogic,Threshold angle in degrees for triggering HMD orientation smoothing.}
40constexpr const char* hmdSmoothingThreshold = "hmdSmoothingThreshold";
41
42//! \vreRoleParam{maxViewMagnification,double,10.0,binocularsSimLogic,Maximum zoom magnification level for the binoculars system.}
43constexpr const char* maxViewMagnification = "maxViewMagnification";
44
45//! @}
46} // namespace BinocularsSimLogicConfig
47
48//! \brief Type identifier for DtBinocularsSimLogic component
49constexpr const char* DtBinocularsSimLogicType = "DtBinocularsSimLogic";
50
51//! \brief Component for handling binoculars zoom simulation and VR-specific functionality
52//!
53//! DtBinocularsSimLogic manages binoculars zoom operations, handling zoom messages
54//! and maintaining the current view magnification state. It provides specialized
55//! functionality for VR environments, including head orientation smoothing when
56//! using binoculars. The component supports both direct zoom-to values and
57//! incremental zoom changes.
59{
60public:
61 //! \brief Constructor for DtBinocularsSimLogic
62 //!
63 //! Initializes the component with default zoom and smoothing settings
65
66 //! \brief Virtual destructor for DtBinocularsSimLogic
67 virtual ~DtBinocularsSimLogic() override;
68
69 //! \brief Initializes the binoculars simulation logic component
70 //! \param player Pointer to the player station this component belongs to
71 //! \param config Configuration table containing binoculars settings
72 //! \return True if initialization succeeded, false otherwise
73 //!
74 //! Reads configuration values for maximum view magnification and HMD smoothing
75 //! settings, registers message handlers, and sets up attribute callbacks
77
78 //! \brief Performs post-initialization after all components are initialized
79 //! \return True if post-initialization succeeded, false otherwise
80 //!
81 //! Sets up VR-specific configurations if applicable, including
82 //! configuring the VR driver's orientation smoothing settings
83 virtual bool postInitialize() override;
84
85 //! \brief Called every frame to update the component state
86 //! \param dt Delta time since the last frame in seconds
87 //!
88 //! Current implementation is empty as updates occur through message handlers
89 //! and attribute change callbacks
90 virtual void tick(double dt) override;
91
92 //! \brief Shuts down the binoculars simulation logic component
93 //!
94 //! Removes message handlers and attribute change callbacks
95 virtual void shutdown() override;
96
97 //! \brief Returns the type identifier for this component
98 //! \return The type string for DtBinocularsSimLogic
99 virtual const char* type() const override;
100
101 //! \brief Handles zoom-to messages for binoculars
102 //! \param msg Zoom-to message
103 //! \return Message handling result indicating the message was handled
104 //!
105 //! Sets the view magnification directly to the specified value,
106 //! clamped between 1.0 and the maximum configured magnification
108
109 //! \brief Handles zoom-by messages for binoculars
110 //! \param msg Zoom-by message
111 //! \return Message handling result indicating the message was handled
112 //!
113 //! Adjusts the view magnification incrementally by the specified amount,
114 //! either increasing or decreasing based on the sign of the zoom value
116
117 //! \brief Callback for view magnification attribute changes
118 //! \param mag New magnification value
119 //!
120 //! Updates the usingBinoculars attribute based on the current magnification
121 //! and handles VR-specific state changes, including mixed reality mode management
122 virtual void onViewMagnificationChanged(double mag);
123
124protected:
125 //! \brief Maximum allowed view magnification value
127
128 //! \brief Pointer to the VR driver if available
129 makVrv::DtVirtualRealityDriver* myVrDriver;
130
131 //! \brief Flag indicating if mixed reality was active before entering binoculars mode
133
134 //! \brief Flag indicating if HMD orientation smoothing is enabled
136
137 //! \brief Smoothing alpha parameter for HMD orientation smoothing
138 //! \note Higher values (closer to 1.0) produce more smoothing
140
141 //! \brief Threshold parameter for HMD orientation smoothing in degrees per second
142 //! \note Rotation speeds below this threshold will be smoothed
144
145 //! \brief Handle for maximum binocular magnification.
146 //! \vreAttrKey{maxViewMagnification}
148 //! \brief Handle for current binocular magnification.
149 //! \vreAttrKey{viewMagnification}
151 //! \brief Handle for blocking binoculars mode.
152 //! \vreAttrKey{blockBinoculars}
154 //! \brief Handle for VR enabled state.
155 //! \vreAttrKey{vr-enabled}
157 //! \brief Handle indicating whether binocular mode is active.
158 //! \vreAttrKey{usingBinoculars}
160};
161} // namespace makVre
Provides handle classes for safe access to attributes.
Type-specific handle class for attributes.
Definition attributeHandle.h:229
double myMaxViewMagnification
Maximum allowed view magnification value.
Definition vreBinocularsSimLogic.h:126
virtual const char * type() const override
Returns the type identifier for this component.
virtual void onViewMagnificationChanged(double mag)
Callback for view magnification attribute changes.
DtAttributeHandleType< bool > myBlockBinocularsAttr
Handle for blocking binoculars mode.
Definition vreBinocularsSimLogic.h:153
virtual ~DtBinocularsSimLogic() override
Virtual destructor for DtBinocularsSimLogic.
bool myMrWasActive
Flag indicating if mixed reality was active before entering binoculars mode.
Definition vreBinocularsSimLogic.h:132
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.
DtAttributeHandleType< double > myViewMagnificationAttr
Handle for current binocular magnification.
Definition vreBinocularsSimLogic.h:150
double myHmdSmoothingAlpha
Smoothing alpha parameter for HMD orientation smoothing.
Definition vreBinocularsSimLogic.h:139
DtAttributeHandleType< double > myMaxViewMagnificationAttr
Handle for maximum binocular magnification.
Definition vreBinocularsSimLogic.h:147
bool myHmdSmoothingEnabled
Flag indicating if HMD orientation smoothing is enabled.
Definition vreBinocularsSimLogic.h:135
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
DtAttributeHandleType< bool > myVrEnabledAttr
Handle for VR enabled state.
Definition vreBinocularsSimLogic.h:156
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.
DtAttributeHandleType< bool > myUsingBinocularsAttr
Handle indicating whether binocular mode is active.
Definition vreBinocularsSimLogic.h:159
double myHmdSmoothingThreshold
Threshold parameter for HMD orientation smoothing in degrees per second.
Definition vreBinocularsSimLogic.h:143
virtual void shutdown() override
Shuts down the binoculars simulation logic component.
makVrv::DtVirtualRealityDriver * myVrDriver
Pointer to the VR driver if available.
Definition vreBinocularsSimLogic.h:129
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:34
constexpr const char * hmdSmoothingThreshold
Definition vreBinocularsSimLogic.h:40
constexpr const char * hmdSmoothingEnabled
Definition vreBinocularsSimLogic.h:37
constexpr const char * maxViewMagnification
Definition vreBinocularsSimLogic.h:43
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:26
!
Definition glsVreMessageUtil.h:50
constexpr const char * DtBinocularsSimLogicType
Type identifier for DtBinocularsSimLogic component.
Definition vreBinocularsSimLogic.h:49
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.