VR-Forces 5.0.2 Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtAttachableUpdater.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2017 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
9 
10 #pragma once
11 
12 #include <vrvCore/DtUniqueID.h>
13 #include <vrvCore/DtTickable.h>
14 #include <vrvCore/DtSceneObject.h>
15 
16 #include <matrix/vlVector.h>
17 #include <matrix/vlTaitBryan.h>
18 
19 #include <list>
20 
21 namespace makVrv
22 {
23 
24  class DtDe;
25  class DtSceneObject;
26  class DtSceneObjectUpdater;
27 
34 
35  {
36  public:
37 
40  {
45  AttachedPointTypeInvalidObject
46  };
47 
49  {
52  AttachedPointModeOrientationOnly
53  };
54 
57  {
58  public:
59 
60  AttachedPoint( AttachedPointType type, int targetVertexIndex,
61  const DtVector& positionOffset )
62  : myAttachedPointType( type )
63  , myTargetVertexIndex( targetVertexIndex )
64  , myPositionOffset( positionOffset )
65  , myAttachedPointMode(AttachedPointModePositionAndOrientation)
66  {
67  }
68 
69  virtual ~AttachedPoint() {}
70 
72  {
73  return myAttachedPointType;
74  }
75 
77  {
78  return myTargetVertexIndex;
79  }
80 
81  void setPositionOffset(const DtVector& o)
82  {
83  myPositionOffset = o;
84  }
85 
86  const DtVector& positionOffset() const
87  {
88  return myPositionOffset;
89  }
90 
92  {
93  myAttachedPointMode = mode;
94  }
95 
97  {
98  return myAttachedPointMode;
99  }
100 
101  protected:
102 
107 
108  };
109 
112  {
113  public:
114 
116  int targetVertexIndex, const DtVector& positionOffset )
117  : AttachedPoint( AttachedPointTypeObject, targetVertexIndex, positionOffset )
118  , mySceneObject( sceneObject )
119  , myUpdater( updater )
120  , mySceneObjectId( 0 )
121  {
122  }
123 
124  virtual ~ObjectAttachedPoint() {}
125 
126  inline void setSceneObject( DtSceneObject* sceneObject )
127  {
128  mySceneObject = sceneObject;
129 
130  if (sceneObject)
131  {
132  mySceneObjectId = sceneObject->uniqueId();
133  }
134  else
135  {
136  mySceneObjectId = 0;
137  }
138  }
139 
140  inline DtUniqueID sceneObjectId() const
141  {
142  return mySceneObjectId;
143  }
144 
145  inline DtSceneObject* sceneObject() const
146  {
147  return mySceneObject;
148  }
149 
150  inline void setUpdater( DtSceneObjectUpdater* updater )
151  {
152  myUpdater = updater;
153  }
154 
155  inline DtSceneObjectUpdater* updater() const
156  {
157  return myUpdater;
158  }
159 
160  // When the class is destructed, the scene object may or may not
161  // exist. Using a separate connection variable makes it possible to
162  // 'disconnect' even if the scene object has been deleted.
163  boost::signalslib::connection mySceneObjectConnection;
164  boost::signalslib::connection mySceneObjectUpdaterConnection;
165 
166  protected:
167 
171  };
172 
176  {
177  public:
178 
179  VertexAttachedPoint( const DtVector& position, int targetVertexIndex,
180  const DtVector& positionOffset )
181  : AttachedPoint( AttachedPointTypeVertex, targetVertexIndex, positionOffset )
182  , myVertex( position )
183  {
184  }
185  virtual ~VertexAttachedPoint() {}
186 
187  DtVector vertex() const
188  {
189  return myVertex;
190  }
191 
192  protected:
193 
195  };
196 
200  {
201  public:
202 
204  int vtx1, int vtx2, double proportion, int targetVertexIndex,
205  const DtVector& positionOffset )
206  : ObjectAttachedPoint( sceneObject, updater, targetVertexIndex, positionOffset )
207  , myFirstVtx( vtx1 )
208  , mySecondVtx( vtx2 )
209  , myProportion( proportion )
210  {
211  myAttachedPointType = AttachedPointTypeProportional;
212  }
213 
214  inline int firstVtx()
215  {
216  return myFirstVtx;
217  }
218 
219  inline int secondVtx()
220  {
221  return mySecondVtx;
222  }
223 
224  inline double proportion()
225  {
226  return myProportion;
227  }
228 
229  protected:
230 
233  double myProportion;
234 
235  };
236 
237  public:
238 
241 
243  virtual ~DtAttachableUpdater();
244 
246  virtual bool needsUpdate( DtTime tNow );
247 
251  virtual void addAttachedPoint( const DtVector& position, int targetVertexIndex );
252 
256  virtual void addAttachedPoint( DtUniqueID uniqueID, int targetVertexIndex );
257 
261  virtual void addAttachedPoint( DtUniqueID uniqueID, int vtx1, int vtx2,
262  double proportion, int targetVertexIndex );
263 
268  virtual const AttachedPoint& attachedPoint( int targetVertexIndex ) const;
269 
272  virtual void setPositionOffset( const DtVector& offset );
273 
277  virtual void setWorldPositionOffset( const DtVector& offset );
278 
282  virtual void setPositionOffset( const DtVector& offset, int vtx );
283 
286  virtual void setOrientationOffset(const DtTaitBryan& offset);
287 
290  virtual void setWorldOrientationOffset(const DtTaitBryan& offset);
291 
293  virtual void setAttachedPointMode( unsigned int mode, int vtx );
294 
296  virtual void update( DtTime tNow );
297 
300  virtual void setSceneObject( DtSceneObject* sceneObject );
301 
304  virtual void doAttachment( DtTime tNow );
305 
306  inline DtTime lastUpdateTime() const
307  {
308  return myLastUpdateTime;
309  }
310 
311  protected:
312 
315  virtual void slot_sceneObjectToBeDeleted( const DtUniqueID& id );
316  virtual void slot_attachedSceneObjectToBeDeleted( const DtUniqueID& );
317  virtual void slot_attachedUpdaterToBeDeleted( const DtUniqueID& id );
319 
320  // get values of attached point at simTime
321  virtual bool pointLocationAndOrientation( AttachedPoint* point,
322  double simTime, DtVector& location, DtTaitBryan& orientation );
323 
325  virtual void removeAttachedPoint(int vtx, DtVector* positionOffset = 0);
326 
327  protected:
330 
333 
336 
337  // When the class is destructed, the scene object may or may not
338  // exist. Using a separate connection variable makes it possible to
339  // 'disconnect' even if the scene object has been deleted.
340  boost::signalslib::connection mySceneObjectConnection;
341  boost::signalslib::connection mySceneObjectUpdaterConnection;
342 
345 
346  typedef std::vector<AttachedPoint*> AttachedPointsVector;
348 
350  DtTaitBryan myOrientationOffset;
351 
354 
356  };
357 }
int targetVertexIndex()
Definition: DtAttachableUpdater.h:76
AttachedPointType myAttachedPointType
Definition: DtAttachableUpdater.h:103
DtUniqueID uniqueId() const
Get the unique ID of the object.
virtual ~ObjectAttachedPoint()
Definition: DtAttachableUpdater.h:124
DtTaitBryan myWorldOrientationOffset
Definition: DtAttachableUpdater.h:353
AttachedPoint used to attach to a scene object.
Definition: DtAttachableUpdater.h:111
virtual ~VertexAttachedPoint()
Definition: DtAttachableUpdater.h:185
Common base class for all attachments.
Definition: DtAttachableUpdater.h:56
DtTime myLastUpdateTime
The last time stamp when the update()
Definition: DtAttachableUpdater.h:344
AttachedPointMode myAttachedPointMode
Definition: DtAttachableUpdater.h:106
DtVector vertex() const
Definition: DtAttachableUpdater.h:187
AttachedPointsVector myAttachedPoints
Definition: DtAttachableUpdater.h:347
AttachPoint used to attach to a position provided through the updater interface.
Definition: DtAttachableUpdater.h:175
Scene Object Updater.
Definition: DtSceneObjectUpdater.h:36
boost::signalslib::connection mySceneObjectConnection
Definition: DtAttachableUpdater.h:340
DtSceneObjectUpdater * updater() const
Definition: DtAttachableUpdater.h:155
std::vector< AttachedPoint * > AttachedPointsVector
Definition: DtAttachableUpdater.h:346
An abstract base class for objects that require updates. This object automatically adds itself to a D...
Definition: DtTickable.h:26
int secondVtx()
Definition: DtAttachableUpdater.h:219
LinearAttachedPoint(DtSceneObject *sceneObject, DtSceneObjectUpdater *updater, int vtx1, int vtx2, double proportion, int targetVertexIndex, const DtVector &positionOffset)
Definition: DtAttachableUpdater.h:203
void setAttachedPointMode(AttachedPointMode mode)
Definition: DtAttachableUpdater.h:91
DtSceneObject * mySceneObject
Definition: DtAttachableUpdater.h:168
AttachedPointType
Types of attachments.
Definition: DtAttachableUpdater.h:39
void setPositionOffset(const DtVector &o)
Definition: DtAttachableUpdater.h:81
DtSceneObject * sceneObject() const
Definition: DtAttachableUpdater.h:145
A DtAttachableUpdater updates a scene an object that can be positioned in the scene by (possibly) att...
Definition: DtAttachableUpdater.h:33
DtVector myVertex
Definition: DtAttachableUpdater.h:194
boost::signalslib::connection mySceneObjectUpdaterConnection
Definition: DtAttachableUpdater.h:164
int myTargetVertexIndex
Definition: DtAttachableUpdater.h:104
int firstVtx()
Definition: DtAttachableUpdater.h:214
DtVector myPositionOffset
Definition: DtAttachableUpdater.h:105
void setUpdater(DtSceneObjectUpdater *updater)
Definition: DtAttachableUpdater.h:150
DtVector myWorldPositionOffset
Definition: DtAttachableUpdater.h:352
void setSceneObject(DtSceneObject *sceneObject)
Definition: DtAttachableUpdater.h:126
DtUniqueID myUniqueId
This distributed object&#39;s unique identifier.
Definition: DtAttachableUpdater.h:332
#define DT_DLL_VRVCORE
Definition: vrvCore.h:20
AttachedPointMode attachedPointMode() const
Definition: DtAttachableUpdater.h:96
int mySecondVtx
Definition: DtAttachableUpdater.h:232
DtTaitBryan myOrientationOffset
Definition: DtAttachableUpdater.h:350
boost::signalslib::connection mySceneObjectConnection
Definition: DtAttachableUpdater.h:163
ObjectAttachedPoint(DtSceneObject *sceneObject, DtSceneObjectUpdater *updater, int targetVertexIndex, const DtVector &positionOffset)
Definition: DtAttachableUpdater.h:115
DtUniqueID mySceneObjectId
Definition: DtAttachableUpdater.h:355
Definition: DtAttachableUpdater.h:42
DtUniqueID mySceneObjectId
Definition: DtAttachableUpdater.h:170
AttachPoint used to attach to a point that is proportionally positioned between 2 other points...
Definition: DtAttachableUpdater.h:199
AttachedPoint(AttachedPointType type, int targetVertexIndex, const DtVector &positionOffset)
Definition: DtAttachableUpdater.h:60
AttachedPointType type() const
Definition: DtAttachableUpdater.h:71
Contains the declaration for makVrv::DtTickable.
DtUniqueID sceneObjectId() const
Definition: DtAttachableUpdater.h:140
double proportion()
Definition: DtAttachableUpdater.h:224
VertexAttachedPoint(const DtVector &position, int targetVertexIndex, const DtVector &positionOffset)
Definition: DtAttachableUpdater.h:179
const char int mode
Definition: ioapi.h:38
A DtSceneObject represents an object that can be positioned in the scene by (possibly) attaching it t...
Definition: DtSceneObject.h:42
Definition: DtAttachableUpdater.h:41
Contains makVrv::DtUniqueID type.
DtSceneObject * mySceneObject
A pointer to the current scene object being updated.
Definition: DtAttachableUpdater.h:335
double myProportion
Definition: DtAttachableUpdater.h:233
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
DtVector myPositionOffset
Definition: DtAttachableUpdater.h:349
boost::signalslib::connection mySceneObjectUpdaterConnection
Definition: DtAttachableUpdater.h:341
voidpf uLong offset
Definition: ioapi.h:42
AttachedPointMode
Definition: DtAttachableUpdater.h:48
int myFirstVtx
Definition: DtAttachableUpdater.h:231
DtDe & myDe
The display engine.
Definition: DtAttachableUpdater.h:329
DtSceneObjectUpdater * myUpdater
Definition: DtAttachableUpdater.h:169
const DtVector & positionOffset() const
Definition: DtAttachableUpdater.h:86
virtual ~AttachedPoint()
Definition: DtAttachableUpdater.h:69
DtTime lastUpdateTime() const
Definition: DtAttachableUpdater.h:306
Contains makVrv::DtSceneObject class.

Document ID: Generated on Sun Dec 4 20:22:03 EST 2022 from SVN revision 249613
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)