VR-Engage  2.2
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
20namespace makVrv
21{
22class DtObserver;
23}
24
25namespace makVre
26{
27class DtVreMessage;
28
30{
31//! \ingroup RoleConfigParams
32//! \defgroup LaserTargetDesignatorSimLogicRoleParams Laser Target Designator Sim Logic Role Parameters
33//! \roleInherits{PlayerComponentRoleParams}
34//! Configuration Options for laser target designator simulation logic role.
35//! @{
36
37//! \vreRoleParam{disableVrHeadPose,bool,true,laserTargetDesignatorSimLogic,Whether to disable VR head pose tracking when using the laser target designator.}
38constexpr const char* disableVrHeadPose = "disableVrHeadPose";
39
40//! \vreRoleParamRequired{inputConfigFile,string,laserTargetDesignatorSimLogic,"configs/input/laserDesignator.lua",Input configuration file path defining laser target designator control bindings.}
41constexpr const char* inputConfigFile = "inputConfigFile";
42
43//! @}
44} // namespace LaserTargetDesignatorSimLogicConfig
45
46class DtVreMessage;
47
48//! \brief Type identifier for DtLaserTargetDesignatorSimLogic component
49constexpr const char* DtLaserTargetDesignatorSimLogicType = "DtLaserTargetDesignatorSimLogic";
50
51//! \brief Component that provides laser target designator functionality
52//!
53//! DtLaserTargetDesignatorSimLogic provides the capability to turn a laser target
54//! designator device on/off. A laser may be either immediately toggled on/off
55//! or started and then stopped at some later time, to provide a 'press and hold'
56//! interface to the device.
57//!
58//! Input handler details (for configuring in an SMS input configuration file):
59//! - Group: "laser-target-designator"
60//! - Handler functions: "toggle-laser", "press-and-hold-to-lase"
62{
63public:
64 //! \brief Constructor for DtLaserTargetDesignatorSimLogic
65 //!
66 //! Initializes component state with default values
68
69 //! \brief Virtual destructor for DtLaserTargetDesignatorSimLogic
71
72 //! \brief Initializes the laser target designator component
73 //! \param player Pointer to the player station this component belongs to
74 //! \param config Configuration table containing laser designator settings
75 //! \return True if initialization succeeded, false otherwise
76 //!
77 //! Configures input handlers, sets up message handlers, initializes sensor modes,
78 //! and connects to necessary signals for pose information updates
79 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
80 //! \brief Called every frame to update the laser designator
81 //! \param dt Delta time since the last frame in seconds
82 //!
83 //! Updates the laser target location if the laser is currently active
84 virtual void tick(double dt) override;
85 //! \brief Shuts down the laser target designator component
86 //!
87 //! Cleans up input handlers, message handlers, disconnects signals,
88 //! and restores original sensor mode
89 virtual void shutdown() override;
90
91 //! \brief Returns the type identifier for this component
92 //! \return The type string for DtLaserTargetDesignatorSimLogic
93 virtual const char* type() const override;
94
95 //! \brief Starts the laser target designator at the current aim point
96 //!
97 //! Performs a ray cast from the observer through the center of the screen,
98 //! sends a StartLasingLocationMessage with the detected location, and
99 //! sets the laser state to on
100 virtual void startLasingLocation();
101
102 //! \brief Stops the laser target designator
103 //!
104 //! Sends a StopLasingLocationMessage and sets the laser state to off
105 virtual void stopLasingLocation();
106
107 //! \brief Updates the current laser target location
108 //!
109 //! Performs a ray cast from the observer through the center of the screen
110 //! and sends a SetLasingLocationMessage with the updated location
111 virtual void updateLasingLocation();
112
113 //! \brief Toggles the laser target designator on or off
114 //!
115 //! If the laser is currently on, calls stopLasingLocation();
116 //! otherwise, calls startLasingLocation()
117 virtual void toggleLasingState();
118
119 //! \brief Toggles between IR and visual sensor modes
120 //!
121 //! Switches the observer's sensor mode between IR and visual,
122 //! updating the IRSensorOn state attribute accordingly
123 virtual void toggleIRSensor();
124
125 //! \brief Input handler function for toggle laser action
126 //! \param value Input value (1.0 to toggle the laser state)
127 //!
128 //! Toggles the laser on/off when the incoming value is 1
129 virtual void handleToggleLaser(float value);
130
131 //! \brief Input handler function for press-and-hold lasing action
132 //! \param value Input value (1.0 = on, 0.0 = off)
133 //!
134 //! Turns the laser on if the incoming value is 1, and
135 //! turns it off if the incoming value is 0
136 virtual void handlePressAndHoldToLase(float value);
137
138 //! \brief Checks if the laser is currently active
139 //! \return True if the laser is currently on, false otherwise
140 //!
141 //! Returns the current state of the "laserOn" attribute
142 virtual bool isLasingOn() const;
143
144 //! \brief Handles menu action messages for the laser designator
145 //! \param msg The menu action message to handle
146 //! \return Message handling result indicating if the message was handled
147 //!
148 //! Processes "toggleLasingState", "toggleIRSensor", and "laserCodeInput" actions
150
151protected:
152 //! \brief Handles changes to the laserOn attribute
153 //! \param on New value of the laserOn attribute
154 //!
155 //! Updates the laserState attribute text based on the on/off state
156 void handleLaserOnChange(bool on);
157
158 //! \brief Updates pose information for VR head tracking
159 //!
160 //! If VR is enabled and disableVrHeadPose is true, this method
161 //! resets the camera position and orientation to prevent head tracking
162 //! from affecting the aiming of the laser designator
164
165 //! \brief Input logic that handles mapping of input actions to functions
167
168 //! \brief Pointer to the observer used for ray casting and sensor mode control
169 makVrv::DtObserver* myObserver;
170
171 //! \brief Path to the input configuration file
172 std::string myInputConfigFile;
173
174 //! \brief Name of the IR sensor mode in VR-Vantage
175 std::string myIRSensorMode;
176
177 //! \brief Name of the visual sensor mode in VR-Vantage
179
180 //! \brief Original sensor mode to restore on shutdown
182
183 //! \brief Flag indicating if the laser has been started
185
186 //! \brief Flag controlling whether VR head pose is disabled during lasing
187 //!
188 //! When true, VR head tracking is disabled to prevent head movement
189 //! from affecting the aim point of the laser designator
191};
192} // namespace makVre
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:35
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:172
makVrv::DtObserver * myObserver
Pointer to the observer used for ray casting and sensor mode control.
Definition laserTargetDesignatorSimLogic.h:169
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.
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:181
std::string myVisualSensorMode
Name of the visual sensor mode in VR-Vantage.
Definition laserTargetDesignatorSimLogic.h:178
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:190
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:184
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:175
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:166
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.
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:38
constexpr const char * inputConfigFile
Definition laserTargetDesignatorSimLogic.h:41
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:30
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtLaserTargetDesignatorSimLogicType
Type identifier for DtLaserTargetDesignatorSimLogic component.
Definition laserTargetDesignatorSimLogic.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.