HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
KIN_Bone.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: KIN_Bone.h ( Kinematics Library, C++)
7  *
8  * COMMENTS:
9  * class for storing bone specification
10  */
11 
12 #ifndef __KIN_Bone__
13 #define __KIN_Bone__
14 
15 #include "KIN_API.h"
16 #include "KIN_AngleConstraint.h"
17 #include <UT/UT_Matrix4.h>
18 #include <SYS/SYS_Types.h>
19 #include <string.h>
20 
22 {
23 public:
25  {
26  myRot[0] = myRot[1] = myRot[2] = 0.0;
27  myRad[0] = myRad[1] = myRad[2] = 0.0;
28  myLength = 0.0;
29  myDampening = 0.0;
30  myExtraXform.identity();
31  myData = 0;
32  myDirtyRadians = true;
33  }
34 
36  {
37  }
38 
39  fpreal getRotate( int axis ) const { return myRot[axis]; }
40  void getRotates( fpreal *r ) const
41  { memcpy( r, myRot, sizeof(myRot) ); }
42 
43  fpreal getRadians( int axis ) const
44  {
45  if( myDirtyRadians )
46  {
47  myRad[0] = SYSdegToRad(myRot[0]);
48  myRad[1] = SYSdegToRad(myRot[1]);
49  myRad[2] = SYSdegToRad(myRot[2]);
50  myDirtyRadians = false;
51  }
52  return myRad[axis];
53  }
54 
55  void getRadians( fpreal *r ) const
56  {
57  if( myDirtyRadians )
58  {
59  myRad[0] = SYSdegToRad(myRot[0]);
60  myRad[1] = SYSdegToRad(myRot[1]);
61  myRad[2] = SYSdegToRad(myRot[2]);
62  myDirtyRadians = false;
63  }
64  memcpy( r, myRad, sizeof(myRad) );
65  }
66 
67  const UT_Matrix4R &getExtraXform() const { return myExtraXform; }
68 
69  fpreal getLength() const { return myLength; }
70  fpreal getDampening() const { return myDampening; }
71  const void *getData() const { return myData; }
72  fpreal constrain(int axis, fpreal angle, fpreal step) const
73  { return myConstraint.constrain(axis, angle, step); }
74 
75  void setRotate( int axis, fpreal r )
76  { myRot[axis] = r; myDirtyRadians = true; }
77  void setRotates( const fpreal *r )
78  {
79  memcpy( myRot, r, sizeof(myRot) );
80  myDirtyRadians = true;
81  }
82  void setRotates( const fpreal *deg, const fpreal *rad)
83  {
84  memcpy( myRot, deg, sizeof(myRot) );
85  memcpy( myRad, rad, sizeof(myRad) );
86  myDirtyRadians = false;
87  }
88 
89  void setExtraXform(const UT_Matrix4R &xform)
90  { myExtraXform = xform; }
91 
92  void setLength( fpreal l ) { myLength = l; }
93  void setDampening( fpreal d ){ myDampening = d; }
94  void setData( const void *d ){ myData = d; }
95  void setConstraint( fpreal rest[3], fpreal xrange[2],
96  fpreal yrange[2], fpreal zrange[2],
97  fpreal damp[3], fpreal roll[3] )
98  {
99  myConstraint.setConstraint(rest, xrange, yrange,
100  zrange, damp, roll);
101  }
102 
103  int64 getMemoryUsage(bool inclusive) const
104  {
105  return inclusive ? sizeof(*this) : 0;
106  }
107 
108 private:
109  fpreal myRot[3];
110  fpreal myLength;
111  fpreal myDampening;
112  UT_Matrix4R myExtraXform;
113  const void *myData;
114  KIN_AngleConstraint myConstraint;
115 
116  mutable fpreal myRad[3];
117  mutable bool myDirtyRadians;
118 };
119 
120 #endif
121 
KIN_Bone()
Definition: KIN_Bone.h:24
void setRotates(const fpreal *deg, const fpreal *rad)
Definition: KIN_Bone.h:82
int64 getMemoryUsage(bool inclusive) const
Definition: KIN_Bone.h:103
void getRotates(fpreal *r) const
Definition: KIN_Bone.h:40
~KIN_Bone()
Definition: KIN_Bone.h:35
GLdouble l
Definition: glew.h:9122
const void * getData() const
Definition: KIN_Bone.h:71
fpreal getLength() const
Definition: KIN_Bone.h:69
GLdouble angle
Definition: glew.h:9135
void setLength(fpreal l)
Definition: KIN_Bone.h:92
fpreal getDampening() const
Definition: KIN_Bone.h:70
fpreal getRadians(int axis) const
Definition: KIN_Bone.h:43
void setRotates(const fpreal *r)
Definition: KIN_Bone.h:77
void setExtraXform(const UT_Matrix4R &xform)
Definition: KIN_Bone.h:89
long long int64
Definition: SYS_Types.h:111
void setDampening(fpreal d)
Definition: KIN_Bone.h:93
const UT_Matrix4R & getExtraXform() const
Definition: KIN_Bone.h:67
void setConstraint(fpreal rest[3], fpreal xrange[2], fpreal yrange[2], fpreal zrange[2], fpreal damp[3], fpreal roll[3])
Definition: KIN_Bone.h:95
fpreal constrain(int axis, fpreal angle, fpreal step) const
Definition: KIN_Bone.h:72
void setData(const void *d)
Definition: KIN_Bone.h:94
void setRotate(int axis, fpreal r)
Definition: KIN_Bone.h:75
double fpreal
Definition: SYS_Types.h:276
GLdouble GLdouble GLdouble r
Definition: glew.h:1406
fpreal getRotate(int axis) const
Definition: KIN_Bone.h:39
#define KIN_API
Definition: KIN_API.h:10
void getRadians(fpreal *r) const
Definition: KIN_Bone.h:55
GA_API const UT_StringHolder rest