VR-Engage  2.2
Loading...
Searching...
No Matches
bullseyeController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file bullseyeController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for managing bullseye reference point targets
9//!
10//! This file defines the DtBullseyeController class which handles player selection
11//! of bullseye targets in VR Engage stations and manages the bullseye reference point
12//! used for tactical position reporting.
13
14#pragma once
15#include "vreVrfmodel/export.h"
19#include <vrfobjcore/controllerComponent.h>
20
21//! \brief Special controller for managing bullseye targets in VR Engage
22//!
23//! This controller handles player selection of bullseye targets in VR Engage stations.
24//! It is responsible for saving the selected bullseye entity ID and sending BullseyeStatus
25//! messages to other simulation components. The controller connects to GUI definitions in
26//! pilot.lua for the "Select Bullseye" functionality.
27
28namespace makVre
29{
30//! \brief Type identifier for the bullseye controller component
31const char DtBullseyeControllerType[] = "bullseye-controller";
32
33//! \brief Controller component for managing bullseye reference points
34//!
35//! The DtBullseyeController provides functionality for selecting, tracking, and
36//! reporting bullseye reference points in tactical simulations. It handles user
37//! selection of bullseye targets and communicates position updates to other
38//! simulation components.
39class VREVRFMODEL_DLL DtBullseyeController : public DtVreSimComponent<DtControllerComponent>
40{
41private:
42 //! \brief Default constructor (not implemented)
43 //!
44 //! Default constructor is private and not implemented to prevent
45 //! creation of instances without proper initialization.
47
48 //! \brief Copy constructor (not implemented)
49 //!
50 //! Copy constructor is private and not implemented to prevent
51 //! copy construction.
53
54 //! \brief Assignment operator (not implemented)
55 //! \return Reference to this object
56 //!
57 //! Assignment operator is private and not implemented to prevent assignment.
59
60public:
61 //! \brief Constructor
62 //! \param name The name of this component
63 //! \param owner The local object that owns this component
64 //! \param simManager The simulation services manager
65 //! \param desc Optional component descriptor
66 //! \param parentRegistry Optional parent registry for reader/writer functionality
67 //!
68 //! Creates a new bullseye controller component with the specified parameters.
69 DtBullseyeController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
70 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
71
72 //! \brief Virtual destructor
73 //!
74 //! Cleans up resources used by the bullseye controller component.
75 virtual ~DtBullseyeController() override;
76
77 //! \brief Gets the type identifier for this component
78 //! \return String identifying the component type (DtBullseyeControllerType)
79 //!
80 //! Implements the DtSimComponent::type() method to return the
81 //! type identifier for this component.
82 virtual const char* type() const override;
83
84 //! \brief Initializes the component
85 //! \return True if initialization is successful, false otherwise
86 //!
87 //! Registers message handlers for bullseye-related messages, particularly
88 //! vrfSetBullseyeIdMessage which is sent by pilotSimLogic.
89 virtual bool init() override;
90
91 //! \brief Factory method to create a new instance of this component
92 //! \param name The name for the new component
93 //! \param owner The local object that will own this component
94 //! \param simManager The simulation services manager
95 //! \param desc Optional component descriptor
96 //! \param parentRegistry Optional parent registry for reader/writer functionality
97 //! \return Pointer to the newly created component
98 //!
99 //! Static factory method used by the component creation system to instantiate
100 //! new instances of this component type.
101 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
102 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
103
104 //! \brief Creates the process state repository for this component
105 //! \return Pointer to the newly created bullseye process state repository
106 //!
107 //! Creates the myProcessState data member and adds it to the process state
108 //! repository manager. Passes the name and type specified in the component
109 //! descriptor (if they exist) to the DtVrfProcessStateRepository::createRepository
110 //! factory method. If name and/or type are not specified, uses the appropriate
111 //! default strings defined in procSRTypes.h.
113
114 //! \brief Updates bullseye status when the target entity's location changes
115 //! \param obj Pointer to the local object that has changed location
116 //!
117 //! Called when the bullseye target entity's location is updated.
118 //! Updates the stored bullseye world position and sends status updates.
119 void processSetLocationComplete(const DtLocalObject* obj);
120
121 //! \brief Handles simulation object addition events
122 //! \param obj Pointer to the newly added local object
123 //!
124 //! Handles the case where a VRF scenario reloads. VR Engage will reset the
125 //! bullseye target according to the saved bullseyeID when the target object
126 //! is added to the simulation.
127 void processSimObjectAdded(const DtLocalObject* obj);
128
129 //! \brief Handles simulation object removal events
130 //! \param obj Pointer to the local object being removed
131 //!
132 //! Removes all callbacks related to the bullseye object when it's
133 //! about to be removed from the simulation.
134 void processSimObjectToBeRemoved(const DtLocalObject* obj);
135
136protected:
137 //! \brief Handles bullseye target selection messages
138 //! \param msg Pointer to the SetBullseyeIdMessage
139 //! \return Message processing result
140 //!
141 //! Processes SetBullseyeIdMessage sent from the user interface and updates
142 //! the current bullseye object based on the selected entity ID.
144
145 //! \brief Handles bullseye status request messages
146 //! \param msg Pointer to the BullseyeStatusRequestMessage
147 //! \return Message processing result
148 //!
149 //! Processes BullseyeStatusRequestMessage sent from GUI components and
150 //! responds with a BullseyeStatusUpdateMessage containing current bullseye information.
152
153 //! \brief Sends bullseye status update to interested components
154 //!
155 //! Sends a BullseyeStatusUpdateMessage to the controlling entity with
156 //! the selected bullseye's geocentric world location. Used to update
157 //! HUD displays and other tactical information systems.
159
160 //! \brief Sets a new bullseye target
161 //! \param obj Reference to the simulation object to use as the bullseye target
162 //!
163 //! Updates the current bullseye object, stores its location, and sends
164 //! a bullseye status update to all interested components.
165 virtual void setNewBullseye(DtSimObjectReference obj);
166
167 //! \brief Performs initialization before the first tick
168 //!
169 //! Sets up initial state and connections needed before the first
170 //! simulation tick is processed.
171 virtual void preFirstTickInit() override;
172 //! \brief Updates the controller state each simulation frame
173 //!
174 //! Performs periodic updates and processing during each simulation cycle.
175 virtual void tick() override;
176
177 //! \brief Gets the default process state repository type
178 //! \return String identifying the default PSR type (DtBullseyePSRType)
179 //!
180 //! Returns the default process state repository type for this component.
181 const char* defaultPSRType() const;
182
183protected:
184 //! \brief Flag indicating if the bullseye reference is currently valid
186
187 //! \brief Last known geocentric position of the bullseye target
189
190 //! \brief Pointer to the bullseye process state repository
192};
193} // namespace makVre
Bullseye process state repository for VREngage.
void processSimObjectAdded(const DtLocalObject *obj)
Handles simulation object addition events.
DtBullseyeController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
bool myBullseyeIsValid
Flag indicating if the bullseye reference is currently valid.
Definition bullseyeController.h:185
virtual bool init() override
Initializes the component.
void processSetLocationComplete(const DtLocalObject *obj)
Updates bullseye status when the target entity's location changes.
virtual DtVreMessageResult handleSetBullseyeId(DtVreMessage *msg)
Handles bullseye target selection messages.
virtual void sendBullseyeStatusUpdate()
Sends bullseye status update to interested components.
DtBullseyePSR * myProcessState
Pointer to the bullseye process state repository.
Definition bullseyeController.h:191
const DtBullseyeController & operator=(const DtBullseyeController &orig)
Assignment operator (not implemented)
DtBullseyeController(const DtBullseyeController &orig)
Copy constructor (not implemented)
virtual void setNewBullseye(DtSimObjectReference obj)
Sets a new bullseye target.
DtBullseyeController()
Default constructor (not implemented)
virtual const char * type() const override
Gets the type identifier for this component.
virtual void preFirstTickInit() override
Performs initialization before the first tick.
virtual void tick() override
Updates the controller state each simulation frame.
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 ~DtBullseyeController() override
Virtual destructor.
const char * defaultPSRType() const
Gets the default process state repository type.
DtVector myLastBullseyeWorldPosition
Last known geocentric position of the bullseye target.
Definition bullseyeController.h:188
virtual DtVreMessageResult handleBullseyeStatusRequest(DtVreMessage *msg)
Handles bullseye status request messages.
virtual DtBullseyePSR * createPSR()
Creates the process state repository for this component.
void processSimObjectToBeRemoved(const DtLocalObject *obj)
Handles simulation object removal events.
Process state repository for the bullseye controller component.
Definition bullseyePSR.h:37
Abstract base class for all VREngage messages.
Definition vreMessage.h:50
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
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 DtBullseyeControllerType[]
Type identifier for the bullseye controller component.
Definition bullseyeController.h:31
DtVreMessageResult
Enumeration of possible message handling results.
Definition vreMessage.h:33
Defines the base class for all VREngage messages.
Base template class for VR-Engage simulation components.