VR-Engage  2.2
Loading...
Searching...
No Matches
humanJoystickCombatController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file humanJoystickCombatController.h
7//! \ingroup vreVrfmodel
8//! \brief Joystick controller for human combat capabilities
9//!
10//! This file defines the DtHumanJoystickCombatController class which enables joystick
11//! control of combat capabilities for human entities, including weapon aiming, firing, and
12//! other combat-related actions.
13
14#pragma once
15
16#include "vreVrfmodel/export.h"
17#include <vrfobjcore/controllerComponent.h>
18#include <vrfmodel/joystickControllerInterface.h>
19
20class DtString;
21class DtSimulationServices;
22class DtJoyDeviceControllerDescriptor;
23class DtJoyDevice;
24class DtHumanStateRepository;
25class DtBooleanOutputPort;
26class DtIntegerOutputPort;
27class DtAnalogOutputPort;
28class DtVectorOutputPort;
29class DtConstrainedAnalogOutputPort;
30
31namespace makVre
32{
33
34//! \brief Type identifier for the human joystick combat controller component
35const char DtHumanJoystickCombatControllerType[] = "human-joystick-combat-controller";
36
37//! \brief Controller for joystick-based combat control of human entities
38//!
39//! DtHumanJoystickCombatController enables joystick control of a human entity's
40//! combat capabilities. It manages weapon aiming, firing, and other combat-related
41//! actions through joystick inputs. This controller works alongside movement controllers
42//! to provide comprehensive control of human entities.
43//!
44//! Uses Descriptor Type: DtHumanJoystickCombatControllerDescriptor
45class VREVRFMODEL_DLL DtHumanJoystickCombatController : public DtControllerComponent,
46 public DtJoystickControllerInterface
47{
48public:
49 //! \brief Constructor
50 //! \param name The name of this component
51 //! \param owner The local object that owns this component
52 //! \param simManager The simulation services manager
53 //! \param desc Component descriptor with configuration parameters
54 //! \param parentRegistry Optional parent registry for reader/writer functionality
55 //!
56 //! Creates a new human joystick combat controller component with the specified parameters.
57 DtHumanJoystickCombatController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
58 DtComponentDescriptor* desc, DtReaderWriterRegistry* parentRegistry = 0);
59
60 //! \brief Virtual destructor
61 //!
62 //! Cleans up resources used by the human joystick combat controller component.
64
65 //! \brief Gets the type identifier for this component
66 //! \return String identifying the component type (DtHumanJoystickCombatControllerType)
67 //!
68 //! Implements the DtSimComponent::type() method to return the
69 //! type identifier for this component.
70 virtual const char* type() const override;
71
72 //! \brief Creates port groups for this component
73 //! \return True if port groups were created successfully, false otherwise
74 //!
75 //! Creates and initializes the output port groups used by this controller,
76 //! including groups for weapon aiming and ballistic gun control.
77 virtual bool createPortGroups() override;
78
79 //! \brief Creates input and output ports for this component
80 //! \return True if ports were created successfully, false otherwise
81 //!
82 //! Creates and initializes all input and output ports used by this controller
83 //! for combat-related functions, including ports for aiming, triggering, and
84 //! weapon state information.
85 virtual bool createPorts() override;
86
87 //! \brief Factory method to create a new instance of this component
88 //! \param name The name for the new component
89 //! \param owner The local object that will own this component
90 //! \param simManager The simulation services manager
91 //! \param desc Optional component descriptor
92 //! \param parentRegistry Optional parent registry for reader/writer functionality
93 //! \return Pointer to the newly created component
94 //!
95 //! Static factory method used by the component creation system to instantiate
96 //! new instances of this component type.
97 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
98 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
99
100private:
101 //! \brief Default constructor (not implemented)
102 //!
103 //! Default constructor is private and not implemented to prevent
104 //! creation of instances without proper initialization.
106
107 //! \brief Copy constructor (not implemented)
108 //!
109 //! Copy constructor is private and not implemented to prevent
110 //! copy construction.
112
113 //! \brief Assignment operator (not implemented)
114 //! \return Reference to this object
115 //!
116 //! Assignment operator is private and not implemented to prevent assignment.
118
119protected:
120 //! \brief Processes joystick input and updates output ports
121 //! \param functionGroup The function group identifier for the input
122 //! \param function The specific function identifier within the group
123 //! \param value The input value from the joystick
124 //! \param repeat Flag indicating if this is a repeated input
125 //!
126 //! Implements the DtJoystickControllerInterface method to process joystick
127 //! input and update the controller's output ports for combat functions.
129 const DtString& functionGroup, const DtString& function, double value, bool repeat) override;
130
131 //! \brief Handles joystick connection event
132 //!
133 //! Called when a joystick is connected to the system.
134 //! Activates joystick control mode for combat functions.
135 virtual void joystickConnected() override;
136
137 //! \brief Handles joystick disconnection event
138 //!
139 //! Called when a joystick is disconnected from the system.
140 //! Deactivates joystick control mode for combat functions.
141 virtual void joystickDisconnected() override;
142
143 //! \brief Updates the controller state each simulation frame
144 //!
145 //! Processes combat-related controls and updates the human entity's
146 //! weapon aiming and firing state based on current joystick inputs.
147 virtual void tick() override;
148
149
150protected:
151 //! \name Ports and Port Groups
152 //! @{
153
154
155 //! \brief Output port group for aiming weapon systems
156 //!
157 //! Contains all output ports related to weapon aiming control.
158 DtOutputPortGroup* myAimWeaponOutputPortGroup;
159
160 //! \brief Output port for enabling aiming at specific angles
161 //!
162 //! When true, allows aiming at specific elevation and azimuth angles.
163 DtBooleanOutputPort* myAimAtAnglePort;
164
165 //! \brief Output port for enabling azimuth aiming
166 //!
167 //! When true, allows aiming in azimuth (side-to-side) direction.
168 DtBooleanOutputPort* myAllowAzimuthAimingPort;
169
170 //! \brief Output port for azimuth aim angle
171 //!
172 //! Controls the azimuth angle for weapon aiming in radians.
173 DtAnalogOutputPort* myAimAzimuthOutputPort;
174
175 //! \brief Output port for elevation aim angle
176 //!
177 //! Controls the elevation angle for weapon aiming in radians.
178 DtAnalogOutputPort* myAimElevationOutputPort;
179
180 //! \brief Output port group for ballistic gun control
181 //!
182 //! Contains all output ports related to the control of ballistic guns.
183 DtOutputPortGroup* myBalGunControlPortGroup;
184
185 //! \brief Output port for weapon trigger state
186 //!
187 //! When true, indicates that the weapon trigger is pulled/activated.
188 DtBooleanOutputPort* myTriggerPort;
189
190 //! \brief Output port for ammunition quantity
191 //!
192 //! Indicates the quantity of ammunition to use for firing.
193 DtIntegerOutputPort* myQuantityOutputPort;
194
195 //! \brief Output port for loaded state
196 //!
197 //! When true, indicates that the weapon is loaded and ready to fire.
198 DtBooleanOutputPort* myLoadedPort;
199
200 //! \brief Output port for line-of-sight state
201 //!
202 //! Indicates whether a valid line-of-sight target exists.
203 DtIntegerOutputPort* myLosPort;
204
205 //! \brief Output port for primary joystick active state
206 //!
207 //! When true, indicates that primary joystick control is active.
208 DtBooleanOutputPort* myActiveJoystickPort;
209
210 //! \brief Output port for secondary joystick active state
211 //!
212 //! When true, indicates that secondary joystick control is active.
213 DtBooleanOutputPort* mySecondActiveJoystickPort;
214
215 //! \brief Pointer to the human state repository
216 //!
217 //! Access to the human entity's state information.
218 DtHumanStateRepository* myHumanStateRepository;
219
220 //! \brief Output port for elevation control
221 //!
222 //! Controls the elevation of the weapon system, with constraints on minimum and maximum values.
223 DtConstrainedAnalogOutputPort* myElevationPort;
224
225 //! \brief Flag indicating if the entity is currently aiming
226 //!
227 //! When true, the entity is actively aiming a weapon.
229
230 //! \brief Flag indicating if the trigger is currently activated
231 //!
232 //! When true, the weapon trigger is being pressed/activated.
234
235 //! \brief Rate of change for pitch (elevation) control
236 //!
237 //! Controls how quickly the weapon elevation changes in response to inputs.
239
240 //! \brief Current pitch (elevation) angle
241 //!
242 //! Stores the current pitch/elevation angle of the weapon in radians.
243 double myPitch;
244
245 //! \brief Current mouse-controlled pitch contribution
246 //!
247 //! Stores the component of pitch that is controlled by mouse input.
249
250 //! \brief Rate of change for yaw (azimuth) control
251 //!
252 //! Controls how quickly the weapon azimuth changes in response to inputs.
254
255 //! \brief Current yaw (azimuth) angle
256 //!
257 //! Stores the current yaw/azimuth angle of the weapon in radians.
258 double myYaw;
259
260 //! \brief Current mouse-controlled yaw contribution
261 //!
262 //! Stores the component of yaw that is controlled by mouse input.
264
265 //! \brief Current state of the weapon
266 //!
267 //! Stores the current operational state of the weapon system.
269
270 //! \brief Current weapon aim elevation
271 //!
272 //! Stores the current elevation angle being used for aiming the weapon.
274
275 //! \brief Current weapon aim azimuth
276 //!
277 //! Stores the current azimuth angle being used for aiming the weapon.
279};
280
281} // namespace makVre
bool myAiming
Flag indicating if the entity is currently aiming.
Definition humanJoystickCombatController.h:228
virtual void calcAndSetPortValues(const DtString &functionGroup, const DtString &function, double value, bool repeat) override
Processes joystick input and updates output ports.
DtIntegerOutputPort * myQuantityOutputPort
Output port for ammunition quantity.
Definition humanJoystickCombatController.h:193
DtOutputPortGroup * myAimWeaponOutputPortGroup
Output port group for aiming weapon systems.
Definition humanJoystickCombatController.h:158
double myCurrentAimAzimuth
Current weapon aim azimuth.
Definition humanJoystickCombatController.h:278
DtAnalogOutputPort * myAimElevationOutputPort
Output port for elevation aim angle.
Definition humanJoystickCombatController.h:178
double myMousePitch
Current mouse-controlled pitch contribution.
Definition humanJoystickCombatController.h:248
DtBooleanOutputPort * myActiveJoystickPort
Output port for primary joystick active state.
Definition humanJoystickCombatController.h:208
DtBooleanOutputPort * myLoadedPort
Output port for loaded state.
Definition humanJoystickCombatController.h:198
DtHumanJoystickCombatController()
Default constructor (not implemented)
DtHumanJoystickCombatController & operator=(const DtHumanJoystickCombatController &orig)
Assignment operator (not implemented)
double myPitch
Current pitch (elevation) angle.
Definition humanJoystickCombatController.h:243
virtual bool createPortGroups() override
Creates port groups for this component.
int myCurrentWeaponState
Current state of the weapon.
Definition humanJoystickCombatController.h:268
bool myTrigger
Flag indicating if the trigger is currently activated.
Definition humanJoystickCombatController.h:233
double myYawingRate
Rate of change for yaw (azimuth) control.
Definition humanJoystickCombatController.h:253
DtBooleanOutputPort * myAllowAzimuthAimingPort
Output port for enabling azimuth aiming.
Definition humanJoystickCombatController.h:168
DtOutputPortGroup * myBalGunControlPortGroup
Output port group for ballistic gun control.
Definition humanJoystickCombatController.h:183
DtIntegerOutputPort * myLosPort
Output port for line-of-sight state.
Definition humanJoystickCombatController.h:203
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Factory method to create a new instance of this component.
virtual const char * type() const override
Gets the type identifier for this component.
double myPitchingRate
Rate of change for pitch (elevation) control.
Definition humanJoystickCombatController.h:238
DtConstrainedAnalogOutputPort * myElevationPort
Output port for elevation control.
Definition humanJoystickCombatController.h:223
DtBooleanOutputPort * myAimAtAnglePort
Output port for enabling aiming at specific angles.
Definition humanJoystickCombatController.h:163
DtAnalogOutputPort * myAimAzimuthOutputPort
Output port for azimuth aim angle.
Definition humanJoystickCombatController.h:173
double myYaw
Current yaw (azimuth) angle.
Definition humanJoystickCombatController.h:258
DtHumanJoystickCombatController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual bool createPorts() override
Creates input and output ports for this component.
DtBooleanOutputPort * myTriggerPort
Output port for weapon trigger state.
Definition humanJoystickCombatController.h:188
virtual void tick() override
Updates the controller state each simulation frame.
virtual void joystickDisconnected() override
Handles joystick disconnection event.
virtual void joystickConnected() override
Handles joystick connection event.
virtual ~DtHumanJoystickCombatController() override
Virtual destructor.
double myCurrentAimElevation
Current weapon aim elevation.
Definition humanJoystickCombatController.h:273
double myMouseYaw
Current mouse-controlled yaw contribution.
Definition humanJoystickCombatController.h:263
DtHumanStateRepository * myHumanStateRepository
Pointer to the human state repository.
Definition humanJoystickCombatController.h:218
DtBooleanOutputPort * mySecondActiveJoystickPort
Output port for secondary joystick active state.
Definition humanJoystickCombatController.h:213
DtHumanJoystickCombatController(const DtHumanJoystickCombatController &orig)
Copy constructor (not implemented)
Defines export macros for the vreVrfmodel library.
#define VREVRFMODEL_DLL
Definition export.h:22
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
const char DtHumanJoystickCombatControllerType[]
Type identifier for the human joystick combat controller component.
Definition humanJoystickCombatController.h:35