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 
99  virtual void setPartTypeAttachedTo(int attachedTo);
100 
102  virtual unsigned short attachedToPartIndex() const;
103 
105  virtual void setAttachedToPartIndex(unsigned int index);
106 
108  virtual unsigned int partType() const;
109 
111  virtual void setPartType(unsigned int artPartType);
112 
114  virtual void getParameterMetrics(std::vector<ParameterMetric>& metrics) const;
115 
128  virtual bool setParameter(ParameterMetric parameterMetric,const Parameter& parameter,
129  bool setOnlyValue = true);
130 
137  inline bool setParameter(ParameterMetric parameterMetric,float value)
138  {
139  Parameter parameter;
140  parameter.value = value;
141  return setParameter(parameterMetric,parameter);
142  }
143 
148  virtual bool getParameter(ParameterMetric parameterMetric,Parameter& parameter) const;
149 
156  virtual float getParameterValue(ParameterMetric parameterMetric, double time) const;
157 
161  inline float getParameterValue(ParameterMetric parameterMetric) const
162  {
163  return getParameterValue(parameterMetric,clock() ? clock()->simTime() : 0.0);
164  }
165 
167  virtual void unsetParameter(ParameterMetric parameterMetric);
168 
170  virtual void unsetAllParameters();
171 
173  virtual void incrementChange(ParameterMetric parameterMetric);
174 
176  virtual bool approximating() const;
177 
179  virtual void setApproximating(bool deadreckoning);
180 
184  virtual void setClock(DtClock* clock);
185 
187 
188  DtClock* clock();
189  const DtClock* clock() const;
191 
192  //@name Fast inline functions for validating metrics.
194 
196  inline bool isParameterSet(ParameterMetric parameterMetric) const;
197 
199  inline bool isParameterMetricValid(ParameterMetric parameterMetric) const;
200 
202  inline bool isParameterApproximated(ParameterMetric parameterMetric) const;
203 
209  inline unsigned int getParameterRateMetric(ParameterMetric parameterMetric) const;
210 
212 
213 
214  //@name Helper functions for getting/setting Translation,Orientation and rates.
216 
218  inline bool hasTranslation() const;
219 
221  inline DtVector translation() const;
222 
224  inline DtVector translation(double time) const;
225 
227  inline bool getTranslation(DtVector& vec) const;
228 
230  inline bool getTranslation(DtVector& vec, double time) const;
231 
233  inline void setTranslation(const DtVector& trans);
234 
236  inline bool hasTranslationRate() const;
237 
239  inline DtVector translationRate() const;
240 
242  inline bool getTranslationRate(DtVector& vec) const;
243 
245  inline void setTranslationRate(const DtVector& transRate);
246 
248  inline bool hasOrientation() const;
249 
251  inline DtTaitBryan orientation() const;
252 
254  inline DtTaitBryan orientation(double time) const;
255 
257  inline bool getOrientation(DtTaitBryan& ori) const;
258 
260  inline bool getOrientation(DtTaitBryan& ori, double time) const;
261 
263  inline void setOrientation(const DtTaitBryan& ori);
264 
266  inline bool hasOrientationRate() const;
267 
269  inline DtVector orientationRate() const;
270 
272  inline bool getOrientationRate(DtVector& oriRate) const;
273 
275  inline void setOrientationRate(const DtVector& oriRate);
276 
278 
280  virtual void printDataToStream(std::ostream& str) const;
281 
282 public:
284  static inline unsigned int decodeArtPartType(unsigned int type);
285 
287  static inline unsigned char decodeArtPartParamMetric(unsigned int type);
288 
289  static inline unsigned int encodeArtPartParamType(unsigned int partType, unsigned char paramMetric);
290 
291  static bool approximatingEnabledFlag();
292  static void setApproximatingEnabledFlag(bool enabled);
293 
294 protected:
295 
296  // A 16bit integer id.
298  unsigned short myAttachedToPartIndex;
299 
300  unsigned int myPartType;
301 
302  //A Mask of the first 32 parameters. Most standards do not support more than 32.
303  unsigned int myParameterMask;
304 
305  //A vector of parameters.
306  std::vector<Parameter> myParameters;
307 
308  //A flag which controls whether to dead-reckon values.
310 
311  //An internal pointer to a shared clock used to automatically get the time.
313 
314 protected:
315 
316  //A flag which controls whether to dead-reckon value by default
318 };
319 
320 #define articulatedPart_inl_
321 #include "articulatedPart.inl"
322 #undef articulatedPart_inl_
323 
324 
325 
326 #endif

Document ID: Generated on Wed Aug 14 15:35:11 EDT 2013 from SVN revision 130445
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)