VR-Forces 4.3.1 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/vrvCore.h>
13 #include <vrvCore/DtUniqueID.h>
14 #include <vrvCore/DtTickable.h>
15 
16 #include <matrix/vlVector.h>
17 #include <matrix/vlTaitBryan.h>
18 
19 #include <vector>
20 #include <list>
21 
22 namespace makVrv
23 {
24 
25  class DtDe;
26  class DtSceneObject;
27  class DtSceneObjectUpdater;
28 
35 
36  {
37  public:
38 
41  {
46  AttachedPointTypeInvalidObject
47  };
48 
50  {
53  AttachedPointModeOrientationOnly
54  };
55 
58  {
59  public:
60 
61  AttachedPoint( AttachedPointType type, int targetVertexIndex,
62  const DtVector& positionOffset )
63  : myAttachedPointType( type )
64  , myTargetVertexIndex( targetVertexIndex )
65  , myPositionOffset( positionOffset )
66  , myAttachedPointMode(AttachedPointModePositionAndOrientation)
67  {
68  }
69 
70  virtual ~AttachedPoint() {}
71 
72  AttachedPointType type() const
73  {
74  return myAttachedPointType;
75  }
76 
77  int targetVertexIndex()
78  {
79  return myTargetVertexIndex;
80  }
81 
82  void setPositionOffset(const DtVector& o)
83  {
84  myPositionOffset = o;
85  }
86 
87  const DtVector& positionOffset() const
88  {
89  return myPositionOffset;
90  }
91 
92  void setAttachedPointMode( AttachedPointMode mode )
93  {
94  myAttachedPointMode = mode;
95  }
96 
97  AttachedPointMode attachedPointMode() const
98  {
99  return myAttachedPointMode;
100  }
101 
102  protected:
103 
108 
109  };
110 
113  {
114  public:
115 
117  int targetVertexIndex, const DtVector& positionOffset )
118  : AttachedPoint( AttachedPointTypeObject, targetVertexIndex, positionOffset )
119  , mySceneObject( sceneObject )
120  , myUpdater( updater )
121  {
122  }
123 
124  virtual ~ObjectAttachedPoint() {}
125 
126  inline void setSceneObject( DtSceneObject* sceneObject )
127  {
128  mySceneObject = sceneObject;
129  }
130 
131  inline DtSceneObject* sceneObject() const
132  {
133  return mySceneObject;
134  }
135 
136  inline void setUpdater( DtSceneObjectUpdater* updater )
137  {
138  myUpdater = updater;
139  }
140 
141  inline DtSceneObjectUpdater* updater() const
142  {
143  return myUpdater;
144  }
145 
146  protected:
147 
150  };
151 
155  {
156  public:
157 
158  VertexAttachedPoint( const DtVector& position, int targetVertexIndex,
159  const DtVector& positionOffset )
160  : AttachedPoint( AttachedPointTypeVertex, targetVertexIndex, positionOffset )
161  , myVertex( position )
162  {
163  }
164  virtual ~VertexAttachedPoint() {}
165 
166  DtVector vertex() const
167  {
168  return myVertex;
169  }
170 
171  protected:
172 
174  };
175 
179  {
180  public:
181 
183  int vtx1, int vtx2, double proportion, int targetVertexIndex,
184  const DtVector& positionOffset )
185  : ObjectAttachedPoint( sceneObject, updater, targetVertexIndex, positionOffset )
186  , myFirstVtx( vtx1 )
187  , mySecondVtx( vtx2 )
188  , myProportion( proportion )
189  {
190  myAttachedPointType = AttachedPointTypeProportional;
191  }
192 
193  inline int firstVtx()
194  {
195  return myFirstVtx;
196  }
197 
198  inline int secondVtx()
199  {
200  return mySecondVtx;
201  }
202 
203  inline double proportion()
204  {
205  return myProportion;
206  }
207 
208  protected:
209 
212  double myProportion;
213 
214  };
215 
216  public:
217 
220 
222  virtual ~DtAttachableUpdater();
223 
225  virtual bool needsUpdate( DtTime tNow );
226 
230  virtual void addAttachedPoint( const DtVector& position, int targetVertexIndex );
231 
235  virtual void addAttachedPoint( DtUniqueID uniqueID, int targetVertexIndex );
236 
240  virtual void addAttachedPoint( DtUniqueID uniqueID, int vtx1, int vtx2,
241  double proportion, int targetVertexIndex );
242 
247  virtual const AttachedPoint& attachedPoint( int targetVertexIndex ) const;
248 
251  virtual void setPositionOffset( const DtVector& offset );
252 
256  virtual void setWorldPositionOffset( const DtVector& offset );
257 
261  virtual void setPositionOffset( const DtVector& offset, int vtx );
262 
265  virtual void setOrientationOffset(const DtTaitBryan& offset);
266 
269  virtual void setWorldOrientationOffset(const DtTaitBryan& offset);
270 
272  virtual void setAttachedPointMode( unsigned int mode, int vtx );
273 
275  virtual void update( DtTime tNow );
276 
279  virtual void setSceneObject( DtSceneObject* sceneObject );
280 
283  virtual void doAttachment( DtTime tNow );
284 
285  inline DtTime lastUpdateTime() const
286  {
287  return myLastUpdateTime;
288  }
289 
290  protected:
291 
294  virtual void slot_sceneObjectToBeDeleted( const DtUniqueID& id );
295  virtual void slot_attachedSceneObjectToBeDeleted( const DtUniqueID& );
296  virtual void slot_attachedUpdaterToBeDeleted( const DtUniqueID& id );
298 
299  // get values of attached point at simTime
300  virtual bool pointLocationAndOrientation( AttachedPoint* point,
301  double simTime, DtVector& location, DtTaitBryan& orientation );
302 
304  virtual void removeAttachedPoint(int vtx, DtVector* positionOffset = 0);
305 
306  protected:
309 
312 
315 
318 
319  typedef std::vector<AttachedPoint*> AttachedPointsVector;
321 
323  DtTaitBryan myOrientationOffset;
324 
327  };
328 }

Document ID: Generated on Wed Jul 29 00:55:00 EDT 2015 from SVN revision 155257
Copyright © 2005-2015 VT MÄK. All Rights Reserved (www.mak.com)