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 
44  fpreal getRadians( int axis ) const
45  {
46  if( myDirtyRadians )
47  {
48  myRad[0] = SYSdegToRad(myRot[0]);
49  myRad[1] = SYSdegToRad(myRot[1]);
50  myRad[2] = SYSdegToRad(myRot[2]);
51  myDirtyRadians = false;
52  }
53  return myRad[axis];
54  }
55 
56  void getRadians( fpreal *r ) const
57  {
58  if( myDirtyRadians )
59  {
60  myRad[0] = SYSdegToRad(myRot[0]);
61  myRad[1] = SYSdegToRad(myRot[1]);
62  myRad[2] = SYSdegToRad(myRot[2]);
63  myDirtyRadians = false;
64  }
65  memcpy( r, myRad, sizeof(myRad) );
66  }
67 
68  const UT_Matrix4R &getExtraXform() const { return myExtraXform; }
69 
70  fpreal getLength() const { return myLength; }
71  fpreal getDampening() const { return myDampening; }
72  const void *getData() const { return myData; }
73  fpreal constrain(int axis, fpreal angle, fpreal step) const
74  { return myConstraint.constrain(axis, angle, step); }
75 
76  void setRotate( int axis, fpreal r )
77  { myRot[axis] = r; myDirtyRadians = true; }
78  void setRotates( const fpreal *r )
79  {
80  memcpy( myRot, r, sizeof(myRot) );
81  myDirtyRadians = true;
82  }
83  void setRotates( const fpreal *deg, const fpreal *rad)
84  {
85  memcpy( myRot, deg, sizeof(myRot) );
86  memcpy( myRad, rad, sizeof(myRad) );
87  myDirtyRadians = false;
88  }
89 
90  void setExtraXform(const UT_Matrix4R &xform)
91  { myExtraXform = xform; }
92 
93  void setLength( fpreal l ) { myLength = l; }
94  void setDampening( fpreal d ){ myDampening = d; }
95  void setData( const void *d ){ myData = d; }
96  void setConstraint( fpreal rest[3], fpreal xrange[2],
97  fpreal yrange[2], fpreal zrange[2],
98  fpreal damp[3], fpreal roll[3] )
99  {
100  myConstraint.setConstraint(rest, xrange, yrange,
101  zrange, damp, roll);
102  }
103 
104  // The Curve Solver can output rotation matrices directly without conversion.
105  // This isn't used by the other solvers, as they are solving in rotation space.
107  { return myRotMat; }
108  void setRotateMatrix( const UT_Matrix3R &m)
109  {
110  myRotMat = m;
111  }
112 
113  int64 getMemoryUsage(bool inclusive) const
114  {
115  return inclusive ? sizeof(*this) : 0;
116  }
117 
118 private:
119  fpreal myRot[3];
120  UT_Matrix3R myRotMat;
121  fpreal myLength;
122  fpreal myDampening;
123  UT_Matrix4R myExtraXform;
124  const void *myData;
125  KIN_AngleConstraint myConstraint;
126 
127  mutable fpreal myRad[3];
128  mutable bool myDirtyRadians;
129 };
130 
131 #endif
132 
KIN_Bone()
Definition: KIN_Bone.h:24
void setRotates(const fpreal *deg, const fpreal *rad)
Definition: KIN_Bone.h:83
int64 getMemoryUsage(bool inclusive) const
Definition: KIN_Bone.h:113
SIM_API const UT_StringHolder angle
void getRotates(fpreal *r) const
Definition: KIN_Bone.h:40
~KIN_Bone()
Definition: KIN_Bone.h:35
const void * getData() const
Definition: KIN_Bone.h:72
fpreal getLength() const
Definition: KIN_Bone.h:70
void setLength(fpreal l)
Definition: KIN_Bone.h:93
fpreal getDampening() const
Definition: KIN_Bone.h:71
fpreal getRadians(int axis) const
Definition: KIN_Bone.h:44
void setRotates(const fpreal *r)
Definition: KIN_Bone.h:78
void setExtraXform(const UT_Matrix4R &xform)
Definition: KIN_Bone.h:90
void setDampening(fpreal d)
Definition: KIN_Bone.h:94
const UT_Matrix4R & getExtraXform() const
Definition: KIN_Bone.h:68
void setConstraint(fpreal rest[3], fpreal xrange[2], fpreal yrange[2], fpreal zrange[2], fpreal damp[3], fpreal roll[3])
Definition: KIN_Bone.h:96
long long int64
Definition: SYS_Types.h:116
fpreal constrain(int axis, fpreal angle, fpreal step) const
Definition: KIN_Bone.h:73
void setData(const void *d)
Definition: KIN_Bone.h:95
void setRotate(int axis, fpreal r)
Definition: KIN_Bone.h:76
fpreal64 fpreal
Definition: SYS_Types.h:277
void setRotateMatrix(const UT_Matrix3R &m)
Definition: KIN_Bone.h:108
fpreal getRotate(int axis) const
Definition: KIN_Bone.h:39
#define KIN_API
Definition: KIN_API.h:11
void getRadians(fpreal *r) const
Definition: KIN_Bone.h:56
GLboolean r
Definition: glcorearb.h:1222
GA_API const UT_StringHolder rest
const UT_Matrix3R & getRotateMatrix() const
Definition: KIN_Bone.h:106