VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
articulatedPartStateComponent.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
6 #pragma once
7 
11 #include <vlpi/articulatedPartCollection.h>
12 
14 
15 namespace makVrf
16 {
17  class DtArticulatedPartStateRepository;
18 
22  {
24  : myArtPartListModified(false)
25  {
26  }
27 
29  void create()
30  {
31  myarticulatedPartManager = std::shared_ptr<DtArticulatedPartManager>(new DtArticulatedPartManager(nullptr, "articulated-parts"));
32  myartPartList = std::shared_ptr<DtArticulatedPartCollection>(new DtArticulatedPartCollection);
33  }
34 
38  : myarticulatedPartManager(orig.myarticulatedPartManager)
39  , myartPartList(orig.myartPartList)
40  , myArtPartListModified(orig.myArtPartListModified)
41  {
42  }
43 
48  {
49  myarticulatedPartManager = rhs.myarticulatedPartManager;
50  myartPartList = rhs.myartPartList;
51  myArtPartListModified = rhs.myArtPartListModified;
52 
53  return *this;
54  }
55 
57  bool initialized() const { return (myarticulatedPartManager.get() != 0); };
59  const DtArticulatedPartManager& articulatedPartManager() const { return *(myarticulatedPartManager.get()); };
61  DtArticulatedPartManager& articulatedPartManager(){ return *(myarticulatedPartManager.get()); };
62 
64  const DtArticulatedPartCollection& artPartList() const { return *(myartPartList.get()); };
66  DtArticulatedPartCollection& artPartList() { return *(myartPartList.get()); };
67 
70  void setArtPartListModified(bool b) { myArtPartListModified = b; };
72  bool artPartListModified() const { return myArtPartListModified; };
74  void clearArtPartListModified() { myArtPartListModified = false; };
75 
76  protected:
78  std::shared_ptr<DtArticulatedPartManager> myarticulatedPartManager;
80  std::shared_ptr<DtArticulatedPartCollection> myartPartList;
83  };
84 
86 
90  {
91  public:
93 
94 
97  : DtFrameStateInterface(storage)
98  {
99  }
100 
107  virtual DtArticulatedPart& attachPartToListIfMissing(DtArtPartType partType) { throw DtUnimplementedMethod("DtArticulatedPart& attachPartToListIfMissing(DtArtPartType partType) is not implemented for this class."); };
111  virtual DtArticulatedPartStateRepository* attachPart(DtArtPartType partType) { throw DtUnimplementedMethod("DtArticulatedPartStateRepository* attachPart(DtArtPartType partType) is not implemented for this class."); };
113  virtual bool artPartListModified() const { throw DtUnimplementedMethod("bool artPartsModified() is not implemented for this class."); };
117  virtual void addParameterType(int partType, int parameterType) { throw DtUnimplementedMethod("void addParameterType(int partType, int parameterType) is not implemented for this class."); };
120  virtual void detachPartIfAttached(DtArtPartType partType) { throw DtUnimplementedMethod("void detachPartIfAttached(DtArtPartType partType) is not implemented for this class."); };
123  virtual void detachPart(DtArtPartType partType) { throw DtUnimplementedMethod("void detachPart(DtArtPartType partType) is not implemented for this class."); };
124  };
125 
128  {
129  public:
133 
135  const DtArticulatedPartStateComponentData& frameState() const { return myData; };
137 
139  virtual const DtArticulatedPartManager& articulatedPartManager() const override;
141  virtual DtArticulatedPartManager& articulatedPartManager() override;
142 
144  virtual const DtArticulatedPartManager& articulatedParts() const override;
146  virtual DtArticulatedPartManager& articulatedParts() override;
147 
149  virtual const DtArticulatedPartCollection& artPartList() const override;
151  virtual DtArticulatedPartCollection& artPartList() override;
152 
155  void setCoordinateSystem(const Coordinate_System*);
156 
158  virtual void makeWritable() override {};
159 
161  virtual void makeReadOnly() override {};
162 
166  virtual DtArticulatedPart& attachPartToListIfMissing(DtArtPartType partType) override;
170  virtual DtArticulatedPartStateRepository* attachPart(DtArtPartType partType) override;
173  virtual void detachPartIfAttached(DtArtPartType partType) override;
176  virtual void detachPart(DtArtPartType partType) override;
177 
180  void setPublishOnLegionNetwork(bool b);
181 
183  virtual void clearModified() override;
185  virtual bool artPartListModified() const override;
186 
190  virtual void addParameterType(int partType, int parameterType) override;
191 
192  protected:
197  };
198 
201  {
202  public:
206 
208  const DtArticulatedPartStateComponentData& frameState() const { return myData; };
209 
211  virtual const DtArticulatedPartManager& articulatedPartManager() const override;
213  virtual const DtArticulatedPartManager& articulatedParts() const override;
215  virtual const DtArticulatedPartCollection& artPartList() const override;
216 
219  void setUpdateFromLegionNetwork(bool);
221  virtual void clearModified() override;
223  virtual bool artPartListModified() const override;
224 
225  protected:
230  {
231  myData = data;
232  }
233 
234  protected:
239  };
240 
244  {
245  public:
249 
251  bool isDoubleBuffered() { return true; };
253  virtual const DtFrameStateInterface* currentFrameState() const override { return &myCurrentFrameState; }
255  virtual DtFrameStateInterface* nextFrameState() override { return &myNextFrameState; };
257  virtual const DtFrameStateInterface* nextFrameState() const override { return &myNextFrameState; };
258 
261  virtual void setCoordinateSystem(const Coordinate_System*) override;
262 
264  virtual void updateDataStorage() override;
265 
268  virtual void updateStateData(DtStateData* sd) override
269  {
270  myCurrentFrameState.updateStateData(sd);
271  myNextFrameState.updateStateData(sd);
272  }
273 
276  virtual void setPublishingOnLegionNetwork(bool b) override;
277 
280  virtual void initializeFromParameters(const DtVrfObjectParameters* params) override;
281 
283  virtual void aboutToBeDeleted() override
284  {
286  myCurrentFrameState.aboutToBeDeleted();
287  myNextFrameState.aboutToBeDeleted();
288  }
289 
293  static void SetAddMissingParameterToAllParts(bool);
295  static bool AddMissingParameterToAllParts();
296 
297  protected:
299  virtual void createPartsFromDescriptors(const std::list<DtSimArtPartDescriptor*>& descriptors,
300  const std::list<DtSimArtPartDescriptor*>& partDefaultsFromActuators);
301 
302  protected:
307  };
308 
312 }
Instances of DtVrfObjectParameters are the readable/writeable objects that contain the information ne...
Definition: vrfObjectParameters.h:64
The articulated part manager maintains a tree of articulated and attached parts for the state reposit...
Definition: articulatedPartManager.h:33
Exception thrown when a required method has not been implemented.
Definition: stateDataTypes.h:30
std::shared_ptr< DtArticulatedPartCollection > myartPartList
DIS/HLA articulated part collection used for network transmission.
Definition: articulatedPartStateComponent.h:80
DtArticulatedPartCollection & artPartList()
Returns a mutable reference to the articulated part collection used for network transmission.
Definition: articulatedPartStateComponent.h:66
2) Define the next frame class. This will be used for write access.
Definition: articulatedPartStateComponent.h:127
A readable, writable type that holds an articulated part type, attached-to part type, attachment point, and a list of art-part params (DtSimArtPartParamList). The read/write name is not used for anything in particular, and therefore may be used for file readability.
Definition: simArtPartDescriptor.h:28
Default creator implementation for a state component type. T_StateComponent is the concrete component...
Definition: stateComponent.h:326
In order to be a well defined state component, you must:
Definition: articulatedPartStateComponent.h:89
virtual bool artPartListModified() const
Returns true if the articulated part list has been modified since last cleared.
Definition: articulatedPartStateComponent.h:113
DtArticulatedPartManager & articulatedPartManager()
Returns a mutable reference to the articulated part manager.
Definition: articulatedPartStateComponent.h:61
#define UNDEFINED_RETURNREF_ACCESSORS(ReturnType, Member)
Defines both const and non-const virtual reference accessors that throw DtUnimplementedMethod, requiring overrides in a derived class.
Definition: doubleBufferedDataStorage.h:74
virtual DtFrameStateInterface * nextFrameState() override
Returns a mutable pointer to the next (write) frame state interface.
Definition: articulatedPartStateComponent.h:255
const DtArticulatedPartStateComponentData & frameState() const
Current frame state only can access current frame buffers. This ensures thread safety.
Definition: articulatedPartStateComponent.h:208
DtArticulatedPartStateComponentNextFrame myNextFrameState
Next (write) frame state for the articulated parts.
Definition: articulatedPartStateComponent.h:306
DtArticulatedPartStateComponentData()
Definition: articulatedPartStateComponent.h:23
bool isDoubleBuffered()
Returns true, indicating this component uses double-buffered state storage.
Definition: articulatedPartStateComponent.h:251
virtual void aboutToBeDeleted() override
Notifies both frame state components that the owning entity is about to be deleted.
Definition: articulatedPartStateComponent.h:283
const DtArticulatedPartStateComponentData & frameState() const
Next frame access write access. Ensure this is only used in a single thread (i.e.a controller thread)...
Definition: articulatedPartStateComponent.h:135
bool myArtPartListModified
Dirty flag indicating the articulated part list has been modified and needs to be transmitted...
Definition: articulatedPartStateComponent.h:82
virtual void detachPartIfAttached(DtArtPartType partType)
Detaches the part of the given type if it is currently attached; a no-op if not present.
Definition: articulatedPartStateComponent.h:120
virtual void updateStateData(DtStateData *sd) override
Updates the state data pointer in both the current and next frame state components.
Definition: articulatedPartStateComponent.h:268
Definition: coordSystem.h:54
The overall structure of the DtStateData mechanism is: The DtStateData contains a list of double buff...
Definition: stateData.h:513
DtArticulatedPartStateComponentData myData
The articulated part state data for the next simulation frame.
Definition: articulatedPartStateComponent.h:194
#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
virtual void makeWritable() override
Override to make component writable.
Definition: articulatedPartStateComponent.h:158
Subclass from this to indicate that this will be a double buffered state component.
Definition: stateComponent.h:489
DtArticulatedPartStateComponentData(const DtArticulatedPartStateComponentData &orig)
Copy constructor. Shares ownership of the manager and collection via shared_ptr.
Definition: articulatedPartStateComponent.h:37
DtStateComponentCreator< DtArticulatedPartStateComponentImplementation > DtArticulatedPartStateComponentCreator
5) Define the creator. This will need to be registered with the REGISTER_STATE_COMPONENT macro in the...
Definition: articulatedPartStateComponent.h:311
virtual void aboutToBeDeleted()
Called when the component is about to be deleted; emits signal_stateComponentAboutToBeDeleted.
virtual void detachPart(DtArtPartType partType)
Detaches the part of the given type.
Definition: articulatedPartStateComponent.h:123
virtual const DtFrameStateInterface * currentFrameState() const override
Returns a const pointer to the current (read) frame state interface.
Definition: articulatedPartStateComponent.h:253
virtual const DtFrameStateInterface * nextFrameState() const override
Returns a const pointer to the next (write) frame state interface.
Definition: articulatedPartStateComponent.h:257
bool initialized() const
Returns true if create() has been called and the manager has been allocated.
Definition: articulatedPartStateComponent.h:57
DtArticulatedPartStateComponentData & frameState()
Definition: articulatedPartStateComponent.h:136
std::shared_ptr< DtArticulatedPartManager > myarticulatedPartManager
Manages the tree of articulated parts for this entity.
Definition: articulatedPartStateComponent.h:74
DtArticulatedPartStateComponentData & operator=(const DtArticulatedPartStateComponentData &rhs)
Assignment operator. Shares ownership of the manager and collection via shared_ptr.
Definition: articulatedPartStateComponent.h:47
4) Define the state component that will contain the wrappers to the next and current frame states tha...
Definition: articulatedPartStateComponent.h:243
bool artPartListModified() const
Returns true if the articulated part list has been modified since last cleared.
Definition: articulatedPartStateComponent.h:72
void create()
Allocates the articulated part manager and the part collection. Must be called before use when not co...
Definition: articulatedPartStateComponent.h:29
The DtArticulatedPartStateRepository class is used to represent articulated parts for an entity...
Definition: articulatedPartStateRepository.h:40
void advanceFrame(const DtArticulatedPartStateComponentData &data)
Advances the current frame buffer by copying in the latest next-frame data.
Definition: articulatedPartStateComponent.h:229
DtArticulatedPartStateComponentCurrentFrame myCurrentFrameState
Current (read) frame state for the articulated parts.
Definition: articulatedPartStateComponent.h:304
#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
const DtArticulatedPartManager & articulatedPartManager() const
Returns a const reference to the articulated part manager.
Definition: articulatedPartStateComponent.h:59
void setArtPartListModified(bool b)
Sets the dirty flag indicating the articulated part list has been modified.
Definition: articulatedPartStateComponent.h:70
const DtArticulatedPartCollection & artPartList() const
Returns a const reference to the articulated part collection used for network transmission.
Definition: articulatedPartStateComponent.h:64
bool myPublishOnLegionNetwork
If true, publishes articulated part state on the LEGION network.
Definition: articulatedPartStateComponent.h:196
virtual DtArticulatedPartStateRepository * attachPart(DtArtPartType partType)
Attaches a part of the given type and returns its state repository.
Definition: articulatedPartStateComponent.h:111
Holds the articulated part state data shared between the next and current frame buffers. Manages the hierarchy of articulated parts and the DIS/HLA collection for network transmission.
Definition: articulatedPartStateComponent.h:21
3) Define the current frame class. This will be used for read access.
Definition: articulatedPartStateComponent.h:200
virtual void addParameterType(int partType, int parameterType)
Adds a parameter metric type for the specified articulated part type.
Definition: articulatedPartStateComponent.h:117
Contains the DtStateComponent class declaration.
DtArticulatedPartStateComponentData myData
The articulated part state data for the current simulation frame.
Definition: articulatedPartStateComponent.h:236
virtual void makeReadOnly() override
Override to make component read-only.
Definition: articulatedPartStateComponent.h:161
Base interface for accessing current or next frame state in a double-buffered state component...
Definition: stateComponent.h:354
bool myUpdateFromLegionNetwork
If true, updates articulated part state from changes received on the LEGION network.
Definition: articulatedPartStateComponent.h:238

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)