VR-Engage  2.2
Loading...
Searching...
No Matches
gunnerObserverUpdater.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file gunnerObserverUpdater.h
7//! \brief Observer updater component that provides gunner-specific view controls for weapons systems
8//! \ingroup vreCommonComponents
9
10#pragma once
11
15
17
19
20#include <matrix/vlVector.h>
21#include <matrix/vlQuaternion.h>
22
23namespace makVrv
24{
25class DtEntityFacade;
26class DtObserver;
27class DtSceneObject;
28}; // namespace makVrv
29
31{
32//! \ingroup RoleConfigParams
33//! \defgroup GunnerObserverUpdaterRoleParams Gunner Observer Updater Role Parameters
34//! \roleInherits{ObserverUpdaterRoleParams}
35//! Configuration Options for gunner observer updater role.
36//! @{
37
38//! \vreRoleParam{attachOffset,DtVector,"DtVector::zero()",gunnerObserverUpdater,Position offset from the attachment part for the observer.}
39constexpr const char* attachOffset = "attachOffset";
40
41//! \vreRoleParam{attachPart,int,DtPrimaryGun1,gunnerObserverUpdater,Part number of the vehicle to attach the observer to (typically the barrel).}
42constexpr const char* attachPart = "attachPart";
43
44//! \vreRoleParam{oriOffset,DtQuaternion,"DtQuaternion(0,0,0,1)",gunnerObserverUpdater,Orientation offset for the observer relative to the attachment part.}
45constexpr const char* oriOffset = "oriOffset";
46
47//! \vreRoleParam{sensorModes,table,"",gunnerObserverUpdater,Table mapping sensor mode names to VR-Vantage sensor identifiers.}
48constexpr const char* sensorModes = "sensorModes";
49
50//! @}
51} // namespace GunnerObserverUpdaterConfig
52
53namespace makVre
54{
55//! \brief Type identifier for DtGunnerObserverUpdater component
56constexpr const char* DtGunnerObserverUpdaterType = "DtGunnerObserverUpdater";
57
58//! \brief Observer updater component that handles gunner view functionality
59//!
60//! DtGunnerObserverUpdater attaches the observer to a weapon system and provides
61//! gunner-specific controls including zoom levels, sensor modes (visual, NVG, thermal),
62//! and appropriate gunner view positioning. It handles observer resets on player creation
63//! and manages smooth transitions between zoom levels.
65{
66public:
67 //! \brief Constructor for DtGunnerObserverUpdater
68 //!
69 //! Initializes observer state variables including attachment status and sensor modes
71
72 //! \brief Destructor for DtGunnerObserverUpdater
73 virtual ~DtGunnerObserverUpdater() override;
74
75 //! \brief Initializes the gunner observer updater component
76 //! \param player Pointer to the player station this component belongs to
77 //! \param config Configuration table containing gunner observer settings
78 //! \return True if initialization succeeded, false otherwise
79 //!
80 //! Sets up observer attachments, configures sensor modes, and registers message handlers
81 //! for player creation and reset events
82 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
83 //! \brief Called every frame to update the gunner observer
84 //! \param dt Delta time since the last frame in seconds
85 //!
86 //! Updates zoom interpolation, observer attachment properties, sensor modes,
87 //! and handles special cases when the vehicle is destroyed
88 virtual void tick(double dt) override;
89 //! \brief Shuts down the gunner observer updater component
90 //!
91 //! Removes message handlers, detaches the observer, and resets sensor modes
92 virtual void shutdown() override;
93
94 //! \brief Returns the type identifier for this component
95 //! \return The type string for DtGunnerObserverUpdater
96 virtual const char* type() const override;
97
98protected:
99 //! \brief Handles player creation messages
100 //! \param msg The player created message
101 //! \return Message handling result indicating message was handled
102 //!
103 //! Resets the observer when a new player is created
105
106 //! \brief Handles player reset messages
107 //! \param msg The reset message
108 //! \return Message handling result indicating message was handled
109 //!
110 //! Resets the observer when the player is reset
112
113 //! \brief Resets the observer to the proper attachment point and orientation
114 //!
115 //! Configures the observer to attach to the correct part of the entity with
116 //! the appropriate offset and rotation settings
118
119 //! \brief Updates the observer's sensor mode based on player state
120 //!
121 //! Changes sensor modes (visual, NVG, thermal) when the player's currentSensor attribute changes
123
124 //! \brief Updates observer behavior when the vehicle is destroyed
125 //!
126 //! Changes observer attachment type and resets when destruction state changes
128
129 //! \brief Flag indicating if the observer is attached to a scene object
131
132 //! \brief Pointer to the observer object being controlled
133 makVrv::DtObserver* myObserver;
134
135 //! \brief Interpolator for smooth zoom level transitions
137
138 //! \brief ID of the part to attach the observer to (e.g., gun barrel)
140
141 //! \brief Position offset from the attachment point
143
144 //! \brief Orientation offset from the attachment point
145 DtQuaternion myOriOffest;
146
147 //! \brief Currently active sensor view mode
149
150 //! \brief Map of SensorViews enums to VR-Engage sensor mode names
151 //!
152 //! This map is initialized with data from the player configuration and maps
153 //! the SensorViews enumeration values to their corresponding string names used
154 //! in VR-Vantage
155 std::map<enum SensorViews, std::string> mySensorModes;
156};
157} // namespace makVre
int myAttachPart
ID of the part to attach the observer to (e.g., gun barrel)
Definition gunnerObserverUpdater.h:139
std::map< enum SensorViews, std::string > mySensorModes
Map of SensorViews enums to VR-Engage sensor mode names.
Definition gunnerObserverUpdater.h:155
virtual const char * type() const override
Returns the type identifier for this component.
makVrv::DtObserver * myObserver
Pointer to the observer object being controlled.
Definition gunnerObserverUpdater.h:133
virtual ~DtGunnerObserverUpdater() override
Destructor for DtGunnerObserverUpdater.
makVre::DtLinearInterpolator< double > * myZoomInterpolator
Interpolator for smooth zoom level transitions.
Definition gunnerObserverUpdater.h:136
void updateDestroyed()
Updates observer behavior when the vehicle is destroyed.
DtVector myAttachedOffset
Position offset from the attachment point.
Definition gunnerObserverUpdater.h:142
DtQuaternion myOriOffest
Orientation offset from the attachment point.
Definition gunnerObserverUpdater.h:145
virtual makVre::DtVreMessageResult handlePlayerCreated(makVre::DtVreMessage *msg)
Handles player creation messages.
DtGunnerObserverUpdater()
Constructor for DtGunnerObserverUpdater.
virtual void tick(double dt) override
Called every frame to update the gunner observer.
SensorViews myLastSensorViewMode
Currently active sensor view mode.
Definition gunnerObserverUpdater.h:148
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the gunner observer updater component.
virtual makVre::DtVreMessageResult handlePlayerReset(makVre::DtVreMessage *msg)
Handles player reset messages.
virtual void shutdown() override
Shuts down the gunner observer updater component.
void resetObserver()
Resets the observer to the proper attachment point and orientation.
void updateSensor()
Updates the observer's sensor mode based on player state.
bool myAttached
Flag indicating if the observer is attached to a scene object.
Definition gunnerObserverUpdater.h:130
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Linear interpolation template class.
Definition linearInterpolator.h:23
DtObserverUpdater()
Default constructor for DtObserverUpdater.
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Base component for managing observer parameters and view settings.
constexpr const char * oriOffset
\vreRoleParam{oriOffset,DtQuaternion,"DtQuaternion(0,0,0,1)",gunnerObserverUpdater,...
Definition gunnerObserverUpdater.h:45
constexpr const char * attachPart
Definition gunnerObserverUpdater.h:42
constexpr const char * attachOffset
Definition gunnerObserverUpdater.h:39
constexpr const char * sensorModes
Definition gunnerObserverUpdater.h:48
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Provides a template class for linear interpolation between values.
Definition gunnerObserverUpdater.h:31
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtGunnerObserverUpdaterType
Type identifier for DtGunnerObserverUpdater component.
Definition gunnerObserverUpdater.h:56
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
SensorViews
Enumeration of available sensor view modes.
Definition stateDefines.h:18
Definition appLauncherComponent.h:28
Common enumeration definitions used throughout the VREngage system.
Defines the base class for all VREngage messages.