VR-Forces Development_Version Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
DtAttachableUpdater.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2013 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 
15 #include <matrix/vlVector.h>
16 #include <matrix/vlTaitBryan.h>
17 
18 #include <list>
19 
20 namespace makVrv
21 {
22 
23  class DtDe;
24  class DtSceneObject;
25  class DtSceneObjectUpdater;
26 
33 
34  {
35  public:
36 
39  {
44  AttachedPointTypeInvalidObject
45  };
46 
48  {
51  AttachedPointModeOrientationOnly
52  };
53 
56  {
57  public:
58 
59  AttachedPoint( AttachedPointType type, int targetVertexIndex,
60  const DtVector& positionOffset )
61  : myAttachedPointType( type )
62  , myTargetVertexIndex( targetVertexIndex )
63  , myPositionOffset( positionOffset )
64  , myAttachedPointMode(AttachedPointModePositionAndOrientation)
65  {
66  }
67 
68  virtual ~AttachedPoint() {}
69 
70  AttachedPointType type() const
71  {
72  return myAttachedPointType;
73  }
74 
75  int targetVertexIndex()
76  {
77  return myTargetVertexIndex;
78  }
79 
80  void setPositionOffset(const DtVector& o)
81  {
82  myPositionOffset = o;
83  }
84 
85  const DtVector& positionOffset() const
86  {
87  return myPositionOffset;
88  }
89 
90  void setAttachedPointMode( AttachedPointMode mode )
91  {
92  myAttachedPointMode = mode;
93  }
94 
95  AttachedPointMode attachedPointMode() const
96  {
97  return myAttachedPointMode;
98  }
99 
100  protected:
101 
106 
107  };
108 
111  {
112  public:
113 
115  int targetVertexIndex, const DtVector& positionOffset )
116  : AttachedPoint( AttachedPointTypeObject, targetVertexIndex, positionOffset )
117  , mySceneObject( sceneObject )
118  , myUpdater( updater )
119  {
120  }
121 
122  virtual ~ObjectAttachedPoint() {}
123 
124  inline void setSceneObject( DtSceneObject* sceneObject )
125  {
126  mySceneObject = sceneObject;
127  }
128 
129  inline DtSceneObject* sceneObject() const
130  {
131  return mySceneObject;
132  }
133 
134  inline void setUpdater( DtSceneObjectUpdater* updater )
135  {
136  myUpdater = updater;
137  }
138 
139  inline DtSceneObjectUpdater* updater() const
140  {
141  return myUpdater;
142  }
143 
144  protected:
145 
148  };
149 
153  {
154  public:
155 
156  VertexAttachedPoint( const DtVector& position, int targetVertexIndex,
157  const DtVector& positionOffset )
158  : AttachedPoint( AttachedPointTypeVertex, targetVertexIndex, positionOffset )
159  , myVertex( position )
160  {
161  }
162  virtual ~VertexAttachedPoint() {}
163 
164  DtVector vertex() const
165  {
166  return myVertex;
167  }
168 
169  protected:
170 
172  };
173 
177  {
178  public:
179 
181  int vtx1, int vtx2, double proportion, int targetVertexIndex,
182  const DtVector& positionOffset )
183  : ObjectAttachedPoint( sceneObject, updater, targetVertexIndex, positionOffset )
184  , myFirstVtx( vtx1 )
185  , mySecondVtx( vtx2 )
186  , myProportion( proportion )
187  {
188  myAttachedPointType = AttachedPointTypeProportional;
189  }
190 
191  inline int firstVtx()
192  {
193  return myFirstVtx;
194  }
195 
196  inline int secondVtx()
197  {
198  return mySecondVtx;
199  }
200 
201  inline double proportion()
202  {
203  return myProportion;
204  }
205 
206  protected:
207 
210  double myProportion;
211 
212  };
213 
214  public:
215 
218 
220  virtual ~DtAttachableUpdater();
221 
223  virtual bool needsUpdate( DtTime tNow );
224 
228  virtual void addAttachedPoint( const DtVector& position, int targetVertexIndex );
229 
233  virtual void addAttachedPoint( DtUniqueID uniqueID, int targetVertexIndex );
234 
238  virtual void addAttachedPoint( DtUniqueID uniqueID, int vtx1, int vtx2,
239  double proportion, int targetVertexIndex );
240 
245  virtual const AttachedPoint& attachedPoint( int targetVertexIndex ) const;
246 
249  virtual void setPositionOffset( const DtVector& offset );
250 
254  virtual void setWorldPositionOffset( const DtVector& offset );
255 
259  virtual void setPositionOffset( const DtVector& offset, int vtx );
260 
263  virtual void setOrientationOffset(const DtTaitBryan& offset);
264 
267  virtual void setWorldOrientationOffset(const DtTaitBryan& offset);
268 
270  virtual void setAttachedPointMode( unsigned int mode, int vtx );
271 
273  virtual void update( DtTime tNow );
274 
277  virtual void setSceneObject( DtSceneObject* sceneObject );
278 
281  virtual void doAttachment( DtTime tNow );
282 
283  inline DtTime lastUpdateTime() const
284  {
285  return myLastUpdateTime;
286  }
287 
288  protected:
289 
292  virtual void slot_sceneObjectToBeDeleted( const DtUniqueID& id );
293  virtual void slot_attachedSceneObjectToBeDeleted( const DtUniqueID& );
294  virtual void slot_attachedUpdaterToBeDeleted( const DtUniqueID& id );
296 
297  // get values of attached point at simTime
298  virtual bool pointLocationAndOrientation( AttachedPoint* point,
299  double simTime, DtVector& location, DtTaitBryan& orientation );
300 
302  virtual void removeAttachedPoint(int vtx, DtVector* positionOffset = 0);
303 
304  protected:
307 
310 
313 
316 
317  typedef std::vector<AttachedPoint*> AttachedPointsVector;
319 
321  DtTaitBryan myOrientationOffset;
322 
325  };
326 }

Document ID: Generated on Tue Mar 8 22:13:38 EST 2016 from SVN revision 162938
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)