VR-Engage  2.2
Loading...
Searching...
No Matches
deployableObjectsSimLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2024 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//\file deployableObjectsLogic.h
7//\brief DtDeployableObjectsLogic;
8// Manage deployment and retrieval of drone and deployable launcher
9// and remote view inset drone and remote sensor entities.
10
11#pragma once
12
14
19
20#include <vrvCore/DtUniqueID.h>
21
22#include <matrix/vlVector.h>
23#include <vlpi/appearance.h>
24
25#include <vector>
26#include "matrix/vlVector.inl" // for DtVector64::DtVector64, DtVector64::operator=
27#include "vlpi/entityIdentifier.h" // for DtEntityIdentifier
28#include "vlpi/entityIdentifier.inl" // for DtEntityIdentifier::DtEntityIdentifier, DtEntityIdentifier::operator=
29#include "xstring" // for string, basic_string
30
31namespace makVre
32{
33
35{
36//! \ingroup RoleConfigParams
37//! \defgroup DeployableObjectsSimLogicRoleParams Deployable Objects Simulation Logic Role Parameters
38//! \roleInherits{EntityControlLogicRoleParams}
39//! Configuration Options for deployable objects simulation logic role including drones, launchers, and remote viewing.
40//! @{
41
42//! \vreRoleParam{droneBatteryWarnings,table,{},deployableObjectsSimLogic,Configuration table for drone battery warning thresholds and messages.}
43constexpr const char* droneBatteryWarnings = "droneBatteryWarnings";
44
45//! \vreRoleParam{droneOverlaySections,vector<string>,{},deployableObjectsSimLogic,Vector of overlay section names to display when using a drone sensor view.}
46constexpr const char* droneOverlaySections = "droneOverlaySections";
47
48//! \vreRoleParam{droneSensorModes,vector<string>|table,{},deployableObjectsSimLogic,Available sensor modes for drone cameras or nested configuration for sensor mode mappings.}
49constexpr const char* droneSensorModes = "droneSensorModes";
50
51//! \vreRoleParam{droneStatusUpdateDisplayTime,double,2.0,deployableObjectsSimLogic,Duration in seconds to display drone status update notifications.}
52constexpr const char* droneStatusUpdateDisplayTime = "droneStatusUpdateDisplayTime";
53
54//! \vreRoleParam{lockTargetHoldTime,double,varies,deployableObjectsSimLogic,Time in seconds to maintain target lock for weapon systems.}
55constexpr const char* lockTargetHoldTime = "lockTargetHoldTime";
56
57//! \vreRoleParamRequired{maxDGain,double,deployableObjectsSimLogic,1.0,Maximum derivative gain value for PID control systems.}
58constexpr const char* maxDGain = "maxDGain";
59
60//! \vreRoleParamRequired{maxFGain,double,deployableObjectsSimLogic,1.0,Maximum feedforward gain value for control systems.}
61constexpr const char* maxFGain = "maxFGain";
62
63//! \vreRoleParamRequired{maxIGain,double,deployableObjectsSimLogic,1.0,Maximum integral gain value for PID control systems.}
64constexpr const char* maxIGain = "maxIGain";
65
66//! \vreRoleParamRequired{maxPGain,double,deployableObjectsSimLogic,1.0,Maximum proportional gain value for PID control systems.}
67constexpr const char* maxPGain = "maxPGain";
68
69//! \vreRoleParam{remoteViewer,table,{},deployableObjectsSimLogic,Configuration table for remote viewer including channel name\, sensor mode\, zoom level\, and viewport settings.}
70constexpr const char* remoteViewer = "remoteViewer";
71
72//! \vreRoleParam{targetLockFadeRate,double,varies,deployableObjectsSimLogic,Rate at which target lock weight fades over time.}
73constexpr const char* targetLockFadeRate = "targetLockFadeRate";
74
75//! \vreRoleParam{thirdPersonOnUseDrone,bool,true,deployableObjectsSimLogic,Whether to switch to third-person view when using a drone.}
76constexpr const char* thirdPersonOnUseDrone = "thirdPersonOnUseDrone";
77
78//! \vreRoleParam{timeOnTargetForLock,double,varies,deployableObjectsSimLogic,Time in seconds required on target to achieve weapon lock.}
79constexpr const char* timeOnTargetForLock = "timeOnTargetForLock";
80
81//! \vreRoleParam{roleHasDeployables,bool,true,deployableObjectsSimLogic,Whether this role has deployable objects (if not, this could be a missile launcher role, for example.}
82constexpr const char* roleHasDeployables = "roleHasDeployables";
83
84//! \vreRoleParam{lookAtDroneOnUse,bool,true,deployableObjectsSimLogic,Whether the ownship should look at the drone when it is used.}
85constexpr const char* lookAtDroneOnUse = "lookAtDroneOnUse";
86
87//! @}
88} // namespace DeployableObjectsSimLogicConfig
89
90} // namespace makVre
91
92
93namespace makVrv
94{
95class DtChannel;
96class DtChannelManager;
97} // namespace makVrv
98
99
100namespace makVre
101{
102// class DtHumanEventProcessor;
103// class DtHumanJoystickControl;
107
108//! \brief Type identifier for DtDeployableObjectsSimLogic component
109constexpr const char* DtDeployableObjectsSimLogicType = "DtDeployableObjectsSimLogic";
110
112{
113public:
116
117 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
118 virtual bool postInitialize() override;
119
120 virtual void tick(double dt) override;
121 virtual void shutdown() override;
122
123 //! \brief Returns the component type identifier
124 //! \return The component type string
125 virtual const char* type() const override;
126
127 virtual void fireMissile(const std::string& rangeId = "");
128
129 virtual void toggleMissileLauncher();
130 virtual void useLauncher(const DtEntityIdentifier& id);
131 virtual void useDrone(const DtEntityIdentifier& id = DtEntityIdentifier::nullId(), const std::string& marking = "");
132 virtual void exitLauncher();
133 virtual void stopUsingDrone();
134
135 // If using a drone, this will set its "AutopilotMode" extended data.
136 virtual void setDroneAutopilotMode(const std::string& mode);
137
138 // Toggle the drone's autopilot mode between manual and task-based movement.
140
141 virtual void setIndirectFireCoordinate(const std::string& coordinate);
142 virtual void clearIndirectTarget();
143
144 virtual void deployEmbeddedEntity(const std::string& embeddedEntityName);
145 virtual void recoverEmbeddedEntity(const std::string& embeddedEntityName);
146
147 virtual void toggleRemoteViewViewport(double val);
148 virtual void setRemoteViewZoomLevel(double val);
149 virtual std::string scopeChannelName() const;
150
151 virtual bool operatingDrone();
152 virtual void setFocusOnEntity(bool val);
153 virtual void toggleFocusOnEntity();
154 virtual void setForwardControls(bool val);
155 virtual void toggleForwardControls();
156 virtual void landDrone();
157 virtual void returnToHome();
158 virtual void toggleDroneChannelVisibility(bool visible);
159
160 virtual void firstStageTrigger(double val);
161
162 // Toggle current "attackMode" extended state data, representing
163 // current attack mode of the launcher, top attack ("top-attack") or direct attack ("direct-attack").
164 virtual void toggleMissileAttackMode(double val);
165
166 virtual void sendJoystickCommand(const DtEntityIdentifier& id,
167 const std::string& functionGroup,
168 const std::string& function,
169 double val,
170 bool repeat = false);
171
172 virtual void onDamageStateChanged(DtDamageState val);
173
174 virtual DtEntityIdentifier launcherId();
175
176 // Open/close remote view inset for sensor gimbal on given entity
177 virtual void openRemoteSensorView(const DtEntityIdentifier& viewEntity);
178 virtual void closeRemoteSensorView();
179
181 {
185
186 bool operator==(const DeployableObject& other) const
187 {
188 return myState == other.myState && myInUse == other.myInUse && myDestroyed == other.myDestroyed;
189 }
190 };
191
192 // Map of deployable object label ("spark", "javelin", for example) to current state of the deployed object.
193 using DeployableObjectStateMap = std::map<std::string, DeployableObject>;
194
195protected:
196 // If incoming message is for entering the menu state, set myShowOverlays to false.
197 // This will hide overlays while we're in the menu state.
199
200 // If incoming message is for exiting the menu state, set showOverlays to true.
201 // This show overlays while in the running state.
203
204 bool scopeExists(DtEntityIdentifier& ownshipId, std::string& channelName);
205
206 bool isAirborne() const;
207 bool hasLauncher() const;
208 bool isAimingLauncher() const;
209
216
219
220 virtual void checkForDroneBatteryWarning(float amount);
221
223 virtual void processMissileRemoved();
224 virtual void processMissileRealized(const DtEntityIdentifier& munitionId);
225 virtual void updateLauncherFocus(double dt);
226 virtual void enableLauncher(LauncherType launcherType = SHOULDER_MOUNTED);
227 virtual void disableLauncher();
228
229 virtual void updateSensor();
230
231 virtual void nextSensor(double val);
232
234
235 // Blank the drone display, send a drone destroyed notification, disable drone controls
236 virtual void setDroneDestroyed();
237
238 virtual DtEntityIdentifier missileId();
239
240 virtual void onSceneClicked(makVrv::DtUniqueID, const DtVector& location, double altAboveGround);
241
252
253 DtEntityIdentifier myRemoteViewEntityId;
254
257 std::vector<ChannelViewport> myViewportConfigurations;
263
264 std::string myTargetName;
265 std::string myMissileName;
267
268 DtEntityIdentifier myMissileId;
269 DtEntityIdentifier myMissileToAttachTo;
270
275
276 float myPGain;
277 float myIGain;
278 float myDGain;
279 float myFGain;
280
282
283 // Map of battery amount to warning already displayed.
284 std::map<int, bool> myDroneBatteryWarnings;
285
286 // Duration in seconds for drone status update notifications.
288
289 // Target seeker
290 std::map<makVrv::DtElementID, double> myPotentialTargetsWeightMap;
294
296
298
300 std::map<enum SensorViews, std::string> mySensorModes;
301
303};
304} // namespace makVre
Event processor for entity creation and placement.
Definition createNewEntityEventProcessor.h:36
Definition deployableObjectsInputLogic.h:20
virtual makVre::DtVreMessageResult handleFireInteraction(makVre::DtVreMessage *msg)
virtual const char * type() const override
Returns the component type identifier.
virtual makVre::DtVreMessageResult handleResourceUpdate(makVre::DtVreMessage *msg)
double myTargetLockWeight
Definition deployableObjectsSimLogic.h:292
std::string myMissileName
Definition deployableObjectsSimLogic.h:265
virtual makVre::DtVreMessageResult handleSimState(makVre::DtVreMessage *msg) override
Message handlers.
virtual bool postInitialize() override
Performs post-initialization setup.
float myMaxIGain
Definition deployableObjectsSimLogic.h:272
DtEntityIdentifier myRemoteViewEntityId
Definition deployableObjectsSimLogic.h:253
DtDeployableObjectsInputLogic * myInputLogic
Definition deployableObjectsSimLogic.h:295
DtEntityIdentifier myMissileToAttachTo
Definition deployableObjectsSimLogic.h:269
virtual void processMissileRealized(const DtEntityIdentifier &munitionId)
virtual void checkForDroneBatteryWarning(float amount)
virtual void enableLauncher(LauncherType launcherType=SHOULDER_MOUNTED)
virtual std::string scopeChannelName() const
virtual void fireMissile(const std::string &rangeId="")
DtCreateNewEntityEventProcessor * myEventProcessor
Definition deployableObjectsSimLogic.h:297
float myMaxFGain
Definition deployableObjectsSimLogic.h:274
double myDroneStatusUpdateDisplayTime
Definition deployableObjectsSimLogic.h:287
std::map< int, bool > myDroneBatteryWarnings
Definition deployableObjectsSimLogic.h:284
ObserverAttachMode myCachedAttachMode
Definition deployableObjectsSimLogic.h:262
float myPGain
Definition deployableObjectsSimLogic.h:276
virtual void setDroneAutopilotMode(const std::string &mode)
virtual ~DtDeployableObjectsSimLogic() override
virtual void onDamageStateChanged(DtDamageState val)
virtual void useLauncher(const DtEntityIdentifier &id)
float myIGain
Definition deployableObjectsSimLogic.h:277
virtual void deployEmbeddedEntity(const std::string &embeddedEntityName)
virtual makVre::DtVreMessageResult handleExitPlayerState(makVre::DtVreMessage *msg)
std::vector< ChannelViewport > myViewportConfigurations
Definition deployableObjectsSimLogic.h:257
std::map< enum SensorViews, std::string > mySensorModes
Definition deployableObjectsSimLogic.h:300
virtual DtEntityIdentifier launcherId()
DtVector myPreviousRemoteViewTarget
Definition deployableObjectsSimLogic.h:266
virtual void setForwardControls(bool val)
bool myShowPidMenu
Definition deployableObjectsSimLogic.h:281
float myDGain
Definition deployableObjectsSimLogic.h:278
virtual makVre::DtVreMessageResult handleEntityRealized(makVre::DtVreMessage *msg)
virtual void updateOwnshipFromSimState(SimulationStateMessage *msg)
virtual void toggleRemoteViewViewport(double val)
SensorViews myLastSensorViewMode
Definition deployableObjectsSimLogic.h:299
virtual void firstStageTrigger(double val)
std::string myTargetName
Definition deployableObjectsSimLogic.h:264
virtual void recoverEmbeddedEntity(const std::string &embeddedEntityName)
virtual void setFocusOnEntity(bool val)
bool scopeExists(DtEntityIdentifier &ownshipId, std::string &channelName)
float myMaxDGain
Definition deployableObjectsSimLogic.h:273
virtual makVre::DtVreMessageResult handleEntityRemoved(makVre::DtVreMessage *msg)
bool myRemoteViewAttachToMunition
Definition deployableObjectsSimLogic.h:258
std::string myRemoteViewSensorMode
Definition deployableObjectsSimLogic.h:256
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the entity control logic.
bool myThirdPersonOnUseDrone
Definition deployableObjectsSimLogic.h:261
std::map< makVrv::DtElementID, double > myPotentialTargetsWeightMap
Definition deployableObjectsSimLogic.h:290
virtual void onSceneClicked(makVrv::DtUniqueID, const DtVector &location, double altAboveGround)
virtual void sendJoystickCommand(const DtEntityIdentifier &id, const std::string &functionGroup, const std::string &function, double val, bool repeat=false)
virtual makVre::DtVreMessageResult handleEnterPlayerState(makVre::DtVreMessage *msg)
float myFGain
Definition deployableObjectsSimLogic.h:279
virtual void shutdown() override
Shuts down the entity control logic.
double myRemoteViewResetTime
Definition deployableObjectsSimLogic.h:259
virtual void toggleDroneChannelVisibility(bool visible)
float myMaxPGain
Definition deployableObjectsSimLogic.h:271
virtual void nextSensor(double val)
DtEntityIdentifier myMissileId
Definition deployableObjectsSimLogic.h:268
std::map< std::string, DeployableObject > DeployableObjectStateMap
Definition deployableObjectsSimLogic.h:193
virtual void setIndirectFireCoordinate(const std::string &coordinate)
double myRemoteViewZoomLevel
Definition deployableObjectsSimLogic.h:260
virtual void updateEmbeddedEntityFromSimState(SimulationStateMessage *msg)
virtual void tick(double dt) override
Updates the entity control logic each frame.
virtual DtEntityIdentifier missileId()
virtual void updateLauncherFocus(double dt)
bool myLookAtDroneOnUse
Definition deployableObjectsSimLogic.h:302
virtual void openRemoteSensorView(const DtEntityIdentifier &viewEntity)
std::string myRemoteViewChannelName
Definition deployableObjectsSimLogic.h:255
double myTargetWeightFadeRate
Definition deployableObjectsSimLogic.h:293
virtual makVre::DtVreMessageResult handleMenuActionMessage(makVre::DtVreMessage *msg)
virtual void useDrone(const DtEntityIdentifier &id=DtEntityIdentifier::nullId(), const std::string &marking="")
virtual void toggleMissileAttackMode(double val)
virtual void setRemoteViewZoomLevel(double val)
double myTargetHoldWeight
Definition deployableObjectsSimLogic.h:291
DtEntityControlLogic()
Constructor.
Table-based access to Lua state for configuration data.
Definition initializer.h:38
virtual DtPlayerStation & player()
Gets the player station.
Class for managing the user interface for engaged roles.
Definition playerStation.h:51
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Definition entityRealized.h:31
Definition simulationState.h:34
Defines the logic for controlling entities in VR-Engage.
constexpr const char * maxPGain
Definition deployableObjectsSimLogic.h:67
constexpr const char * lockTargetHoldTime
Definition deployableObjectsSimLogic.h:55
constexpr const char * timeOnTargetForLock
Definition deployableObjectsSimLogic.h:79
constexpr const char * droneOverlaySections
Definition deployableObjectsSimLogic.h:46
constexpr const char * roleHasDeployables
\vreRoleParam{roleHasDeployables,bool,true,deployableObjectsSimLogic,Whether this role has deployable...
Definition deployableObjectsSimLogic.h:82
constexpr const char * droneBatteryWarnings
Definition deployableObjectsSimLogic.h:43
constexpr const char * thirdPersonOnUseDrone
Definition deployableObjectsSimLogic.h:76
constexpr const char * droneSensorModes
Definition deployableObjectsSimLogic.h:49
constexpr const char * maxFGain
Definition deployableObjectsSimLogic.h:61
constexpr const char * targetLockFadeRate
Definition deployableObjectsSimLogic.h:73
constexpr const char * droneStatusUpdateDisplayTime
Definition deployableObjectsSimLogic.h:52
constexpr const char * lookAtDroneOnUse
Definition deployableObjectsSimLogic.h:85
constexpr const char * maxIGain
Definition deployableObjectsSimLogic.h:64
constexpr const char * maxDGain
Definition deployableObjectsSimLogic.h:58
constexpr const char * remoteViewer
Definition deployableObjectsSimLogic.h:70
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition deployableObjectsSimLogic.h:35
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
ObserverAttachMode
Enumeration of camera/observer attachment offsets.
Definition stateDefines.h:44
constexpr const char * DtDeployableObjectsSimLogicType
Type identifier for DtDeployableObjectsSimLogic component.
Definition deployableObjectsSimLogic.h:109
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
SensorViews
Enumeration of available sensor view modes.
Definition stateDefines.h:18
LauncherType
Enumeration of launcher equipment types.
Definition stateDefines.h:76
@ SHOULDER_MOUNTED
Launcher designed to be fired from the shoulder.
Definition stateDefines.h:78
Definition appLauncherComponent.h:28
Common enumeration definitions used throughout the VREngage system.
Definition deployableObjectsSimLogic.h:243
bool showDroneHUDElements
Definition deployableObjectsSimLogic.h:249
bool showHumanOverlay
Definition deployableObjectsSimLogic.h:250
int left
Definition deployableObjectsSimLogic.h:244
bool showDroneFrame
Definition deployableObjectsSimLogic.h:248
int right
Definition deployableObjectsSimLogic.h:245
int bottom
Definition deployableObjectsSimLogic.h:246
int top
Definition deployableObjectsSimLogic.h:247
Definition deployableObjectsSimLogic.h:181
bool myDestroyed
Definition deployableObjectsSimLogic.h:184
SimulationStateMessage::EmbeddedEntity myState
Definition deployableObjectsSimLogic.h:182
bool operator==(const DeployableObject &other) const
Definition deployableObjectsSimLogic.h:186
bool myInUse
Definition deployableObjectsSimLogic.h:183
Definition simulationState.h:49
Defines the base class for all VREngage messages.