VR-Engage  2.2
Loading...
Searching...
No Matches
objectProximitySensor.h
Go to the documentation of this file.
1/*******************************************************************************
2** Copyright (c) 2025 MAK Technologies
3** All rights reserved.
4*******************************************************************************/
5
6//! \file objectProximitySensor.h
7//! \ingroup vreVrfmodel
8//! \brief Proximity sensor for detecting objects within a specified range
9//!
10//! This file defines the DtObjectProximitySensor class which extends the base
11//! proximity sensor to detect specific objects within a configurable detection range.
12//! It provides functionality to monitor and report on objects that enter and exit
13//! the sensor's detection area.
14
15#pragma once
16
17#include "vreVrfmodel/export.h"
19
20#include <vrfmodel/simpleProximitySensor.h>
21#include <vrfutil/rwSensorContactInfo.h>
22
23//! \brief Sensor type enumeration value for proximity sensors
24//!
25//! This value is used to identify proximity sensors when requesting sensor updates
26//! in the front-end systems.
27static const DtSensorTypeEnum DtProximitySensorType = static_cast<DtSensorTypeEnum>(50);
28
29//! \brief Type identifier string for object proximity sensor components
30static const char* DtObjectProximitySensorType = "object-proximity-sensor";
31
32namespace makVre
33{
34class DtObjectProximitySensorMonitor;
35
36//! \brief Component that detects objects within a specified distance range
37//!
38//! DtObjectProximitySensor extends the base proximity sensor to detect
39//! specific objects that come within a configurable detection range.
40//! It provides notifications when objects enter or exit the sensor's range,
41//! and maintains a list of currently detected objects. The component also
42//! supports integration with front-end visualization systems and provides
43//! Lua bindings for scripting access.
44class VREVRFMODEL_DLL DtObjectProximitySensor : public DtVreSimComponent<DtSimpleProximitySensor>
45{
46private:
47 //! \brief Default constructor (not implemented)
48 //!
49 //! Default constructor is private and not implemented to prevent
50 //! creation of instances without proper initialization.
52
53 //! \brief Copy constructor (not implemented)
54 //!
55 //! Copy constructor is private and not implemented to prevent
56 //! copy construction.
58
59 //! \brief Assignment operator (not implemented)
60 //! \return Reference to this object
61 //!
62 //! Assignment operator is private and not implemented to prevent assignment.
64
65public:
66 //! \brief Constructor
67 //! \param name The name of this component
68 //! \param owner The local object that owns this component
69 //! \param simManager The simulation services manager
70 //! \param desc Optional component descriptor with configuration parameters
71 //! \param parentRegistry Optional parent registry for reader/writer functionality
72 //!
73 //! Creates a new object proximity sensor component with the specified parameters.
74 DtObjectProximitySensor(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
75 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
76
77 //! \brief Virtual destructor
78 //!
79 //! Cleans up resources used by the object proximity sensor component,
80 //! including the sensor monitor.
81 virtual ~DtObjectProximitySensor() override;
82
83 //! \brief Gets the type identifier for this component
84 //! \return String identifying the component type (DtObjectProximitySensorType)
85 //!
86 //! Implements the DtSimComponent::type() method to return the
87 //! type identifier for this component.
88 virtual const char* type() const override;
89
90 //! \brief Initializes the component
91 //! \return True if initialization is successful, false otherwise
92 //!
93 //! Performs component initialization, setting up the sensor monitor
94 //! and configuring detection parameters based on the component descriptor.
95 virtual bool init() override;
96
97 //! \brief Updates the sensor state each simulation frame
98 //!
99 //! Processes sensor detection logic each frame, but only if the simulation
100 //! is not paused. Detects objects that have entered or exited the sensor's
101 //! range and updates the sensor monitor accordingly.
102 virtual void tick() override;
103
104 //! \brief Disables the sensor component
105 //!
106 //! Overridden to clear out the target list and update the monitor when the
107 //! sensor is disabled, ensuring the sensor contact list is properly cleared
108 //! in the front-end visualization.
109 virtual void disable() override;
110
111 //! \brief Sets the enabled state of the sensor component
112 //! \param yesNo True to enable the sensor, false to disable it
113 //!
114 //! Overridden to properly handle the sensor's enabled state, ensuring that
115 //! the target list and monitor are updated appropriately when the state changes.
116 virtual void setIsEnabled(bool yesNo) override;
117
118 //! \brief Factory method to create a new instance of this component
119 //! \param name The name for the new component
120 //! \param owner The local object that will own this component
121 //! \param simManager The simulation services manager
122 //! \param desc Optional component descriptor
123 //! \param parentRegistry Optional parent registry for reader/writer functionality
124 //! \return Pointer to the newly created component
125 //!
126 //! Static factory method used by the component creation system to instantiate
127 //! new instances of this component type.
128 static DtSimComponent* creator(const DtString& name, DtLocalObject* owner, DtSimulationServices* simManager,
129 DtComponentDescriptor* desc = 0, DtReaderWriterRegistry* parentRegistry = 0);
130
131protected:
132 //! \brief Creates and initializes the sensor monitor
133 //! \return True if monitor creation and initialization succeeds, false otherwise
134 //!
135 //! Creates a DtObjectProximitySensorMonitor instance and initializes it,
136 //! establishing the connection between the sensor and the front-end
137 //! visualization system.
139
140 //! \brief Processes detected objects in the sensor's range
141 //! \return True if the status of any detected objects changed, false otherwise
142 //!
143 //! Performs detection checks for objects within the sensor's range, updating
144 //! the list of detected objects and notifying the sensor monitor of any changes.
145 virtual bool processObjects();
146
147 //! \brief Processes dynamic terrain objects for detection
148 //! \param contactNames Set of UUIDs for contact objects being tracked
149 //! \param searchFor String pattern to search for in dynamic terrain objects
150 //! \param sendAsType Entity type to use when reporting detections
151 //! \return True if any dynamic terrain objects were detected, false otherwise
152 //!
153 //! Searches for dynamic terrain objects matching the specified pattern and
154 //! adds them to the sensor's detection list when found within range.
156 std::set<DtUUID>& contactNames, std::string searchFor, DtEntityType sendAsType);
157
158protected:
159 //! \brief Pointer to the sensor monitor
160 //!
161 //! The monitor object that handles communication between the sensor and
162 //! the front-end visualization system. Maintains the list of detected
163 //! objects and their properties for display.
165};
166
167} // namespace makVre
virtual const char * type() const override
Gets the type identifier for this component.
virtual ~DtObjectProximitySensor() override
Virtual destructor.
virtual bool init() override
Initializes the component.
virtual bool processDynamicTerrainObjects(std::set< DtUUID > &contactNames, std::string searchFor, DtEntityType sendAsType)
Processes dynamic terrain objects for detection.
DtObjectProximitySensor()
Default constructor (not implemented)
virtual bool processObjects()
Processes detected objects in the sensor's range.
virtual void setIsEnabled(bool yesNo) override
Sets the enabled state of the sensor component.
DtObjectProximitySensor(const DtString &name, DtLocalObject *owner, DtSimulationServices *simManager, DtComponentDescriptor *desc=0, DtReaderWriterRegistry *parentRegistry=0)
Constructor.
virtual void tick() override
Updates the sensor state each simulation frame.
const DtObjectProximitySensor & operator=(const DtObjectProximitySensor &orig)
Assignment operator (not implemented)
virtual bool createAndInitSensorMonitor()
Creates and initializes the sensor monitor.
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 void disable() override
Disables the sensor component.
DtObjectProximitySensorMonitor * myMonitor
Pointer to the sensor monitor.
Definition objectProximitySensor.h:164
DtObjectProximitySensor(const DtObjectProximitySensor &orig)
Copy constructor (not implemented)
Monitor for managing proximity sensor contact information.
Definition objectProximitySensorMonitor.h:37
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
static const char * DtObjectProximitySensorType
Type identifier string for object proximity sensor components.
Definition objectProximitySensor.h:30
static const DtSensorTypeEnum DtProximitySensorType
Sensor type enumeration value for proximity sensors.
Definition objectProximitySensor.h:27
Base template class for VR-Engage simulation components.