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