VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
searchLightStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2025 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
10 #include "legionDataStore/writeStateInstance.h"
11 #include "vrfutil/uuid.h"
12 
13 #include <vlutil/vlString.h>
14 
15 namespace makVrf
16 {
19  {
22  : myLightType(0)
23  , myIntensity(0.0f)
24  , myRange(0.0f)
25  , myConeAngle(0.0f)
26  , myColor(0)
27  , myPowerOn(false)
28  , myTrackingMode(0)
29  , mySearchId()
35  {};
36 
40  {
41  myLightType = orig.myLightType;
42  myIntensity = orig.myIntensity;
43  myRange = orig.myRange;
44  myConeAngle = orig.myConeAngle;
45  myColor = orig.myColor;
46 
47  myPowerOn = orig.myPowerOn;
49  mySearchId = orig.mySearchId;
54 
56  }
57 
62  {
63  myLightType = orig.myLightType;
64  myIntensity = orig.myIntensity;
65  myRange = orig.myRange;
66  myConeAngle = orig.myConeAngle;
67  myColor = orig.myColor;
68 
69  myPowerOn = orig.myPowerOn;
71  mySearchId = orig.mySearchId;
76 
78 
79  return *this;
80  }
81 
83  DEFINE_ACCESSOR_MUTATOR(unsigned, lightType, LightType)
84  DEFINE_ACCESSOR_MUTATOR(unsigned, color, Color)
85  DEFINE_ACCESSOR_MUTATOR(double, intensity, Intensity)
86  DEFINE_ACCESSOR_MUTATOR(double, range, Range)
87  DEFINE_ACCESSOR_MUTATOR(double, coneAngle, ConeAngle)
88 
90  DEFINE_ACCESSOR_MUTATOR(bool, powerOn, PowerOn)
91  DEFINE_ACCESSOR_MUTATOR(unsigned, trackingMode, TrackingMode)
92  DEFINE_ACCESSOR_MUTATOR(DtString, searchId, SearchId)
93  DEFINE_ACCESSOR_MUTATOR(DtTaitBryan, relativeOrientation, RelativeOrientation)
94  DEFINE_ACCESSOR_MUTATOR(DtVector, targetedLocation, TargetedLocation)
95  DEFINE_ACCESSOR_MUTATOR(DtVector, targetedRelativeLocation, TargetedRelativeLocation)
96  DEFINE_ACCESSOR_MUTATOR(DtUUID, targetedEntity, TargetedEntity)
97 
99  DEFINE_ACCESSOR_MUTATOR(DtVector, relativeLocation, RelativeLocation)
100 
101  protected:
102 
105  unsigned myLightType;
107  unsigned myColor;
109  double myIntensity;
111  double myRange;
113  double myConeAngle;
114 
117  bool myPowerOn;
119  unsigned myTrackingMode;
121  DtString mySearchId;
130 
134  };
135 
141  {
142  public:
144 
145 
148  : DtFrameStateInterface(sd)
149  { }
150 
155  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned, color, Color)
157  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, intensity, Intensity)
159  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, range, Range)
161  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(double, coneAngle, ConeAngle)
162 
163 
164  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(bool, powerOn, PowerOn)
167  UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(unsigned, trackingMode, TrackingMode)
169  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtString, searchId, SearchId)
171  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtTaitBryan, relativeOrientation, RelativeOrientation)
173  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, targetedLocation, TargetedLocation)
175  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, targetedRelativeLocation, TargetedRelativeLocation)
177  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtUUID, targetedEntity, TargetedEntity)
178 
179 
180  UNDEFINED_RETURNREF_ACCESSOR(DtUUID, host)
183  UNDEFINED_RETURNREF_ACCESSOR(DtEntityIdentifier, entityId)
185  UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(DtVector, relativeLocation, RelativeLocation)
186  };
187 
191  {
192  public:
197  virtual ~DtSearchLightStateComponentNextFrame() override;
198 
201  const DtSearchLightStateComponentData& frameState() const { return myData; };
203 
205 
209  virtual const unsigned lightType() const override;
210  virtual void setLightType(const unsigned&) override;
212 
216  virtual const unsigned color() const override;
217  virtual void setColor(const unsigned&) override;
219 
223  virtual const double intensity() const override;
224  virtual void setIntensity(const double&) override;
226 
230  virtual const double range() const override;
231  virtual void setRange(const double&) override;
233 
237  virtual const double coneAngle() const override;
238  virtual void setConeAngle(const double&) override;
240 
242 
246  virtual const bool powerOn() const override;
247  virtual void setPowerOn(const bool&) override;
249 
253  virtual const unsigned trackingMode() const override;
254  virtual void setTrackingMode(const unsigned&) override;
256 
260  virtual const DtString& searchId() const override;
261  virtual void setSearchId(const DtString&) override;
263 
267  virtual const DtTaitBryan& relativeOrientation() const override;
268  virtual void setRelativeOrientation(const DtTaitBryan&) override;
270 
274  virtual const DtVector& targetedLocation() const override;
275  virtual void setTargetedLocation(const DtVector&) override;
277 
281  virtual const DtVector& targetedRelativeLocation() const override;
282  virtual void setTargetedRelativeLocation(const DtVector&) override;
284 
288  virtual const DtUUID& targetedEntity() const override;
289  virtual void setTargetedEntity(const DtUUID&) override;
291 
293 
295  virtual const DtUUID& host() const override;
296 
298  virtual const DtEntityIdentifier& entityId() const override;
299 
303  virtual const DtVector& relativeLocation() const override;
304  virtual void setRelativeLocation(const DtVector&) override;
306 
308  virtual void makeWritable() override {};
309 
311  virtual void makeReadOnly() override {};
312 
313  protected:
315  mutable DtSearchLightStateComponentData myData;
316  };
317 
320  {
321  public:
326  virtual ~DtSearchLightStateComponentCurrentFrame() override;
327 
329  const DtSearchLightStateComponentData& frameState() const { return myData; };
330 
333  virtual const unsigned lightType() const override;
335  virtual const unsigned color() const override;
337  virtual const double intensity() const override;
339  virtual const double range() const override;
341  virtual const double coneAngle() const override;
342 
345  virtual const bool powerOn() const override;
347  virtual const unsigned trackingMode() const override;
349  virtual const DtString& searchId() const override;
351  virtual const DtTaitBryan& relativeOrientation() const override;
353  virtual const DtVector& targetedLocation() const override;
355  virtual const DtVector& targetedRelativeLocation() const override;
357  virtual const DtUUID& targetedEntity() const override;
358 
361  virtual const DtUUID& host() const override;
363  virtual const DtEntityIdentifier& entityId() const override;
365  virtual const DtVector& relativeLocation() const override;
366 
367  friend class DtSearchLightStateImplementation;
370  void advanceFrame(const DtSearchLightStateComponentData& data) { myData = data; };
371 
372  protected:
375  };
376 
381  {
382  public:
386 
388  bool isDoubleBuffered() { return true; };
390  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
392  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; }
394  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; }
395 
397  virtual void updateDataStorage() override
398  {
399  if (myNextFrameState.isWritable())
400  {
401  myCurrentFrameState.advanceFrame(myNextFrameState.frameState());
402  }
403 
404  myCurrentFrameState.emitComponentUpdated();
405  }
406 
409  virtual void updateStateData(DtStateData* sd) override
410  {
411  myCurrentFrameState.updateStateData(sd);
412  myNextFrameState.updateStateData(sd);
413  }
414 
416  virtual void aboutToBeDeleted() override
417  {
419  myCurrentFrameState.aboutToBeDeleted();
420  myNextFrameState.aboutToBeDeleted();
421  }
422 
423  protected:
428  };
429 
432 }
UUID is a unique ID wrapper class.
Definition: uuid.h:59
DtUUID myTargetedEntity
UUID of the entity currently targeted by this search light.
Definition: searchLightStateComponent.h:129
DtStateComponentCreator< DtSearchLightStateComponentImplementation > DtSearchLightStateComponentCreator
Factory creator type for DtSearchLightStateComponentImplementation; register with REGISTER_STATE_COMP...
Definition: searchLightStateComponent.h:431
double myRange
Maximum effective range of the search-light beam (meters).
Definition: searchLightStateComponent.h:111
DtString mySearchId
Application-defined string identifier for this search-light entry.
Definition: searchLightStateComponent.h:121
bool isDoubleBuffered()
Definition: searchLightStateComponent.h:388
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
DtSearchLightStateComponentNextFrame myNextFrameState
The next-frame (writable) state instance.
Definition: searchLightStateComponent.h:427
const DtSearchLightStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: searchLightStateComponent.h:201
Contains the DtUUID class declaration.
virtual void aboutToBeDeleted() override
Notifies both frame states that this component is about to be removed.
Definition: searchLightStateComponent.h:416
unsigned myLightType
Search Light accessor/mutators:
Definition: searchLightStateComponent.h:105
DtVector myRelativeLocation
Embedded System members: Position of the search light relative to the host entity (meters...
Definition: searchLightStateComponent.h:133
unsigned myTrackingMode
Tracking mode controlling how the search light follows a target.
Definition: searchLightStateComponent.h:119
Write-access implementation of DtSearchLightStateComponent for the next simulation frame...
Definition: searchLightStateComponent.h:190
DtSearchLightStateComponentData & frameState()
Definition: searchLightStateComponent.h:202
#define UNDEFINED_RETURNREF_ACCESSOR(ReturnType, Member)
Defines a virtual const reference accessor that throws DtUnimplementedMethod, marking the method as r...
Definition: doubleBufferedDataStorage.h:60
DtSearchLightStateComponentData(const DtSearchLightStateComponentData &orig)
Copy constructor.
Definition: searchLightStateComponent.h:39
const DtSearchLightStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: searchLightStateComponent.h:329
virtual const DtFrameStateInterface * currentFrameState() const override
Definition: searchLightStateComponent.h:390
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
#define DEFINE_STATE_COMPONENT_TYPE(CreatedComponent)
Macro to define all required static and virtual state component type methods. Place in the public sec...
Definition: stateComponent.h:272
DtVector myTargetedLocation
World-space location that the search light is pointing at (meters, geocentric).
Definition: searchLightStateComponent.h:125
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
LightType
Definition: DtLight.h:31
#define UNDEFINED_RETURNVALUE_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual by-value accessor and an undefined virtual setter, both throwing DtUnimp...
Definition: doubleBufferedDataStorage.h:103
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
virtual DtFrameStateInterface * nextFrameState() override
Definition: searchLightStateComponent.h:392
DtSearchLightStateComponentData & operator=(const DtSearchLightStateComponentData &orig)
Assignment operator.
Definition: searchLightStateComponent.h:61
Abstract interface representing the search-light state for an entity. Provides accessors and mutators...
Definition: searchLightStateComponent.h:140
Concrete double-buffered state component implementation for search-light data. Owns both a current-fr...
Definition: searchLightStateComponent.h:380
double myConeAngle
Half-angle of the search-light cone (radians).
Definition: searchLightStateComponent.h:113
virtual void updateStateData(DtStateData *sd) override
Propagates the new state data pointer to both the current- and next-frame states. ...
Definition: searchLightStateComponent.h:409
#define UNDEFINED_RETURNREF_ACCESSOR_MUTATOR(Type, Member, Set)
Defines an undefined virtual const-reference accessor and an undefined virtual setter, both throwing DtUnimplementedMethod and requiring overrides in a derived class.
Definition: doubleBufferedDataStorage.h:112
#define DEFINE_ACCESSOR_MUTATOR(ReturnType, Accessor, Mutator)
Defines a const reference accessor and an inline setter for a member variable.
Definition: doubleBufferedDataStorage.h:37
virtual void makeWritable() override
Override to make component writable.
Definition: searchLightStateComponent.h:308
bool myPowerOn
Aimable System members: Boolean indicating whether or not the system is powered on.
Definition: searchLightStateComponent.h:117
#define DT_DLL_vrfStateData
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfStateDataDefines.h:29
Read-only access implementation of DtSearchLightStateComponent for the current simulation frame...
Definition: searchLightStateComponent.h:319
DtSearchLightStateComponentData()
Default constructor. Initializes all light properties and aim state to their off/zero defaults...
Definition: searchLightStateComponent.h:21
Cached frame data for the search-light state component.
Definition: searchLightStateComponent.h:18
DtVector myTargetedRelativeLocation
Body-relative location relative to the targeted entity that the search light is pointing at (meters)...
Definition: searchLightStateComponent.h:127
double myIntensity
Luminous intensity of the search-light beam.
Definition: searchLightStateComponent.h:109
virtual void updateDataStorage() override
Copies next-frame state into the current frame and emits a component-updated signal.
Definition: searchLightStateComponent.h:397
Contains the DtStateComponent class declaration.
virtual const DtFrameStateInterface * nextFrameState() const override
Definition: searchLightStateComponent.h:394
DtTaitBryan myRelativeOrientation
Orientation of the search light relative to the host entity body frame (Tait-Bryan angles)...
Definition: searchLightStateComponent.h:123
DtSearchLightStateComponentCurrentFrame myCurrentFrameState
The current-frame (read-only) state instance.
Definition: searchLightStateComponent.h:425
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
unsigned myColor
Packed RGBA color of the search-light beam.
Definition: searchLightStateComponent.h:107

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)