VR-Link API Documentation for HLA 1.3
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 
102  virtual void setPartTypeAttachedTo(int attachedTo);
103 
105  virtual unsigned short attachedToPartIndex() const;
106 
112  virtual void setAttachedToPartIndex(unsigned int index);
113 
115  virtual unsigned int partType() const;
116 
118  virtual void setPartType(unsigned int artPartType);
119 
121  virtual void getParameterMetrics(std::vector<ParameterMetric>& metrics) const;
122 
135  virtual bool setParameter(ParameterMetric parameterMetric,const Parameter& parameter,
136  bool setOnlyValue = true);
137 
144  inline bool setParameter(ParameterMetric parameterMetric,float value)
145  {
146  Parameter parameter;
147  parameter.value = value;
148  return setParameter(parameterMetric,parameter);
149  }
150 
155  virtual bool getParameter(ParameterMetric parameterMetric,Parameter& parameter) const;
156 
163  virtual float getParameterValue(ParameterMetric parameterMetric, double time) const;
164 
168  inline float getParameterValue(ParameterMetric parameterMetric) const
169  {
170  return getParameterValue(parameterMetric,clock() ? clock()->simTime() : 0.0);
171  }
172 
174  virtual void unsetParameter(ParameterMetric parameterMetric);
175 
177  virtual void unsetAllParameters();
178 
180  virtual void incrementChange(ParameterMetric parameterMetric);
181 
183  virtual bool approximating() const;
184 
186  virtual void setApproximating(bool deadreckoning);
187 
191  virtual void setClock(DtClock* clock);
192 
194  DtClock* clock();
196  const DtClock* clock() const;
198 
199  //@name Fast inline functions for validating metrics.
201 
203  inline bool isParameterSet(ParameterMetric parameterMetric) const;
204 
206  inline bool isParameterMetricValid(ParameterMetric parameterMetric) const;
207 
209  inline bool isParameterApproximated(ParameterMetric parameterMetric) const;
210 
216  inline unsigned int getParameterRateMetric(ParameterMetric parameterMetric) const;
217 
219 
220 
221  //@name Helper functions for getting/setting Translation,Orientation and rates.
223 
225  inline bool hasTranslation() const;
226 
228  inline DtVector translation() const;
229 
231  inline DtVector translation(double time) const;
232 
234  inline bool getTranslation(DtVector& vec) const;
235 
237  inline bool getTranslation(DtVector& vec, double time) const;
238 
240  inline void setTranslation(const DtVector& trans);
241 
243  inline bool hasTranslationRate() const;
244 
246  inline DtVector translationRate() const;
247 
249  inline bool getTranslationRate(DtVector& vec) const;
250 
252  inline void setTranslationRate(const DtVector& transRate);
253 
255  inline bool hasOrientation() const;
256 
258  inline DtTaitBryan orientation() const;
259 
261  inline DtTaitBryan orientation(double time) const;
262 
264  inline bool getOrientation(DtTaitBryan& ori) const;
265 
267  inline bool getOrientation(DtTaitBryan& ori, double time) const;
268 
270  inline void setOrientation(const DtTaitBryan& ori);
271 
273  inline bool hasOrientationRate() const;
274 
276  inline DtVector orientationRate() const;
277 
279  inline bool getOrientationRate(DtVector& oriRate) const;
280 
282  inline void setOrientationRate(const DtVector& oriRate);
283 
285 
287  virtual void printDataToStream(std::ostream& str) const;
288 
289 public:
292  static inline unsigned int decodeArtPartType(unsigned int type);
293 
295  static inline unsigned int decodeArtPartClass(unsigned int type);
296 
298  static inline unsigned char decodeArtPartParamMetric(unsigned int type);
299 
301  static inline unsigned int encodeArtPartParamType(unsigned int partClass, unsigned char paramMetric);
302 
303  static bool approximatingEnabledFlag();
304  static void setApproximatingEnabledFlag(bool enabled);
305 
306 protected:
307 
308  // A 16bit integer id.
310  unsigned short myAttachedToPartIndex;
311 
312  unsigned int myPartType;
313 
314  //A Mask of the first 32 parameters. Most standards do not support more than 32.
315  unsigned int myParameterMask;
316 
317  //A vector of parameters.
318  std::vector<Parameter> myParameters;
319 
320  //A flag which controls whether to dead-reckon values.
322 
323  //An internal pointer to a shared clock used to automatically get the time.
325 
326 protected:
327 
328  //A flag which controls whether to dead-reckon value by default
330 };
331 
332 #define articulatedPart_inl_
333 #include "articulatedPart.inl"
334 #undef articulatedPart_inl_
335 
336 
337 
338 #endif
bool setParameter(ParameterMetric parameterMetric, float value)
Set the parameter, set only the value.
Definition: articulatedPart.h:144
const bool operator==(const DtU128 &lhs, const DtU128 &rhs)
bool myApproximatingFlag
Definition: articulatedPart.h:321
float value
Definition: articulatedPart.h:36
unsigned int myPartType
Definition: articulatedPart.h:312
This file contains the declaration of DtClock and DtTime.
Used to set and maintain time in a simulation.
Definition: vlTime.h:25
DtClock * myClock
Definition: articulatedPart.h:324
DtTaitBryans are used to represent orientation of an object, using a set of three Euler angles...
Definition: vlTaitBryan.h:43
unsigned char change
Definition: articulatedPart.h:37
float getParameterValue(ParameterMetric parameterMetric) const
Get the parameter value using the internal clock.
Definition: articulatedPart.h:168
This file declares DtVector and DtVector32.
Definition: vlVector.h:224
unsigned char ParameterMetric
A Metric is only 5 bits, aka 0-31, only 1-16 are typically defined.
Definition: articulatedPart.h:66
This file declares DtTaitBryan.
unsigned int myParameterMask
Definition: articulatedPart.h:315
double time
Definition: articulatedPart.h:38
int myPartTypeAttachedTo
Definition: articulatedPart.h:309
#define DT_DLL_VLPROTIND
Definition: vlMachineTypes.h:110
const bool operator!=(const DtU128 &lhs, const DtU128 &rhs)
ParameterMetrics
Standard parameter metrics enumerations.
Definition: articulatedPart.h:45
A single articulated part which has a number of parameters.
Definition: articulatedPart.h:30
A parameter structure.
Definition: articulatedPart.h:34
std::vector< Parameter > myParameters
Definition: articulatedPart.h:318
unsigned short myAttachedToPartIndex
Definition: articulatedPart.h:310
static bool theApproximatingEnabledFlag
Definition: articulatedPart.h:329
This file contains typedefs for machine dependant types.

Document ID: Generated on Tue Feb 2 21:02:17 EST 2021 from SVN revision 223668
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)