VR-Link API Documentation for HLA 1.3
articulatedPart.h
Go to the documentation of this file.
1 /*********************************************************************
2 ** Copyright (c) 1992-2010 VT MAK
3 ** All rights reserved.
4 *********************************************************************/
5 
6 
11 
12 #ifndef articulatedPart_H_
13 #define articulatedPart_H_
14 
15 #include <vlutil/vlMachineTypes.h>
16 #include <vlutil/vlTime.h>
17 
18 #include <matrix/vlTaitBryan.h>
19 #include <matrix/vlVector.h>
20 
21 #include <vector>
22 
23 
24 class DtClock;
25 
31 {
32 public:
34  struct Parameter
35  {
36  float value;
37  unsigned char change;
38  double time;
39  };
40 
46  {
47  ParameterMetric_Position = 1,
48  ParameterMetric_PositionRate = 2,
49  ParameterMetric_Extension = 3,
50  ParameterMetric_ExtensionRate = 4,
51  ParameterMetric_X = 5,
52  ParameterMetric_XRate = 6,
53  ParameterMetric_Y = 7,
54  ParameterMetric_YRate = 8,
55  ParameterMetric_Z = 9,
56  ParameterMetric_ZRate = 10,
57  ParameterMetric_Azimuth = 11,
58  ParameterMetric_AzimuthRate = 12,
59  ParameterMetric_Elevation = 13,
60  ParameterMetric_ElevationRate = 14,
61  ParameterMetric_Rotation = 15,
62  ParameterMetric_RotationRate = 16
63  };
64 
66  typedef unsigned char ParameterMetric;
67 
71  DtArticulatedPart(DtClock* clock = 0);
72 
75 
77  DtArticulatedPart& operator=(const DtArticulatedPart& copy);
78 
80  virtual ~DtArticulatedPart();
81 
84  bool operator==(const DtArticulatedPart& other) const;
85  bool operator!=(const DtArticulatedPart& other) const;
86 
89  virtual bool hasTheSameMetrics(const DtArticulatedPart& other) const;
90 
93  virtual unsigned int parameterCount() const;
94 
96  virtual int partTypeAttachedTo() const;
97 
101  virtual void setPartTypeAttachedTo(int attachedTo);
102 
104  virtual unsigned short attachedToPartIndex() const;
105 
109  virtual void setAttachedToPartIndex(unsigned int index);
110 
112  virtual unsigned int partType() const;
113 
115  virtual void setPartType(unsigned int artPartType);
116 
118  virtual void getParameterMetrics(std::vector<ParameterMetric>& metrics) const;
119 
132  virtual bool setParameter(ParameterMetric parameterMetric,const Parameter& parameter,
133  bool setOnlyValue = true);
134 
141  inline bool setParameter(ParameterMetric parameterMetric,float value)
142  {
143  Parameter parameter;
144  parameter.value = value;
145  return setParameter(parameterMetric,parameter);
146  }
147 
152  virtual bool getParameter(ParameterMetric parameterMetric,Parameter& parameter) const;
153 
160  virtual float getParameterValue(ParameterMetric parameterMetric, double time) const;
161 
165  inline float getParameterValue(ParameterMetric parameterMetric) const
166  {
167  return getParameterValue(parameterMetric,clock() ? clock()->simTime() : 0.0);
168  }
169 
171  virtual void unsetParameter(ParameterMetric parameterMetric);
172 
174  virtual void unsetAllParameters();
175 
177  virtual void incrementChange(ParameterMetric parameterMetric);
178 
180  virtual bool approximating() const;
181 
183  virtual void setApproximating(bool deadreckoning);
184 
188  virtual void setClock(DtClock* clock);
189 
191 
192  DtClock* clock();
193  const DtClock* clock() const;
195 
196  //@name Fast inline functions for validating metrics.
198 
200  inline bool isParameterSet(ParameterMetric parameterMetric) const;
201 
203  inline bool isParameterMetricValid(ParameterMetric parameterMetric) const;
204 
206  inline bool isParameterApproximated(ParameterMetric parameterMetric) const;
207 
213  inline unsigned int getParameterRateMetric(ParameterMetric parameterMetric) const;
214 
216 
217 
218  //@name Helper functions for getting/setting Translation,Orientation and rates.
220 
222  inline bool hasTranslation() const;
223 
225  inline DtVector translation() const;
226 
228  inline DtVector translation(double time) const;
229 
231  inline bool getTranslation(DtVector& vec) const;
232 
234  inline bool getTranslation(DtVector& vec, double time) const;
235 
237  inline void setTranslation(const DtVector& trans);
238 
240  inline bool hasTranslationRate() const;
241 
243  inline DtVector translationRate() const;
244 
246  inline bool getTranslationRate(DtVector& vec) const;
247 
249  inline void setTranslationRate(const DtVector& transRate);
250 
252  inline bool hasOrientation() const;
253 
255  inline DtTaitBryan orientation() const;
256 
258  inline DtTaitBryan orientation(double time) const;
259 
261  inline bool getOrientation(DtTaitBryan& ori) const;
262 
264  inline bool getOrientation(DtTaitBryan& ori, double time) const;
265 
267  inline void setOrientation(const DtTaitBryan& ori);
268 
270  inline bool hasOrientationRate() const;
271 
273  inline DtVector orientationRate() const;
274 
276  inline bool getOrientationRate(DtVector& oriRate) const;
277 
279  inline void setOrientationRate(const DtVector& oriRate);
280 
282 
284  virtual void printDataToStream(std::ostream& str) const;
285 
286 public:
289  static inline unsigned int decodeArtPartType(unsigned int type);
290 
292  static inline unsigned int decodeArtPartClass(unsigned int type);
293 
295  static inline unsigned char decodeArtPartParamMetric(unsigned int type);
296 
298  static inline unsigned int encodeArtPartParamType(unsigned int partClass, unsigned char paramMetric);
299 
300  static bool approximatingEnabledFlag();
301  static void setApproximatingEnabledFlag(bool enabled);
302 
303 protected:
304 
305  // A 16bit integer id.
307  unsigned short myAttachedToPartIndex;
308 
309  unsigned int myPartType;
310 
311  //A Mask of the first 32 parameters. Most standards do not support more than 32.
312  unsigned int myParameterMask;
313 
314  //A vector of parameters.
315  std::vector<Parameter> myParameters;
316 
317  //A flag which controls whether to dead-reckon values.
319 
320  //An internal pointer to a shared clock used to automatically get the time.
322 
323 protected:
324 
325  //A flag which controls whether to dead-reckon value by default
327 };
328 
329 #define articulatedPart_inl_
330 #include "articulatedPart.inl"
331 #undef articulatedPart_inl_
332 
333 
334 
335 #endif

Document ID: Generated on Wed Oct 23 22:25:48 EDT 2013 from SVN revision 132765
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)