VR-Engage  2.3
Loading...
Searching...
No Matches
laserTargetDesignatorSimLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file laserTargetDesignatorSimLogic.h
7//! \brief Component providing laser target designator functionality for ground and air vehicles
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
16
18#include "vreUtil/initializer.h"
19
20#include <vrvCore/DtUniqueID.h>
21
22#include <vector>
23
24namespace makVrv
25{
26class DtObserver;
27}
28
29namespace makVre
30{
31class DtVreMessage;
32
34{
35//! \ingroup RoleConfigParams
36//! \defgroup LaserTargetDesignatorSimLogicRoleParams Laser Target Designator Sim Logic Role Parameters
37//! \roleInherits{PlayerComponentRoleParams}
38//! Configuration Options for laser target designator simulation logic role.
39//! @{
40
41//! \vreRoleParam{disableVrHeadPose,bool,true,laserTargetDesignatorSimLogic,Whether to disable VR head pose tracking when using the laser target designator.}
42constexpr const char* disableVrHeadPose = "disableVrHeadPose";
43
44//! \vreRoleParamRequired{inputConfigFile,string,laserTargetDesignatorSimLogic,"configs/input/laserDesignator.lua",Input configuration file path defining laser target designator control bindings.}
45constexpr const char* inputConfigFile = "inputConfigFile";
46
47//! @}
48} // namespace LaserTargetDesignatorSimLogicConfig
49
50class DtVreMessage;
51
52//! \brief Type identifier for DtLaserTargetDesignatorSimLogic component
53constexpr const char* DtLaserTargetDesignatorSimLogicType = "DtLaserTargetDesignatorSimLogic";
54
55//! \brief Component that provides laser target designator functionality
56//!
57//! DtLaserTargetDesignatorSimLogic provides the capability to turn a laser target
58//! designator device on/off. A laser may be either immediately toggled on/off
59//! or started and then stopped at some later time, to provide a 'press and hold'
60//! interface to the device.
61//!
62//! Input handler details (for configuring in an SMS input configuration file):
63//! - Group: "laser-target-designator"
64//! - Handler functions: "toggle-laser", "press-and-hold-to-lase"
66{
67public:
68 //! \brief Constructor for DtLaserTargetDesignatorSimLogic
69 //!
70 //! Initializes component state with default values
72
73 //! \brief Virtual destructor for DtLaserTargetDesignatorSimLogic
75
76 //! \brief Initializes the laser target designator component
77 //! \param player Pointer to the player station this component belongs to
78 //! \param config Configuration table containing laser designator settings
79 //! \return True if initialization succeeded, false otherwise
80 //!
81 //! Configures input handlers, sets up message handlers, initializes sensor modes,
82 //! and connects to necessary signals for pose information updates
83 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
84 //! \brief Called every frame to update the laser designator
85 //! \param dt Delta time since the last frame in seconds
86 //!
87 //! Updates the laser target location if the laser is currently active
88 virtual void tick(double dt) override;
89 //! \brief Shuts down the laser target designator component
90 //!
91 //! Cleans up input handlers, message handlers, disconnects signals,
92 //! and restores original sensor mode
93 virtual void shutdown() override;
94
95 //! \brief Returns the type identifier for this component
96 //! \return The type string for DtLaserTargetDesignatorSimLogic
97 virtual const char* type() const override;
98
99 //! \brief Starts the laser target designator at the current aim point
100 //!
101 //! Performs a ray cast from the observer through the center of the screen,
102 //! sends a StartLasingLocationMessage with the detected location, and
103 //! sets the laser state to on
104 virtual void startLasingLocation();
105
106 //! \brief Stops the laser target designator
107 //!
108 //! Sends a StopLasingLocationMessage and sets the laser state to off
109 virtual void stopLasingLocation();
110
111 //! \brief Updates the current laser target location
112 //!
113 //! Performs a ray cast from the observer through the center of the screen
114 //! and sends a SetLasingLocationMessage with the updated location
115 virtual void updateLasingLocation();
116
117 //! \brief Toggles the laser target designator on or off
118 //!
119 //! If the laser is currently on, calls stopLasingLocation();
120 //! otherwise, calls startLasingLocation()
121 virtual void toggleLasingState();
122
123 //! \brief Toggles between IR and visual sensor modes
124 //!
125 //! Switches the observer's sensor mode between IR and visual,
126 //! updating the IRSensorOn state attribute accordingly
127 virtual void toggleIRSensor();
128
129 //! \brief Input handler function for toggle laser action
130 //! \param value Input value (1.0 to toggle the laser state)
131 //!
132 //! Toggles the laser on/off when the incoming value is 1
133 virtual void handleToggleLaser(float value);
134
135 //! \brief Input handler function for press-and-hold lasing action
136 //! \param value Input value (1.0 = on, 0.0 = off)
137 //!
138 //! Turns the laser on if the incoming value is 1, and
139 //! turns it off if the incoming value is 0
140 virtual void handlePressAndHoldToLase(float value);
141
142 //! \brief Checks if the laser is currently active
143 //! \return True if the laser is currently on, false otherwise
144 //!
145 //! Returns the current state of the "laserOn" attribute
146 virtual bool isLasingOn() const;
147
148 //! \brief Handles menu action messages for the laser designator
149 //! \param msg The menu action message to handle
150 //! \return Message handling result indicating if the message was handled
151 //!
152 //! Processes "toggleLasingState", "toggleIRSensor", and "laserCodeInput" actions
154
155protected:
156 //! \brief Appends all laser designator element IDs to a raycast ignore list
157 //! \param ignoreList List of element IDs the lasing ray cast should pass through
158 //!
159 //! Laser designator visuals (spot and code text) are pickable, so the
160 //! center-screen lasing ray cast can hit a designator's own visualization
161 //! and feed that location back to the simulation, walking the laser spot
162 //! toward the viewer. Ignoring all laser designator elements lets the ray
163 //! reach the entity or terrain behind them.
164 void appendLaserDesignatorElements(std::vector<makVrv::DtElementID>& ignoreList) const;
165
166 //! \brief Handles changes to the laserOn attribute
167 //! \param on New value of the laserOn attribute
168 //!
169 //! Updates the laserState attribute text based on the on/off state
170 void handleLaserOnChange(bool on);
171
172 //! \brief Updates pose information for VR head tracking
173 //!
174 //! If VR is enabled and disableVrHeadPose is true, this method
175 //! resets the camera position and orientation to prevent head tracking
176 //! from affecting the aiming of the laser designator
178
179 //! \brief Input logic that handles mapping of input actions to functions
181
182 //! \brief Pointer to the observer used for ray casting and sensor mode control
183 makVrv::DtObserver* myObserver;
184
185 //! \brief Path to the input configuration file
186 std::string myInputConfigFile;
187
188 //! \brief Name of the IR sensor mode in VR-Vantage
189 std::string myIRSensorMode;
190
191 //! \brief Name of the visual sensor mode in VR-Vantage
193
194 //! \brief Original sensor mode to restore on shutdown
196
197 //! \brief Flag indicating if the laser has been started
199
200 //! \brief Flag controlling whether VR head pose is disabled during lasing
201 //!
202 //! When true, VR head tracking is disabled to prevent head movement
203 //! from affecting the aim point of the laser designator
205
206 //! \brief Attribute handle storing the laser code used for target designation.
207 //! \vreAttrKey{laserCode}
209
210 //! \brief Attribute handle indicating whether the laser designator is currently lasing.
211 //! \vreAttrKey{laserOn}
213
214 //! \brief Attribute handle storing the laser state string ("ON" or "OFF").
215 //! \vreAttrKey{laserState}
217
218 //! \brief Attribute handle indicating whether the IR sensor is currently active.
219 //! \vreAttrKey{IRSensorOn}
221
222 //! \brief Attribute handle indicating whether VR mode is enabled for the player.
223 //! \vreAttrKey{vr-enabled}
225};
226} // namespace makVre
Type-specific handle class for attributes.
Definition attributeHandle.h:229
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Class for managing input configuration and handling in VR-Engage.
Definition inputLogic.h:39
DtAttributeHandleType< bool > myLaserOnAttr
Attribute handle indicating whether the laser designator is currently lasing.
Definition laserTargetDesignatorSimLogic.h:212
void appendLaserDesignatorElements(std::vector< makVrv::DtElementID > &ignoreList) const
Appends all laser designator element IDs to a raycast ignore list.
virtual void stopLasingLocation()
Stops the laser target designator.
virtual const char * type() const override
Returns the type identifier for this component.
std::string myInputConfigFile
Path to the input configuration file.
Definition laserTargetDesignatorSimLogic.h:186
makVrv::DtObserver * myObserver
Pointer to the observer used for ray casting and sensor mode control.
Definition laserTargetDesignatorSimLogic.h:183
virtual void toggleLasingState()
Toggles the laser target designator on or off.
virtual void shutdown() override
Shuts down the laser target designator component.
DtLaserTargetDesignatorSimLogic()
Constructor for DtLaserTargetDesignatorSimLogic.
DtAttributeHandleType< bool > myIRSensorOnAttr
Attribute handle indicating whether the IR sensor is currently active.
Definition laserTargetDesignatorSimLogic.h:220
virtual void tick(double dt) override
Called every frame to update the laser designator.
std::string myCachedSensorMode
Original sensor mode to restore on shutdown.
Definition laserTargetDesignatorSimLogic.h:195
std::string myVisualSensorMode
Name of the visual sensor mode in VR-Vantage.
Definition laserTargetDesignatorSimLogic.h:192
virtual void handlePressAndHoldToLase(float value)
Input handler function for press-and-hold lasing action.
bool myDisableVrHeadPose
Flag controlling whether VR head pose is disabled during lasing.
Definition laserTargetDesignatorSimLogic.h:204
void updatePoseInformation()
Updates pose information for VR head tracking.
virtual void toggleIRSensor()
Toggles between IR and visual sensor modes.
bool myLaserStarted
Flag indicating if the laser has been started.
Definition laserTargetDesignatorSimLogic.h:198
DtAttributeHandleType< int > myLaserCodeAttr
Attribute handle storing the laser code used for target designation.
Definition laserTargetDesignatorSimLogic.h:208
virtual DtVreMessageResult handleMenuMessage(makVre::DtVreMessage *msg)
Handles menu action messages for the laser designator.
std::string myIRSensorMode
Name of the IR sensor mode in VR-Vantage.
Definition laserTargetDesignatorSimLogic.h:189
virtual void startLasingLocation()
Starts the laser target designator at the current aim point.
DtInputLogic myInputLogic
Input logic that handles mapping of input actions to functions.
Definition laserTargetDesignatorSimLogic.h:180
DtAttributeHandleType< std::string > myLaserStateAttr
Attribute handle storing the laser state string ("ON" or "OFF").
Definition laserTargetDesignatorSimLogic.h:216
virtual bool isLasingOn() const
Checks if the laser is currently active.
virtual void updateLasingLocation()
Updates the current laser target location.
virtual ~DtLaserTargetDesignatorSimLogic() override
Virtual destructor for DtLaserTargetDesignatorSimLogic.
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the laser target designator component.
void handleLaserOnChange(bool on)
Handles changes to the laserOn attribute.
virtual void handleToggleLaser(float value)
Input handler function for toggle laser action.
DtAttributeHandleType< bool > myVrEnabledAttr
Attribute handle indicating whether VR mode is enabled for the player.
Definition laserTargetDesignatorSimLogic.h:224
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 * disableVrHeadPose
Definition laserTargetDesignatorSimLogic.h:42
constexpr const char * inputConfigFile
Definition laserTargetDesignatorSimLogic.h:45
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Provides configuration initialization for VREngage components.
Defines the DtInputLogic class for handling input in VR-Engage.
Definition laserTargetDesignatorSimLogic.h:34
!
Definition glsVreMessageUtil.h:50
constexpr const char * DtLaserTargetDesignatorSimLogicType
Type identifier for DtLaserTargetDesignatorSimLogic component.
Definition laserTargetDesignatorSimLogic.h:53
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.