VR-Engage  2.2
Loading...
Searching...
No Matches
updateVisualsConnector.h
Go to the documentation of this file.
1/******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4******************************************************************************/
5
6//! \file updateVisualsConnector.h
7//! \brief Defines the DtUpdateVisualsConnector class for handling visual model updates
8//!
9//! Class DtUpdateVisualsConnector is an event connector that handles
10//! VisualsLoaded events. These are events indicating that the visual
11//! definition/mapping data associated with a simulation model set (SMS) has
12//! been loaded. In response to such events, it recreates the DtVrlinkElement
13//! objects (entities, aggregates, and tactical graphics), based on the updated
14//! visual model definition data. This happens any time the visual
15//! definition/mapping data associated with an SMS changes (i.e., when a different
16//! SMS with visual definition/mapping data gets loaded).
17
18#pragma once
19
20#include "export.h"
21
23
25
26namespace makVre
27{
28//! \brief Connector for handling visual model definition updates
29//!
30//! DtUpdateVisualsConnector responds to visual model definition changes by
31//! recreating and updating DtVrlinkElement objects to reflect the new visual
32//! definitions. It handles entities, aggregates, and tactical graphics,
33//! ensuring they use the latest visual model definitions from the current
34//! simulation model set (SMS).
36{
37public:
38 //! \brief Default constructor
39 //!
40 //! Initializes the connector with name "UpdateVisuals"
42
43 //! \brief Virtual destructor
44 virtual ~DtUpdateVisualsConnector() override;
45
46 //! \brief Installs the visual update connector with the application and connection
47 //! \param app Pointer to the player station application
48 //! \param connection Pointer to the protocol-specific VR-Link connection
49 //!
50 //! Registers message handlers for VisualModelDefinitionsLoadedMessage messages
51 virtual void install(DtPlayerStationApp* app, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection* connection) override;
52
53 //! \brief Performs periodic processing of entity reparenting
54 //!
55 //! Handles re-parenting of embarked entities that were discovered during SMS reload
56 //! by attempting to re-establish parent-child relationships over several ticks
57 virtual void tick() override;
58
59 //! \brief Shuts down the visual update connector
60 //!
61 //! Removes message handlers for visual model definition updates
62 virtual void shutdown() override;
63
64protected:
65 //! \brief Map of entities that need to be reparented
66 //!
67 //! Map of entity global designators to their parent entity global designators
68 //! Used to track entities that need to be reparented after SMS reload
69 std::map<DtGlobalObjectDesignator, DtGlobalObjectDesignator> myEntitiesToReparent;
70
71 //! \brief Counter for reparenting attempts
72 //!
73 //! Number of ticks remaining to attempt reparenting of entities
74 //! When this reaches zero, any remaining entities will have warning messages logged
76
77 //! \brief Handles visual model definition loaded messages
78 //! \param msg Pointer to the visual model definitions loaded message
79 //! \return Message result indicating how the message was handled
80 //!
81 //! Updates all visual DtVrlinkElements (entities, aggregates, tactical graphics)
82 //! with the latest visual model definitions/mappings. For each element, it disables
83 //! and re-enables the model sets, updates the element definition, and then
84 //! re-visualizes the element using the new definitions.
86
87 //! \brief Handles SMS load complete messages
88 //! \param msg Pointer to the SMS load complete message
89 //! \return Message result indicating how the message was handled
90 //!
91 //! Sets up the reparenting process after SMS reload by initializing the
92 //! myTicksToReparent counter and removing the handler since it's only needed once per reload
94};
95} // namespace makVre
Base class for all simulation event connectors in VREngage.
Definition simEventConnector.h:54
Top-level class representing the VR-Engage application.
Definition playerStationApp.h:163
virtual void install(DtPlayerStationApp *app, makVrv::DT_PROTOCOL_NAMESPACE::DtVrlinkConnection *connection) override
Installs the visual update connector with the application and connection.
virtual void shutdown() override
Shuts down the visual update connector.
std::map< DtGlobalObjectDesignator, DtGlobalObjectDesignator > myEntitiesToReparent
Map of entities that need to be reparented.
Definition updateVisualsConnector.h:69
virtual void tick() override
Performs periodic processing of entity reparenting.
virtual ~DtUpdateVisualsConnector() override
Virtual destructor.
DtUpdateVisualsConnector()
Default constructor.
int myTicksToReparent
Counter for reparenting attempts.
Definition updateVisualsConnector.h:75
virtual makVre::DtVreMessageResult handleVisualModelDefinitionsLoaded(makVre::DtVreMessage *msg)
Handles visual model definition loaded messages.
virtual makVre::DtVreMessageResult handleSmsLoadComplete(makVre::DtVreMessage *msg)
Handles SMS load complete messages.
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
Defines export macros and protocol namespace for vrePlayerStationConnector.
#define VRL_DLL
Empty definition for non-Windows platforms.
Definition export.h:52
Include export definitions for this library.
Definition glsVreMessageUtil.h:49
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base DtSimEventConnector class for VREngage simulation events.
Defines the base class for all VREngage messages.