VR-Engage  2.2
Loading...
Searching...
No Matches
vreTurretFocusController.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file vreTurretFocusController.h
7//! \ingroup vreVrfmodel
8//! \brief Controller for managing turret focus on specific targets
9//!
10//! This file defines the DtVreTurretFocusController class which extends
11//! the mounting controller to provide functionality for focusing a turret
12//! on specific targets. It handles the turret_focus scripted set and manages
13//! target tracking.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
18
20
21#include <vrfmodel/mountingController.h>
22#include <vrfmodel/scriptEnableController.h>
23
24#include <vrfutil/rwUUID.h>
25
26namespace makVre
27{
28//! \brief Type identifier for the turret focus controller component
29const char DtVreTurretFocusControllerType[] = "turret-focus-controller";
30
31//! \brief Controller for managing turret focus on specific targets
32//!
33//! DtVreTurretFocusController extends the mounting controller to provide
34//! functionality for focusing a turret on specific targets. It processes the
35//! turret_focus scripted task set and manages target tracking, allowing turrets
36//! to maintain focus on designated targets during movement and engagement.
37//! The controller receives target updates and ensures the turret remains
38//! pointed at the specified entity.
40{
41public:
42 //! \brief Constructor
43 //! \param name The name of this component
44 //! \param owner The local object that owns this component
45 //! \param simManager The simulation services manager
46 //! \param desc Component descriptor with configuration parameters
47 //! \param parentRegistry Optional parent registry for reader/writer functionality
48 //!
49 //! Creates a new turret focus controller component with the specified parameters.
50 DtVreTurretFocusController(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
51 DtComponentDescriptor* desc = NULL, DtReaderWriterRegistry* parentRegistry = 0);
52
53 //! \brief Virtual destructor
54 //!
55 //! Cleans up resources used by the turret focus controller component.
56 virtual ~DtVreTurretFocusController() override;
57
58 //! \brief Gets the type identifier for this component
59 //! \return String identifying the component type (DtVreTurretFocusControllerType)
60 //!
61 //! Implements the DtSimComponent::type() method to return the
62 //! type identifier for this component.
63 virtual const char* type() const override;
64
65 //! \brief Initializes the turret focus controller
66 //! \return True if initialization is successful, false otherwise
67 //!
68 //! Registers attribute provider functions and sets up message callbacks for
69 //! turret focus control. Called during component creation.
70 virtual bool init() override;
71
72 //! \brief Updates the turret focus each simulation frame
73 //!
74 //! Overridden to manage the turret's focus target point. Updates the mounting
75 //! controller with the current position of the targeted entity, ensuring the
76 //! turret remains pointed at the correct target during simulation.
77 virtual void tick() override;
78
79 //! \brief Static callback function for turret focus messages
80 //! \param msg The simulation message containing focus target information
81 //! \param usrData User data pointer, typically pointing to an instance of this class
82 //!
83 //! Static function registered as a callback to handle turret focus messages.
84 //! Forwards the message to the appropriate instance's processSetTurretFocus method.
85 static void setTurretFocusCallback(DtSimMessage* msg, void* usrData);
86
87 //! \brief Processes a turret focus message
88 //! \param msg The simulation message containing focus target information
89 //!
90 //! Extracts the target entity UUID from the message and updates the controller's
91 //! target focus accordingly. This sets the turret to focus on a specific entity.
92 virtual void processSetTurretFocus(DtSimMessage* msg);
93
94 //! \brief Factory method to create a new instance of this component
95 //! \param name The name for the new component
96 //! \param owner The local object that will own this component
97 //! \param simManager The simulation services manager
98 //! \param desc Optional component descriptor
99 //! \param parentRegistry Optional parent registry for reader/writer functionality
100 //! \return Pointer to the newly created component
101 //!
102 //! Static factory method used by the component creation system to instantiate
103 //! new instances of this component type.
104 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
105 DtComponentDescriptor* desc, DtReaderWriterRegistry* parentRegistry);
106
107private:
108 //! \brief Copy constructor (not implemented)
109 //!
110 //! Copy constructor is private and not implemented to prevent
111 //! copy construction.
113
114 //! \brief Assignment operator (not implemented)
115 //! \return Reference to this object
116 //!
117 //! Assignment operator is private and not implemented to prevent assignment.
119
120protected:
121 //! \brief UUID of the current target entity
122 //!
123 //! Stores the unique identifier of the entity that the turret
124 //! is currently focused on tracking.
126};
127} // namespace makVre
DtVreSimComponent(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Definition vreSimComponent.h:54
static void setTurretFocusCallback(DtSimMessage *msg, void *usrData)
Static callback function for turret focus messages.
virtual void tick() override
Updates the turret focus each simulation frame.
virtual bool init() override
Initializes the turret focus controller.
virtual void processSetTurretFocus(DtSimMessage *msg)
Processes a turret focus message.
DtVreTurretFocusController(const DtVreTurretFocusController &orig)
Copy constructor (not implemented)
DtVreTurretFocusController(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=NULL, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
DtVreTurretFocusController & operator=(const DtVreTurretFocusController &orig)
Assignment operator (not implemented)
virtual ~DtVreTurretFocusController() override
Virtual destructor.
static DtSimComponent * creator(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc, DtReaderWriterRegistry *parentRegistry)
Factory method to create a new instance of this component.
DtUUID myTargetSimObjectUUID
UUID of the current target entity.
Definition vreTurretFocusController.h:125
virtual const char * type() const override
Gets the type identifier for this component.
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 DtVreTurretFocusControllerType[]
Type identifier for the turret focus controller component.
Definition vreTurretFocusController.h:29
Base template class for VR-Engage simulation components.