VR-Forces 4.6 Class Documentation
 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 
71  AttachedPointType type() const
72  {
73  return myAttachedPointType;
74  }
75 
76  int targetVertexIndex()
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 
91  void setAttachedPointMode( AttachedPointMode mode )
92  {
93  myAttachedPointMode = mode;
94  }
95 
96  AttachedPointMode attachedPointMode() const
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 }

Document ID: Generated on Thu Apr 12 03:15:37 EDT 2018 from SVN revision 187986
Copyright © 2005-2018 VT MÄK. All Rights Reserved (www.mak.com)