VR-Engage  2.2
Loading...
Searching...
No Matches
mixedRealityUpdater.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file mixedRealityUpdater.h
7//! \brief Component that provides mixed reality (augmented reality) capabilities
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
16
17
18#include <osg/ref_ptr>
19#include <osg/Program>
20#include <osg/MatrixTransform>
21
22#include <matrix/vlVector.h>
23
24namespace makVrv
25{
26class DtDe;
27class DtVirtualRealityDriver;
28class DtTrackedCamera;
29class DtObserver;
30}; // namespace makVrv
31
32namespace makVre
33{
35{
36//! \ingroup RoleConfigParams
37//! \defgroup MixedRealityUpdaterRoleParams Mixed Reality Updater Role Parameters
38//! \roleInherits{PlayerComponentRoleParams}
39//! Configuration Options for mixed reality updater role.
40//! @{
41
42//! \vreRoleParam{A,float,1.0,mixedRealityUpdater,Parameter A for mixed reality rendering algorithm calibration.}
43constexpr const char* A = "A";
44
45//! \vreRoleParam{algorithm,int,0,mixedRealityUpdater,Algorithm selection for mixed reality processing and rendering.}
46constexpr const char* algorithm = "algorithm";
47
48//! \vreRoleParam{B,float,1.0,mixedRealityUpdater,Parameter B for mixed reality rendering algorithm calibration.}
49constexpr const char* B = "B";
50
51//! \vreRoleParam{C,float,1.0,mixedRealityUpdater,Parameter C for mixed reality rendering algorithm calibration.}
52constexpr const char* C = "C";
53
54//! \vreRoleParam{cameraProjectionGeometry,string,"$(DATA_DIR)\\Objects\\cockpitMask\\cockpitMask.xml",mixedRealityUpdater,Path to the camera projection geometry file for cockpit masking in mixed reality mode.}
55constexpr const char* cameraProjectionGeometry = "cameraProjectionGeometry";
56
57//! \vreRoleParam{D,float,1.0,mixedRealityUpdater,Parameter D for mixed reality rendering algorithm calibration.}
58constexpr const char* D = "D";
59
60//! \vreRoleParam{maskColor,vector,{0.15; 0.70; 0.30},mixedRealityUpdater,RGB color vector for chroma key masking in mixed reality processing.}
61constexpr const char* maskColor = "maskColor";
62
63//! @}
64} // namespace MixedRealityUpdaterConfig
65
66//! \brief Type identifier for DtMixedRealityUpdater component
67constexpr const char* DtMixedRealityUpdaterType = "DtMixedRealityUpdater";
68
69//! \brief Component that implements mixed reality (augmented reality) functionality
70//!
71//! DtMixedRealityUpdater integrates camera video feeds with the virtual environment
72//! to create a mixed reality experience. It manages a masking object that blends
73//! real-world camera imagery with virtual content, handles chroma keying for
74//! green screen effects, and provides UI controls for adjusting mixed reality parameters.
76{
77public:
78 //! \brief Constructor for DtMixedRealityUpdater
79 //!
80 //! Initializes component state with default values
82
83 //! \brief Virtual destructor for DtMixedRealityUpdater
84 virtual ~DtMixedRealityUpdater() override;
85
86 //! \brief Initializes the mixed reality updater component
87 //! \param player Pointer to the player station this component belongs to
88 //! \param config Configuration table containing mixed reality settings
89 //! \return True if initialization succeeded, false otherwise
90 //!
91 //! Reads configuration parameters for the mixed reality system, including
92 //! masking algorithm settings, color parameters, and camera projection geometry path
93 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
94
95 //! \brief Performs post-initialization after all components are initialized
96 //! \return True if post-initialization succeeded, false otherwise
97 //!
98 //! Acquires the VR driver, sets up the masking object, and starts the mixed reality system
99 virtual bool postInitialize() override;
100
101 //! \brief Called every frame to update the mixed reality state
102 //! \param dt Delta time since the last frame in seconds
103 //!
104 //! Handles cockpit control visibility on first update and processes UI interactions
105 //! for mixed reality parameter adjustments
106 virtual void tick(double dt) override;
107
108 //! \brief Shuts down the mixed reality updater component
109 //!
110 //! Disables mixed reality mode, removes the mask object, disconnects signals,
111 //! and restores cockpit control visibility
112 virtual void shutdown() override;
113
114 //! \brief Returns the component type identifier
115 //! \return The component type string
116 virtual const char* type() const override;
117
118protected:
119 //! \brief Updates the mask transform and shader parameters
120 //!
121 //! Called each frame to update the mask transform based on the observer's position
122 //! and orientation, and to update shader parameters for chroma keying
123 virtual void updateMask();
124
125 //! \brief Handles shader reload requests
126 //!
127 //! Reloads the mask shader files and updates the state set with the new shader
128 virtual void handleReloadShader();
129
130 //! \brief Handles menu action messages for mixed reality controls
131 //! \param msg The menu action message
132 //! \return Message handling result indicating if the message was handled
133 //!
134 //! Processes menu actions, currently supporting toggling the AR camera menu
136
137 //! \brief Sets the visibility of cockpit controls
138 //! \param visible True to show cockpit controls, false to hide them
139 //!
140 //! Manipulates the entity's appearance to show or hide virtual cockpit controls,
141 //! typically hiding them when in mixed reality mode to see real controls
142 virtual void setCockpitControlsVisible(bool visible);
143
144 //! \brief Pointer to the observer used for positioning the mask
145 makVrv::DtObserver* myObserver;
146
147 //! \brief Pointer to the virtual reality driver that provides camera integration
148 makVrv::DtVirtualRealityDriver* myVrDriver;
149
150 //! \brief Transform node for the masking geometry
151 osg::ref_ptr<osg::MatrixTransform> myMaskTransform;
152
153 //! \brief Shader program used for blending camera imagery with virtual content
154 osg::ref_ptr<osg::Program> myMaskShader;
155
156 //! \brief Color used for chroma keying (typically green for green screen)
157 DtVector myMaskColor;
158
159 //! \brief Selected chroma keying algorithm (0-4 for different methods)
161
162 //! \brief First algorithm parameter, meaning varies by algorithm type
163 float myA;
164
165 //! \brief Second algorithm parameter, meaning varies by algorithm type
166 float myB;
167
168 //! \brief Third algorithm parameter, meaning varies by algorithm type
169 float myC;
170
171 //! \brief Fourth algorithm parameter, meaning varies by algorithm type
172 float myD;
173
174 //! \brief Camera X offset in millimeters
175 float ix;
176
177 //! \brief Camera Y offset in millimeters
178 float iy;
179
180 //! \brief Camera Z offset in millimeters
181 float iz;
182
183 //! \brief Camera pitch offset in degrees
184 float ip;
185
186 //! \brief Flag indicating whether to show the camera adjustment menu
188
189 //! \brief Path to the camera projection geometry (mask model)
190 std::string myMaskPath;
191
192 //! \brief Flag indicating if cockpit controls visibility needs to be toggled
194};
195} // namespace makVre
Table-based access to Lua state for configuration data.
Definition initializer.h:38
bool myStickNeedsSwitch
Flag indicating if cockpit controls visibility needs to be toggled.
Definition mixedRealityUpdater.h:193
int myAlgorithm
Selected chroma keying algorithm (0-4 for different methods)
Definition mixedRealityUpdater.h:160
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
osg::ref_ptr< osg::Program > myMaskShader
Shader program used for blending camera imagery with virtual content.
Definition mixedRealityUpdater.h:154
makVrv::DtObserver * myObserver
Pointer to the observer used for positioning the mask.
Definition mixedRealityUpdater.h:145
float myC
Third algorithm parameter, meaning varies by algorithm type.
Definition mixedRealityUpdater.h:169
virtual makVre::DtVreMessageResult handleMenuActionMessage(makVre::DtVreMessage *msg)
Handles menu action messages for mixed reality controls.
virtual void setCockpitControlsVisible(bool visible)
Sets the visibility of cockpit controls.
float myA
First algorithm parameter, meaning varies by algorithm type.
Definition mixedRealityUpdater.h:163
virtual void updateMask()
Updates the mask transform and shader parameters.
bool myShowCameraMenu
Flag indicating whether to show the camera adjustment menu.
Definition mixedRealityUpdater.h:187
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the mixed reality updater component.
virtual const char * type() const override
Returns the component type identifier.
virtual ~DtMixedRealityUpdater() override
Virtual destructor for DtMixedRealityUpdater.
osg::ref_ptr< osg::MatrixTransform > myMaskTransform
Transform node for the masking geometry.
Definition mixedRealityUpdater.h:151
float myB
Second algorithm parameter, meaning varies by algorithm type.
Definition mixedRealityUpdater.h:166
virtual void shutdown() override
Shuts down the mixed reality updater component.
DtMixedRealityUpdater()
Constructor for DtMixedRealityUpdater.
float myD
Fourth algorithm parameter, meaning varies by algorithm type.
Definition mixedRealityUpdater.h:172
float ix
Camera X offset in millimeters.
Definition mixedRealityUpdater.h:175
float ip
Camera pitch offset in degrees.
Definition mixedRealityUpdater.h:184
virtual void tick(double dt) override
Called every frame to update the mixed reality state.
virtual void handleReloadShader()
Handles shader reload requests.
float iz
Camera Z offset in millimeters.
Definition mixedRealityUpdater.h:181
DtVector myMaskColor
Color used for chroma keying (typically green for green screen)
Definition mixedRealityUpdater.h:157
float iy
Camera Y offset in millimeters.
Definition mixedRealityUpdater.h:178
makVrv::DtVirtualRealityDriver * myVrDriver
Pointer to the virtual reality driver that provides camera integration.
Definition mixedRealityUpdater.h:148
std::string myMaskPath
Path to the camera projection geometry (mask model)
Definition mixedRealityUpdater.h:190
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 * algorithm
Definition mixedRealityUpdater.h:46
constexpr const char * A
Definition mixedRealityUpdater.h:43
constexpr const char * D
Definition mixedRealityUpdater.h:58
constexpr const char * cameraProjectionGeometry
Definition mixedRealityUpdater.h:55
constexpr const char * B
Definition mixedRealityUpdater.h:49
constexpr const char * C
Definition mixedRealityUpdater.h:52
constexpr const char * maskColor
Definition mixedRealityUpdater.h:61
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition mixedRealityUpdater.h:35
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtMixedRealityUpdaterType
Type identifier for DtMixedRealityUpdater component.
Definition mixedRealityUpdater.h:67
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.