VR-Engage  2.3
Loading...
Searching...
No Matches
DtVreSensorFieldOfViewManager.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file DtVreSensorFieldOfViewManager.h
7//! \brief Defines the VR-Engage sensor field of view manager
8//!
9//! This file contains the DtVreSensorFieldOfViewManager class which extends the
10//! base DtSensorFieldOfViewManager to provide VR-Engage-specific behavior for
11//! managing sensor field of view states, associated observers, and sensor views.
12//! \ingroup vrvCore
13
14#pragma once
15
17#include <vrvCore/vrvCore.h>
18#include <vrvCore/DtSensorFieldOfViewManager.h>
19#include <vrvCore/DtSensorFieldOfViewData.h>
20
22
23#include <map>
24#include <set>
25
26namespace makVrv
27{
28//! \brief Forward declaration of the observer class
29class DtObserver;
30
31//! \brief Forward declaration of the sensor view overlay class
32class DtSensorViewOverlay;
33} // namespace makVrv
34
35namespace makVre
36{
37//! \brief VR-Engage sensor field of view manager
38//!
39//! DtVreSensorFieldOfViewManager extends the base DtSensorFieldOfViewManager
40//! to provide VR-Engage-specific behavior for managing sensor field of view
41//! states and the observers associated with them. This includes handling
42//! target object position updates, processing tracked locations, managing
43//! sensor view windows, and finding appropriate display windows and channels
44//! for sensor views.
45//! \ingroup vrvCore
46class PLAYERSTATION_DLL DtVreSensorFieldOfViewManager : public makVrv::DtSensorFieldOfViewManager
47{
48public:
49
50 //! \brief Destructor
51 //!
52 //! Cleans up resources used by the sensor field of view manager.
54
55 //! \brief Constructor
56 //! \param de Reference to the display engine
57 //!
58 //! Creates a new sensor field of view manager associated with the
59 //! specified display engine. This constructor is technically protected,
60 //! as instances should be created through the instance() factory method.
62
63 //! \brief Handles target object position messages
64 //! \param msg Pointer to the target object position message
65 //! \return Message processing result
66 //!
67 //! Processes messages containing target object position updates.
68 //! Updates the cached position and may trigger sensor view updates.
70
71 //! \brief Updates sensor field of view state for a specific sensor
72 //! \param hostId Unique ID of the host entity
73 //! \param sensorId Unique ID of the sensor
74 //! \param observerName Name of the observer to update
75 //!
76 //! Updates the sensor field of view state for the specified sensor,
77 //! which may involve creating or updating sensor views and observers.
78 //! Overridden to provide VR-Engage-specific update behavior.
79 //! Handles observer cleanup, target tracking, stabilized orientation, zoom, and overlay refresh as separate steps.
80 virtual void update(makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId,
81 const std::string& observerName) override;
82
83 //! \brief Processes the location of a tracked target
84 //! \param observer Pointer to the observer
85 //! \param hostEntity Element ID of the host entity
86 //! \param relativeLocation Relative location of the tracked target from the host
87 //! \param targetLocation Absolute location of the tracked target
88 //!
89 //! Processes the location of a tracked target relative to the host entity.
90 //! This method is overridden to make it public, allowing VR-Engage systems
91 //! to directly process track locations when needed.
92 virtual void processTrackLocation(makVrv::DtObserver* observer, makVrv::DtElementID hostEntity,
93 const DtVector& relativeLocation, const DtVector& targetLocation) override;
94
95 //! \brief Finds the display window and channel for an observer
96 //! \param observer Pointer to the observer
97 //! \param displayName Output parameter for the display name
98 //! \param windowName Output parameter for the window name
99 //! \param channelName Output parameter for the channel name
100 //! \return True if a display window and channel were found, false otherwise
101 //!
102 //! Finds the appropriate display window and channel for the specified observer.
103 //! This method is overridden to make it public, allowing VR-Engage systems
104 //! to directly find display windows and channels when needed.
105 virtual bool findDisplayWindowAndChannel(const makVrv::DtObserver* observer, std::string& displayName,
106 std::string& windowName, std::string& channelName) const override;
107
108 //! \brief Removes a sensor view window
109 //! \param entId Unique ID of the entity
110 //! \param sensorId Unique ID of the sensor
111 //!
112 //! Removes a sensor view window that has been created for the specified
113 //! entity and sensor. This method is overridden because the base class implementation
114 //! attempts to delete the window as well, which would also delete channels
115 //! associated with it. The VR-Engage implementation provides a safer approach
116 //! that avoids unintended channel deletion.
117 virtual void removeSensorView(makVrv::DtUniqueID entId, makVrv::DtUniqueID sensorId) override;
118
119 //! \brief Adds a sensor observer and registers updates on signal_preObserverUpdate.
120 //! \param observerName Name of the observer
121 //! \param hostId Element ID of the host entity
122 //! \param sensorId Element ID of the sensor
123 //! \param createControls Unused; forwarded to the base class
124 //!
125 //! The base class updates on signal_postUpdate, after observers are positioned, which makes
126 //! stabilized views lag the host by one frame.
127 virtual void addSensorObserver(const std::string& observerName, makVrv::DtElementID hostId,
128 makVrv::DtElementID sensorId, bool createControls) override;
129
130 //! \brief Starts the sensor's stabilized view from the gimbal angles instead of the observer's pose.
131 //! \param hostId Element ID of the host entity
132 //! \param sensorId Element ID of the sensor
133 //!
134 //! Use for observers created for the view, which have no meaningful pose until their first update.
135 virtual void disableObserverSeeding(makVrv::DtElementID hostId, makVrv::DtElementID sensorId);
136
137protected:
139 {
150
157 //! False after tracking, when the observer still points at the old target.
159
160 //! Last horizon-relative pitch and host-relative yaw commanded while tracking.
162 double myTrackedTopoPitch = 0.0;
164
165 //! Last geocentric point aimed at while tracking.
168
169 //! After tracking, hold the tracked pitch until the gimbal settles; its slew to the hold angle
170 //! converts body-relative to horizon-relative elevation and is not a real change of view.
174 };
175
176 //! \brief Cached position of the last tracked target
177 //!
178 //! Stores the position of the last tracked target for use in subsequent
179 //! calculations or updates. This avoids redundant position calculations
180 //! or lookups when the same target is being processed multiple times.
182
183 std::map<HostAndSensorId, DtPitchRollStabilizationState> myPitchRollStabilization;
184
185 //! Sensors whose stabilization state must not be seeded from the observer pose.
186 std::set<HostAndSensorId> myObserverSeedingDisabled;
187
188protected:
189 //! \brief Removes cached stabilization state for one host and sensor.
190 virtual void clearStabilization(const HostAndSensorId& hostAndSensor);
191
192 //! \brief Returns the stabilization state for a sensor, creating it from player settings if needed.
194 const HostAndSensorId& hostAndSensor, makVrv::DtUniqueID hostId);
195
196 //! \brief Prepares stabilization state for a frame in which the observer tracks a target.
198 const HostAndSensorId& hostAndSensor, makVrv::DtUniqueID hostId);
199
200 //! \brief Aims a stabilized observer at a world-space target with zero roll.
201 virtual bool trackRollLevel(makVrv::DtObserver* observer, const HostAndSensorId& hostAndSensor,
202 makVrv::DtUniqueID hostId, makVrv::DtUniqueID fovHostId, const DtVector& relativeLocation,
203 const DtVector& targetNetPosition);
204
205 //! \brief Resolves and applies the current tracked target, including cached-target fallback.
206 //! \return True if target handling owns this frame and stabilized-view processing should not run.
207 virtual bool updateTrackingView(makVrv::DtObserver* observer, const HostAndSensorId& hostAndSensor,
208 makVrv::DtUniqueID hostId, makVrv::DtUniqueID fovHostId, const DtVector& relativeLocation,
209 makVrv::DtUniqueID targetId, const DtVector& targetLocation, const std::string& trackingMode);
210
211 //! \brief Seeds stabilized angles from the sensor, prior target view, or initial observer pose.
212 virtual void initializeStabilizationState(makVrv::DtObserver* observer, double hostTopoYaw, double fovRelativeYaw,
213 double fovRelativePitch, double fovRelativeRoll, DtPitchRollStabilizationState& state);
214
215 //! \brief Advances stabilized angles using sensor movement and tracking-resume settling.
216 virtual void advanceStabilizationState(double fovRelativeYaw, double fovRelativePitch,
218
219 //! \brief Applies horizon-relative pitch/roll stabilization when no target is being tracked.
220 virtual void updateStabilizedView(makVrv::DtObserver* observer, const HostAndSensorId& hostAndSensor,
221 makVrv::DtUniqueID hostId, makVrv::DtUniqueID fovHostId, const DtVector& relativeLocation,
222 double fovRelativeYaw, double fovRelativePitch, double fovRelativeRoll);
223};
224} // namespace makVre
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
virtual void updateStabilizedView(makVrv::DtObserver *observer, const HostAndSensorId &hostAndSensor, makVrv::DtUniqueID hostId, makVrv::DtUniqueID fovHostId, const DtVector &relativeLocation, double fovRelativeYaw, double fovRelativePitch, double fovRelativeRoll)
Applies horizon-relative pitch/roll stabilization when no target is being tracked.
virtual void processTrackLocation(makVrv::DtObserver *observer, makVrv::DtElementID hostEntity, const DtVector &relativeLocation, const DtVector &targetLocation) override
Processes the location of a tracked target.
DtVreSensorFieldOfViewManager(makVrv::DtDe &de)
Constructor.
virtual bool findDisplayWindowAndChannel(const makVrv::DtObserver *observer, std::string &displayName, std::string &windowName, std::string &channelName) const override
Finds the display window and channel for an observer.
virtual void initializeStabilizationState(makVrv::DtObserver *observer, double hostTopoYaw, double fovRelativeYaw, double fovRelativePitch, double fovRelativeRoll, DtPitchRollStabilizationState &state)
Seeds stabilized angles from the sensor, prior target view, or initial observer pose.
DtVector myCachedPosition
Cached position of the last tracked target.
Definition DtVreSensorFieldOfViewManager.h:181
virtual void update(makVrv::DtUniqueID hostId, makVrv::DtUniqueID sensorId, const std::string &observerName) override
Updates sensor field of view state for a specific sensor.
std::set< HostAndSensorId > myObserverSeedingDisabled
Sensors whose stabilization state must not be seeded from the observer pose.
Definition DtVreSensorFieldOfViewManager.h:186
virtual DtPitchRollStabilizationState & suspendStabilizationForTracking(const HostAndSensorId &hostAndSensor, makVrv::DtUniqueID hostId)
Prepares stabilization state for a frame in which the observer tracks a target.
virtual void removeSensorView(makVrv::DtUniqueID entId, makVrv::DtUniqueID sensorId) override
Removes a sensor view window.
std::map< HostAndSensorId, DtPitchRollStabilizationState > myPitchRollStabilization
Definition DtVreSensorFieldOfViewManager.h:183
virtual void addSensorObserver(const std::string &observerName, makVrv::DtElementID hostId, makVrv::DtElementID sensorId, bool createControls) override
Adds a sensor observer and registers updates on signal_preObserverUpdate.
virtual ~DtVreSensorFieldOfViewManager() override
Destructor.
virtual void clearStabilization(const HostAndSensorId &hostAndSensor)
Removes cached stabilization state for one host and sensor.
virtual DtPitchRollStabilizationState & pitchRollStabilizationState(const HostAndSensorId &hostAndSensor, makVrv::DtUniqueID hostId)
Returns the stabilization state for a sensor, creating it from player settings if needed.
virtual void disableObserverSeeding(makVrv::DtElementID hostId, makVrv::DtElementID sensorId)
Starts the sensor's stabilized view from the gimbal angles instead of the observer's pose.
virtual bool trackRollLevel(makVrv::DtObserver *observer, const HostAndSensorId &hostAndSensor, makVrv::DtUniqueID hostId, makVrv::DtUniqueID fovHostId, const DtVector &relativeLocation, const DtVector &targetNetPosition)
Aims a stabilized observer at a world-space target with zero roll.
virtual makVre::DtVreMessageResult handleTargetObjectPosition(makVre::DtVreMessage *msg)
Handles target object position messages.
virtual bool updateTrackingView(makVrv::DtObserver *observer, const HostAndSensorId &hostAndSensor, makVrv::DtUniqueID hostId, makVrv::DtUniqueID fovHostId, const DtVector &relativeLocation, makVrv::DtUniqueID targetId, const DtVector &targetLocation, const std::string &trackingMode)
Resolves and applies the current tracked target, including cached-target fallback.
virtual void advanceStabilizationState(double fovRelativeYaw, double fovRelativePitch, DtPitchRollStabilizationState &state)
Advances stabilized angles using sensor movement and tracking-resume settling.
Defines export macros for the VR-Engage Player Station library.
#define PLAYERSTATION_DLL
Definition export.h:24
!
Definition glsVreMessageUtil.h:50
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Definition appLauncherComponent.h:28
makVrv::DtDe * de()
Gets the display element pointer used by the plugin.
Definition DtVreSensorFieldOfViewManager.h:139
double myTrackedRelativeYaw
Definition DtVreSensorFieldOfViewManager.h:163
double myHorizonRelativePitch
Definition DtVreSensorFieldOfViewManager.h:156
double myLastFovRelativeYaw
Definition DtVreSensorFieldOfViewManager.h:154
bool myHaveLastTrackedTarget
Last geocentric point aimed at while tracking.
Definition DtVreSensorFieldOfViewManager.h:166
bool myEnablePitchRollStabilization
Definition DtVreSensorFieldOfViewManager.h:151
double myLastFovRelativePitch
Definition DtVreSensorFieldOfViewManager.h:155
double myTrackedTopoPitch
Definition DtVreSensorFieldOfViewManager.h:162
DtVector myLastTrackedTargetNet
Definition DtVreSensorFieldOfViewManager.h:167
bool myResumingFromTracking
After tracking, hold the tracked pitch until the gimbal settles; its slew to the hold angle converts ...
Definition DtVreSensorFieldOfViewManager.h:171
DtPitchRollStabilizationState()
Definition DtVreSensorFieldOfViewManager.h:140
bool myHaveTrackedOrientation
Last horizon-relative pitch and host-relative yaw commanded while tracking.
Definition DtVreSensorFieldOfViewManager.h:161
bool myInitialized
Definition DtVreSensorFieldOfViewManager.h:152
int mySettledFrames
Definition DtVreSensorFieldOfViewManager.h:173
bool mySeedFromObserver
False after tracking, when the observer still points at the old target.
Definition DtVreSensorFieldOfViewManager.h:158
int myResumeFrames
Definition DtVreSensorFieldOfViewManager.h:172
double myCommandedRelativeYaw
Definition DtVreSensorFieldOfViewManager.h:153
Defines the base class for all VREngage messages.