VR-Forces 4.5 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 #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  protected:
161 
165  };
166 
170  {
171  public:
172 
173  VertexAttachedPoint( const DtVector& position, int targetVertexIndex,
174  const DtVector& positionOffset )
175  : AttachedPoint( AttachedPointTypeVertex, targetVertexIndex, positionOffset )
176  , myVertex( position )
177  {
178  }
179  virtual ~VertexAttachedPoint() {}
180 
181  DtVector vertex() const
182  {
183  return myVertex;
184  }
185 
186  protected:
187 
189  };
190 
194  {
195  public:
196 
198  int vtx1, int vtx2, double proportion, int targetVertexIndex,
199  const DtVector& positionOffset )
200  : ObjectAttachedPoint( sceneObject, updater, targetVertexIndex, positionOffset )
201  , myFirstVtx( vtx1 )
202  , mySecondVtx( vtx2 )
203  , myProportion( proportion )
204  {
205  myAttachedPointType = AttachedPointTypeProportional;
206  }
207 
208  inline int firstVtx()
209  {
210  return myFirstVtx;
211  }
212 
213  inline int secondVtx()
214  {
215  return mySecondVtx;
216  }
217 
218  inline double proportion()
219  {
220  return myProportion;
221  }
222 
223  protected:
224 
227  double myProportion;
228 
229  };
230 
231  public:
232 
235 
237  virtual ~DtAttachableUpdater();
238 
240  virtual bool needsUpdate( DtTime tNow );
241 
245  virtual void addAttachedPoint( const DtVector& position, int targetVertexIndex );
246 
250  virtual void addAttachedPoint( DtUniqueID uniqueID, int targetVertexIndex );
251 
255  virtual void addAttachedPoint( DtUniqueID uniqueID, int vtx1, int vtx2,
256  double proportion, int targetVertexIndex );
257 
262  virtual const AttachedPoint& attachedPoint( int targetVertexIndex ) const;
263 
266  virtual void setPositionOffset( const DtVector& offset );
267 
271  virtual void setWorldPositionOffset( const DtVector& offset );
272 
276  virtual void setPositionOffset( const DtVector& offset, int vtx );
277 
280  virtual void setOrientationOffset(const DtTaitBryan& offset);
281 
284  virtual void setWorldOrientationOffset(const DtTaitBryan& offset);
285 
287  virtual void setAttachedPointMode( unsigned int mode, int vtx );
288 
290  virtual void update( DtTime tNow );
291 
294  virtual void setSceneObject( DtSceneObject* sceneObject );
295 
298  virtual void doAttachment( DtTime tNow );
299 
300  inline DtTime lastUpdateTime() const
301  {
302  return myLastUpdateTime;
303  }
304 
305  protected:
306 
309  virtual void slot_sceneObjectToBeDeleted( const DtUniqueID& id );
310  virtual void slot_attachedSceneObjectToBeDeleted( const DtUniqueID& );
311  virtual void slot_attachedUpdaterToBeDeleted( const DtUniqueID& id );
313 
314  // get values of attached point at simTime
315  virtual bool pointLocationAndOrientation( AttachedPoint* point,
316  double simTime, DtVector& location, DtTaitBryan& orientation );
317 
319  virtual void removeAttachedPoint(int vtx, DtVector* positionOffset = 0);
320 
321  protected:
324 
327 
330 
333 
334  typedef std::vector<AttachedPoint*> AttachedPointsVector;
336 
338  DtTaitBryan myOrientationOffset;
339 
342 
344  };
345 }

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)