00001
00002
00003
00004
00005
00006
00007
00008 #ifndef GLBHAND_H
00009 #define GLBHAND_H
00010
00011
00012 #include "glbarrettbase.h"
00013 #include "glbarrettfinger.h"
00014
00015 using namespace Wm3;
00016
00039 class GLBHand{
00040
00041 public:
00047 GLBHand();
00048
00054 ~GLBHand();
00055
00060 void initModell();
00061
00064 void initTriMesh();
00065
00071 void initGL();
00072
00078 void draw(GLenum mode = GL_RENDER);
00079
00085 void setSpread(const float &spread);
00086
00087 float spread() const;
00088
00096 void setForce(const int &finger, const double &force);
00097
00104 void setJoints(double *jointValues);
00105
00106
00112 GLBarrettFinger F1;
00118 GLBarrettFinger F2;
00124 GLBarrettFinger F3;
00125
00131 GLBarrettBase Base;
00132
00133 bool initialized() const;
00134 bool triMeshInitialized() const;
00135 bool glInitialized() const;
00136
00137
00138
00139 void generateTriMesh();
00140 void updateTriMesh();
00141
00142
00143
00144 NodePtr node();
00145 void setScale(const float scale);
00146 float scale() const;
00147
00148 protected:
00149
00153 void makeBaseList();
00154
00155
00156
00160 GLint BaseList;
00161
00166 float SpreadAngle;
00167
00168 bool ModelInitialized;
00169 bool TriMeshInitialized;
00170 bool GLInitialized;
00171
00172 float ScaleFactor;
00173
00174
00175 Wm3::TArray<Wm3::TriMesh*> *PartsMeshF1;
00176 Wm3::TArray<Wm3::TriMesh*> *PartsMeshF2;
00177 Wm3::TArray<Wm3::TriMesh*> *PartsMeshF3;
00178
00179
00180 NodePtr BarrettHandNode;
00181
00182 NodePtr BarrettHandF1Node;
00183 NodePtr BarrettHandF1NodeHelper;
00184
00185 NodePtr BarrettHandF2Node;
00186 NodePtr BarrettHandF2NodeHelper;
00187
00188 NodePtr BarrettHandF3Node;
00189
00190 NodePtr BarrettHandBaseNode;
00191 };
00192
00193
00194
00195
00196
00197 inline NodePtr GLBHand::node()
00198 {
00199 return BarrettHandNode;
00200 }
00201
00202
00203
00204
00205
00206 inline void GLBHand::updateTriMesh()
00207 {
00208 F1.updateTriMesh();
00209 F2.updateTriMesh();
00210 F3.updateTriMesh();
00211
00212 BarrettHandF1NodeHelper->Local.SetRotate(Matrix3f().FromAxisAngle(Vector3f::UNIT_Y, (float) (180.0-SpreadAngle)*DEGTORAD));
00213
00214 BarrettHandF2NodeHelper->Local.SetRotate(Matrix3f().FromAxisAngle(Vector3f::UNIT_Y, (float) (180.0+SpreadAngle)*DEGTORAD));
00215 }
00216
00217
00218
00219
00220
00221 inline float GLBHand::scale() const
00222 {
00223 return ScaleFactor;
00224 }
00225
00226
00227
00228
00229
00230 inline float GLBHand::spread() const
00231 {
00232 return SpreadAngle;
00233 }
00234
00235
00236
00237
00238 inline void GLBHand::setSpread(const GLfloat &spread)
00239 {
00240 SpreadAngle = spread;
00241 BarrettHandF1NodeHelper->Local.SetRotate(Matrix3f().FromAxisAngle(Vector3f::UNIT_Y, (float) (180.0-SpreadAngle)*DEGTORAD));
00242
00243 BarrettHandF2NodeHelper->Local.SetRotate(Matrix3f().FromAxisAngle(Vector3f::UNIT_Y, (float) (180.0+SpreadAngle)*DEGTORAD));
00244 }
00245
00246
00247
00248
00249 inline bool GLBHand::initialized() const
00250 {
00251 return ModelInitialized;
00252 }
00253
00254
00255
00256
00257 inline bool GLBHand::triMeshInitialized() const
00258 {
00259 return TriMeshInitialized;
00260 }
00261
00262
00263
00264
00265
00266 inline bool GLBHand::glInitialized() const
00267 {
00268 return GLInitialized;
00269 }
00270
00271
00272
00273
00274
00275 inline void GLBHand::setForce(const int &finger, const double &force)
00276 {
00277 switch(finger){
00278 case 1:
00279 F1.setForce(force);
00280 break;
00281 case 2:
00282 F2.setForce(force);
00283 break;
00284 case 3:
00285 F3.setForce(force);
00286 break;
00287 default:
00288
00289 break;
00290 }
00291
00292
00293 }
00294
00295
00296
00297
00298
00299 inline void GLBHand::setJoints(double *jointValues)
00300 {
00301 F1.setJoints((GLfloat)jointValues[0], (GLfloat)jointValues[1]);
00302 F2.setJoints((GLfloat)jointValues[2], (GLfloat)jointValues[3]);
00303 F3.setJoints((GLfloat)jointValues[4], (GLfloat)jointValues[5]);
00304 SpreadAngle = (GLfloat) jointValues[7];
00305 updateTriMesh();
00306 }
00307
00308 #endif //GLBARRETTHAND_H