VR-Engage  2.3
Loading...
Searching...
No Matches
gunnerRangeSimLogic.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file gunnerRangeSimLogic.h
7//! \brief Component that computes range to target for gunner and weapon systems
8//! \ingroup vreCommonComponents
9
10#pragma once
11
13
15
16#include "vreUtil/initializer.h"
17
18namespace makVre
19{
20class DtVreMessage;
21
23{
24//! \ingroup RoleConfigParams
25//! \defgroup GunnerRangeSimLogicRoleParams Gunner Range Sim Logic Role Parameters
26//! \roleInherits{PlayerComponentRoleParams}
27//! Configuration Options for gunner range simulation logic role.
28//! @{
29
30//! \vreRoleParam{channelName,string,"Channel 1",gunnerRangeSimLogic,Name of the display channel used for range computation ray casting.}
31constexpr const char* channelName = "channelName";
32
33//! \vreRoleParam{updateInterval,double,1.0,gunnerRangeSimLogic,Time interval in seconds between range computation updates.}
34constexpr const char* updateInterval = "updateInterval";
35
36//! \vreRoleParam{windowName,string,"Window 1",gunnerRangeSimLogic,Name of the display window used for range computation ray casting.}
37constexpr const char* windowName = "windowName";
38
39//! @}
40} // namespace GunnerRangeSimLogicConfig
41
42class DtVreMessage;
43class DtGunnerJoystickControl;
44class DtGunnerEventProcessor;
45
46//! \brief Type identifier for DtGunnerRangeSimLogic component
47constexpr const char* DtGunnerRangeSimLogicType = "DtGunnerRangeSimLogic";
48
49//! \brief Component that periodically computes the range to target for gunner systems
50//!
51//! DtGunnerRangeSimLogic periodically computes the range from the entity to the first
52//! object or terrain polygon it intersects. It casts a ray from the observer through
53//! the center point of the screen and sets the player attribute "range" with the
54//! distance in meters. The computation occurs at a configurable time interval.
56{
57public:
58 //! \brief Constructor for DtGunnerRangeSimLogic
59 //!
60 //! Initializes component with default values for update interval (1 second),
61 //! window name ("Window 1"), and channel name ("Channel 1")
63
64 //! \brief Destructor for DtGunnerRangeSimLogic
65 virtual ~DtGunnerRangeSimLogic() override;
66
67 //! \brief Initializes the gunner range simulation component
68 //! \param player Pointer to the player station this component belongs to
69 //! \param config Configuration table containing range simulation settings
70 //! \return True if initialization succeeded, false otherwise
71 //!
72 //! Configures the component with the following parameters from the configuration table:
73 //! - updateInterval: Time in seconds between range updates (default: 1 second)
74 //! - windowName: Name of the window to use for ray casting (default: "Window 1")
75 //! - channelName: Name of the channel to use for ray casting (default: "Channel 1")
76 //!
77 //! Also initializes the "range" player attribute to 0.0
78 virtual bool initialize(DtPlayerStation* player, DtInitTable& config) override;
79
80 //! \brief Called every frame to update the range simulation
81 //! \param dt Delta time since the last frame in seconds
82 //!
83 //! Calls updateRange() each tick to calculate the current range to target
84 virtual void tick(double dt) override;
85
86 //! \brief Shuts down the gunner range simulation component
87 //!
88 //! Performs any necessary cleanup operations
89 virtual void shutdown() override;
90
91 //! \brief Returns the type identifier for this component
92 //! \return The type string for DtGunnerRangeSimLogic
93 virtual const char* type() const override;
94
95protected:
96 //! \brief Computes the range to target at specified time intervals
97 //!
98 //! Called each tick to determine if it's time to update the range value.
99 //! When triggered, casts a ray from the observer through the center of the screen
100 //! and computes the distance to the first intersection. Sets the player attribute
101 //! "range" with the calculated distance in meters.
102 virtual void updateRange();
103
104 //! \brief Simulation time at which the next range update should be computed
106
107 //! \brief Time interval in seconds between range updates
108 //!
109 //! Defaults to 1.0 second if not specified in configuration
111
112 //! \brief Name of the window to use for ray casting
113 //!
114 //! Defaults to "Window 1" if not specified in configuration
115 std::string myWindowName;
116
117 //! \brief Name of the channel to use for ray casting
118 //!
119 //! Defaults to "Channel 1" if not specified in configuration
120 std::string myChannelName;
121
122 //! \brief Attribute handle storing the calculated range to the current aim point.
123 //! \vreAttrKey{range}
125
126 //! \brief Attribute handle storing the ownship's current geocentric position.
127 //! \vreAttrKey{ownship.position}
129
130 //! \brief Attribute handle storing the entity identifier of the vehicle the gunner is attached to.
131 //! \vreAttrKey{attachedTo}
133};
134} // namespace makVre
Type-specific handle class for attributes.
Definition attributeHandle.h:229
virtual bool initialize(DtPlayerStation *player, DtInitTable &config) override
Initializes the gunner range simulation component.
virtual ~DtGunnerRangeSimLogic() override
Destructor for DtGunnerRangeSimLogic.
virtual void shutdown() override
Shuts down the gunner range simulation component.
DtAttributeHandleType< double > myRangeAttr
Attribute handle storing the calculated range to the current aim point.
Definition gunnerRangeSimLogic.h:124
std::string myWindowName
Name of the window to use for ray casting.
Definition gunnerRangeSimLogic.h:115
double myTimeToUpdate
Simulation time at which the next range update should be computed.
Definition gunnerRangeSimLogic.h:105
std::string myChannelName
Name of the channel to use for ray casting.
Definition gunnerRangeSimLogic.h:120
virtual const char * type() const override
Returns the type identifier for this component.
DtAttributeHandleType< DtVector > myPositionAttr
Attribute handle storing the ownship's current geocentric position.
Definition gunnerRangeSimLogic.h:128
virtual void updateRange()
Computes the range to target at specified time intervals.
virtual void tick(double dt) override
Called every frame to update the range simulation.
DtAttributeHandleType< DtEntityIdentifier > myAttachedToAttr
Attribute handle storing the entity identifier of the vehicle the gunner is attached to.
Definition gunnerRangeSimLogic.h:132
double myUpdateInterval
Time interval in seconds between range updates.
Definition gunnerRangeSimLogic.h:110
DtGunnerRangeSimLogic()
Constructor for DtGunnerRangeSimLogic.
Table-based access to Lua state for configuration data.
Definition initializer.h:38
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 * channelName
Definition gunnerRangeSimLogic.h:31
constexpr const char * updateInterval
Definition gunnerRangeSimLogic.h:34
constexpr const char * windowName
Definition gunnerRangeSimLogic.h:37
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.
Definition gunnerRangeSimLogic.h:23
!
Definition glsVreMessageUtil.h:50
constexpr const char * DtGunnerRangeSimLogicType
Type identifier for DtGunnerRangeSimLogic component.
Definition gunnerRangeSimLogic.h:47
Defines the DtPlayerComponent base class for VR-Engage role components.