VR-Engage  2.2
Loading...
Searching...
No Matches
artPartParamToStateAttrMap.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file artPartParamToStateAttrMap.h
7//! \brief Defines the DtArtPartParamToStateAttrMap component that maps articulated part parameters to state attributes.
8//!
9//! This component enables mapping of DIS articulated part parameter values to state attributes
10//! within the VR Engagement system. It processes simulation state messages to extract articulated
11//! part information and update corresponding state attributes based on configured mappings.
12
13#pragma once
14
16
18
19namespace makVre
20{
21
23{
24//! \ingroup RoleConfigParams
25//! \defgroup ArtPartParamToStateAttrMapRoleParams Art Part Param To State Attr Map Role Parameters
26//! \roleInherits{PlayerComponentRoleParams}
27//! Configuration Options for art part param to state attr map role.
28//! @{
29
30//! \vreRoleParam{artPartParameters,table,{},artPartParamToStateAttrMap,Table of articulated part parameter mappings defining which DIS art part types and parameter types map to which state attributes.}
31constexpr const char* artPartParameters = "artPartParameters";
32
33//! @}
34} // namespace ArtPartParamToStateAttrMapConfig
35
36//! \brief Type identifier for DtArtPartParamToStateAttrMap component
37constexpr const char* DtArtPartParamToStateAttrMapType = "DtArtPartParamToStateAttrMap";
38
39//! \brief Component for mapping DIS articulated part parameters to state attributes.
40//!
41//! The DtArtPartParamToStateAttrMap component enables a user to map DIS articulated part
42//! parameter values to state attributes. This allows the application to access and use
43//! articulation values (such as turret azimuth, gun elevation, etc.) from DIS simulation
44//! entities through the standard state attribute system.
45//!
46//! Example Lua configuration:
47//! \code
48//! ["artPartParamToStateAttrMap"] = {
49//! componentType = "DtArtPartParamToStateAttrMap";
50//! priority = 5;
51//! artPartParameters = {
52//! {artPartType = 4096, parameterType = 10, stateAttributeName = "primaryTurretAzimuth"};
53//! {artPartType = 4416, parameterType = 12, stateAttributeName = "primaryGunElevation"};
54//! };
55//! };
56//! \endcode
58{
59public:
60 //! \brief Constructor for DtArtPartParamToStateAttrMap
61 //!
62 //! Initializes the component with the name "DtArtPartParamToStateAttrMap".
64
65 //! \brief Virtual destructor for DtArtPartParamToStateAttrMap
67
68 //! \brief Initializes the component with configuration from Lua
69 //!
70 //! Processes the provided configuration to create mappings between articulated part types,
71 //! parameter types, and state attribute names. Also registers a handler for simulation state messages.
72 //!
73 //! \param player Pointer to the player station this component belongs to
74 //! \param config Configuration table containing initialization parameters, especially the artPartParameters table
75 //! \return True if initialization succeeds, false otherwise
77
78 //! \brief Updates the component state (empty implementation)
79 //!
80 //! This method is called each frame, but currently has no implementation for this component.
81 //!
82 //! \param dt Delta time in seconds since the last tick
83 virtual void tick(double dt) override;
84
85 //! \brief Returns the type identifier for this component
86 //! \return The type string for DtArtPartParamToStateAttrMap
87 virtual const char* type() const override;
88
89protected:
90 //! \brief Handles simulation state messages
91 //!
92 //! Processes simulation state messages to extract articulated part parameters and
93 //! updates corresponding state attributes based on the configured mappings.
94 //!
95 //! \param msg The simulation state message to process
96 //! \return HANDLED if the message was successfully processed
98
99 //! \brief Shuts down the component
100 //!
101 //! Removes the simulation state message handler.
102 virtual void shutdown() override;
103
104 //! \brief Structure defining mapping between an articulated part parameter and a state attribute
106 {
107 //! \brief DIS parameter type enumeration value
108 //!
109 //! Valid values include:
110 //! - 0: POSITION
111 //! - 1: POSITIONRATE
112 //! - 2: EXTENSION
113 //! - 3: EXTENSIONRATE
114 //! - 4: X
115 //! - 5: XRATE
116 //! - 6: Y
117 //! - 7: YRATE
118 //! - 8: Z
119 //! - 9: ZRATE
120 //! - 10: AZIMUTH
121 //! - 11: AZIMUTHRATE
122 //! - 12: ELEVATION
123 //! - 13: ELEVATIONRATE
124 //! - 14: ROTATION
125 //! - 15: ROTATIONRATE
126 int parameterType;
127
128 //! \brief Name of the state attribute to hold the parameter value
129 std::string stateAttributeName;
130 };
131
132 //! \brief Map of art part type to parameter/state attribute descriptor
133 //!
134 //! The map keys are DIS articulated part type enumeration values,
135 //! and the values are ArtPartParamStateAttrDescriptor structures.
136 std::map<int, ArtPartParamStateAttrDescriptor> myArtPartParameterMap;
137};
138} // namespace makVre
virtual void shutdown() override
Shuts down the component.
struct ArtPartParamStateAttrDescriptor { int parameterType; std::string stateAttributeName; } ArtPartParamStateAttrDescriptor
Structure defining mapping between an articulated part parameter and a state attribute.
Definition artPartParamToStateAttrMap.h:105
std::map< int, ArtPartParamStateAttrDescriptor > myArtPartParameterMap
Map of art part type to parameter/state attribute descriptor.
Definition artPartParamToStateAttrMap.h:136
DtArtPartParamToStateAttrMap()
Constructor for DtArtPartParamToStateAttrMap.
virtual void tick(double dt) override
Updates the component state (empty implementation)
virtual const char * type() const override
Returns the type identifier for this component.
virtual bool initialize(makVre::DtPlayerStation *player, makVre::DtInitTable &config) override
Initializes the component with configuration from Lua.
virtual makVre::DtVreMessageResult handleSimState(makVre::DtVreMessage *msg)
Handles simulation state messages.
virtual ~DtArtPartParamToStateAttrMap() override
Virtual destructor for DtArtPartParamToStateAttrMap.
Table-based access to Lua state for configuration data.
Definition initializer.h:38
Base class for all role components in VR-Engage.
Definition playerComponent.h:78
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
Defines the logic for controlling entities in VR-Engage.
constexpr const char * artPartParameters
Definition artPartParamToStateAttrMap.h:31
Defines export/import macros for the vreCommonComponents library.
#define VRECOMMONCOMPONENTS_DLL
DLL export/import macro for the vreCommonComponents library.
Definition export.h:28
Definition artPartParamToStateAttrMap.h:23
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
constexpr const char * DtArtPartParamToStateAttrMapType
Type identifier for DtArtPartParamToStateAttrMap component.
Definition artPartParamToStateAttrMap.h:37
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33