VR-Engage  2.2
Loading...
Searching...
No Matches
slewToCueControl.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file slewToCueControl.h
7//! \brief Component for weapon system slew-to-cue functionality based on observer orientation
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
16
17namespace makVre
18{
19class DtPlayerStation;
20
22{
23//! \ingroup RoleConfigParams
24//! \defgroup SlewToCueControlRoleParams Slew To Cue Control Role Parameters
25//! \roleInherits{PlayerComponentRoleParams}
26//! Configuration Options for slew to cue control role.
27//! @{
28
29//! \vreRoleParam{inputConfigFile,string,"",slewToCueControl,Input configuration file path for slew-to-cue control bindings.}
30constexpr const char* inputConfigFile = "inputConfigFile";
31
32//! \vreRoleParam{inputConfigGroup,string,"commander",slewToCueControl,Input configuration group name for slew-to-cue controls.}
33constexpr const char* inputConfigGroup = "inputConfigGroup";
34
35//! \vreRoleParam{slewToCueBinding,string,"slew-to-cue",slewToCueControl,Input binding name for activating slew-to-cue functionality.}
36constexpr const char* slewToCueBinding = "slewToCueBinding";
37
38//! \vreRoleParam{updateDeltaAngle,double,1.0,slewToCueControl,Minimum angle change in degrees required to trigger a slew-to-cue update.}
39constexpr const char* updateDeltaAngle = "updateDeltaAngle";
40
41//! \vreRoleParam{updateRate,double,0.2,slewToCueControl,Maximum rate in seconds for sending slew-to-cue updates to the weapon system.}
42constexpr const char* updateRate = "updateRate";
43
44//! \vreRoleParam{weaponSystemToSlew,string,"weapon",slewToCueControl,Name of the weapon system component to control for slew-to-cue operations.}
45constexpr const char* weaponSystemToSlew = "weaponSystemToSlew";
46
47//! @}
48} // namespace SlewToCueControlConfig
49
50//! \brief Type identifier for DtSlewToCueControl component
51constexpr const char* DtSlewToCueControlType = "DtSlewToCueControl";
52
53//! \brief Component that enables slew-to-cue functionality for weapon systems
54//!
55//! DtSlewToCueControl provides the ability to send slew-to-cue commands to a specified
56//! weapon system, directing it to orient toward the player's current view direction.
57//! It requires a DtWeaponPoseUpdater component to obtain the current weapon position
58//! and orientation data. The component supports rate-limited updates and angle thresholds
59//! to optimize network traffic when sending cue commands.
61{
62public:
63 //! \brief Constructor for DtSlewToCueControl
64 //!
65 //! Initializes the component with default settings for slew control
67
68 //! \brief Virtual destructor for DtSlewToCueControl
69 virtual ~DtSlewToCueControl() override;
70
71 //! \brief Initializes the slew-to-cue control component
72 //! \param player Pointer to the player station this component belongs to
73 //! \param config Configuration table containing slew control settings
74 //! \return True if initialization succeeded, false otherwise
75 //!
76 //! Reads configuration settings for the weapon system to slew, update rate,
77 //! update delta angle, and sets up input bindings for activation
78 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
79 //! \brief Performs post-initialization after all components are initialized
80 //! \return True if post-initialization succeeded, false otherwise
81 //!
82 //! Verifies the presence of weaponLocation and weaponOrientation attributes
83 //! and sets up the attribute change callback for orientation updates
84 virtual bool postInitialize() override;
85
86 //! \brief Called every frame to update the slew control state
87 //! \param dt Delta time since the last frame in seconds
88 //!
89 //! When slewing is active, manages update timing and sends slew-to-cue
90 //! messages based on the configured update rate and angle thresholds
91 virtual void tick(double dt) override;
92 //! \brief Shuts down the slew-to-cue control component
93 //!
94 //! Removes attribute change callbacks, deactivates slewing if active,
95 //! and performs base class shutdown operations
96 virtual void shutdown() override;
97
98 //! \brief Returns the type identifier for this component
99 //! \return The type string for DtSlewToCueControl
100 virtual const char* type() const override;
101
102 //! \brief Input handler for activating/deactivating slew-to-cue
103 //! \param val Input value (1.0 for activation, 0.0 for deactivation)
104 //!
105 //! Activates slew-to-cue when input is pressed and deactivates it when released,
106 //! sending appropriate messages to the weapon system
107 virtual void activateSlewToCue(double val);
108
109protected:
110 //! \brief Callback for weapon orientation attribute changes
111 //! \param ori New orientation value
112 //!
113 //! Determines if the orientation change exceeds the configured delta angle
114 //! threshold and sets the update needed flag accordingly
115 virtual void weaponOrientationAttributeUpdated(DtTaitBryan ori);
116
117 //! \brief Input logic for handling slew control input bindings
119
120 //! \brief Name of the weapon system to send slew commands to
122
123 //! \brief Flag indicating if slewing is currently active
125
126 //! \brief Flag indicating if an update needs to be sent
128
129 //! \brief Minimum time between slew updates in seconds
131
132 //! \brief Timer tracking time until next possible update
134
135 //! \brief Minimum angle change in degrees to trigger an update
137
138 //! \brief Last sent forward vector for angle change comparison
140};
141
142} // 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 DtPlayerStation & player()
Gets the player station.
DtPlayerComponent()
Constructor.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
double myUpdateDeltaAngle
Minimum angle change in degrees to trigger an update.
Definition slewToCueControl.h:136
bool mySlewingActive
Flag indicating if slewing is currently active.
Definition slewToCueControl.h:124
virtual ~DtSlewToCueControl() override
Virtual destructor for DtSlewToCueControl.
bool myUpdateNeeded
Flag indicating if an update needs to be sent.
Definition slewToCueControl.h:127
virtual const char * type() const override
Returns the type identifier for this component.
DtInputLogic myInputLogic
Input logic for handling slew control input bindings.
Definition slewToCueControl.h:118
DtVector32 myLastSentVector
Last sent forward vector for angle change comparison.
Definition slewToCueControl.h:139
virtual void activateSlewToCue(double val)
Input handler for activating/deactivating slew-to-cue.
DtSlewToCueControl()
Constructor for DtSlewToCueControl.
double myUpdateRate
Minimum time between slew updates in seconds.
Definition slewToCueControl.h:130
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the slew-to-cue control component.
double myUpdateTimer
Timer tracking time until next possible update.
Definition slewToCueControl.h:133
virtual void tick(double dt) override
Called every frame to update the slew control state.
std::string myWeaponSystemToSlew
Name of the weapon system to send slew commands to.
Definition slewToCueControl.h:121
virtual void weaponOrientationAttributeUpdated(DtTaitBryan ori)
Callback for weapon orientation attribute changes.
virtual bool postInitialize() override
Performs post-initialization after all components are initialized.
virtual void shutdown() override
Shuts down the slew-to-cue control component.
constexpr const char * updateRate
Definition slewToCueControl.h:42
constexpr const char * updateDeltaAngle
Definition slewToCueControl.h:39
constexpr const char * inputConfigGroup
Definition slewToCueControl.h:33
constexpr const char * slewToCueBinding
Definition slewToCueControl.h:36
constexpr const char * weaponSystemToSlew
Definition slewToCueControl.h:45
constexpr const char * inputConfigFile
Definition slewToCueControl.h:30
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Defines the DtInputLogic class for handling input in VR-Engage.
Definition slewToCueControl.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtSlewToCueControlType
Type identifier for DtSlewToCueControl component.
Definition slewToCueControl.h:51
Defines the DtPlayerComponent base class for VR-Engage role components.