iCub-main
bvhnodelefthand.h
Go to the documentation of this file.
1 /*
2  * bvhnodelefthand.h
3  */
4 
5 /*
6  * Copyright (C) 2009 RobotCub Consortium
7  * Author: Alessandro Scalzo alessandro.scalzo@iit.it
8  * CopyPolicy: Released under the terms of the GNU GPL v2.0.
9  *
10  * Based on:
11  *
12  * Qavimator
13  * Copyright (C) 2006 by Zi Ree *
14  * Zi Ree @ SecondLife *
15  * Released under the terms of the GNU GPL v2.0.
16  */
17 
18 #ifndef BVHNODELEFTHAND_H
19 #define BVHNODELEFTHAND_H
20 
21 #include "bvhnodeend.h"
22 
24 {
25 public:
26 
27  BVHNodeLEFTHAND(const QString& name,int enc,double a,double d,double alpha,double theta0,iCubMesh* mesh=0)
28  : BVHNodeEND(name,enc,a,d,alpha,theta0,mesh){ nEnc=enc; }
29 
30  void FingerSegment(double length)
31  {
32  length-=1.0;
33  gluDisk(cyl,0.0,5.0,16,16);
34  gluCylinder(cyl,5.0,5.0,length,16,16);
35  glTranslated(0.0,0.0,length);
36  gluDisk(cyl,0.0,5.0,16,16);
37  glTranslated(0.0,0.0,1.0);
38  }
39 
40  virtual void draw(double* encoders,BVHNode* pSelected)
41  {
42  glPushMatrix();
43 
44  glRotated(dTheta0+encoders[nEnc],0.0,0.0,1.0);
45  glTranslated(dA,0.0,dD);
46 
47  glRotated(dAlpha,1.0,0.0,0.0);
48 
49  drawArrows();
50 
51  glColor4f(0.2,0.2,0.2,1.0);
52  glBegin(GL_QUADS);
53  glNormal3d(0.0,0.0,1.0);
54  glVertex3d(-63.0,-12.0,16.0);
55  glNormal3d(0.0,0.0,1.0);
56  glVertex3d(15.0,-30.0,16.0);
57  glNormal3d(0.0,0.0,1.0);
58  glVertex3d(15.0,30.0,16.0);
59  glNormal3d(0.0,0.0,1.0);
60  glVertex3d(-63.0,12.0,16.0);
61  glNormal3d(0.0,0.0,-1.0);
62  glVertex3d(-63.0,-12.0,6.0);
63  glNormal3d(0.0,0.0,-1.0);
64  glVertex3d(15.0,-30.0,6.0);
65  glNormal3d(0.0,0.0,-1.0);
66  glVertex3d(15.0,30.0,6.0);
67  glNormal3d(0.0,0.0,-1.0);
68  glVertex3d(-63.0,12.0,6.0);
69 
70  glNormal3d(0.0,-1.0,0.0);
71  glVertex3d(-63.0,-12.0,16.0);
72  glNormal3d(0.0,-1.0,0.0);
73  glVertex3d(-63.0,-12.0,6.0);
74  glNormal3d(0.0,-1.0,0.0);
75  glVertex3d(15.0,-30.0,6.0);
76  glNormal3d(0.0,-1.0,0.0);
77  glVertex3d(15.0,-30.0,16.0);
78 
79  glNormal3d(0.0,1.0,0.0);
80  glVertex3d(15.0,30.0,16.0);
81  glNormal3d(0.0,1.0,0.0);
82  glVertex3d(15.0,30.0,6.0);
83  glNormal3d(0.0,1.0,0.0);
84  glVertex3d(-63.0,12.0,6.0);
85  glNormal3d(0.0,1.0,0.0);
86  glVertex3d(-63.0,12.0,16.0);
87  glEnd();
88 
89  glColor4f(0.5,0.5,0.5,1.0);
90 
91  //thumb
92  glPushMatrix();
93  glTranslated(-30.0,-7.5,5.0);
94  //glRotated(-75.0,0.0,0.0,1.0);
95  glRotated(-90.0,0.0,0.0,1.0);
96 
97  glRotated(110.0+encoders[nEnc+2],0.0,1.0,0.0);
98  FingerSegment(10.0);
99 
100  glRotated(-encoders[nEnc+3],1.0,0.0,0.0);
101  FingerSegment(20.0);
102 
103  glRotated(-encoders[nEnc+4],1.0,0.0,0.0);
104  FingerSegment(20.0);
105 
106  glRotated(-encoders[nEnc+4],1.0,0.0,0.0);
107  FingerSegment(20.0);
108  glPopMatrix();
109 
110  // middle
111  glPushMatrix();
112  glTranslated(15.0,-7.5,11.0);
113  glRotated(-10.0+0.1666*encoders[nEnc+1],0.0,0.0,1.0);
114  glRotated(90.0+encoders[nEnc+7],0.0,1.0,0.0);
115  FingerSegment(35.0);
116 
117  glRotated(encoders[nEnc+8],0.0,1.0,0.0);
118  FingerSegment(22.0);
119 
120  glRotated(encoders[nEnc+8],0.0,1.0,0.0);
121  FingerSegment(13.0);
122  glPopMatrix();
123 
124  // index
125  glPushMatrix();
126  glTranslated(15.0,-22.5,11.0);
127  glRotated(-30.0+0.5*encoders[nEnc+1],0.0,0.0,1.0);
128  glRotated(90.0+encoders[nEnc+5],0.0,1.0,0.0);
129  FingerSegment(31.0);
130 
131  glRotated(encoders[nEnc+6],0.0,1.0,0.0);
132  FingerSegment(19.0);
133 
134  glRotated(encoders[nEnc+6],0.0,1.0,0.0);
135  FingerSegment(12.0);
136  glPopMatrix();
137 
138  // ring
139  glPushMatrix();
140  glTranslated(15.0,7.5,11.0);
141  glRotated(10.0-0.1666*encoders[nEnc+1],0.0,0.0,1.0);
142  glRotated(90.0+encoders[nEnc+9],0.0,1.0,0.0);
143  FingerSegment(31.0);
144 
145  glRotated(encoders[nEnc+9],0.0,1.0,0.0);
146  FingerSegment(19.0);
147 
148  glRotated(encoders[nEnc+9],0.0,1.0,0.0);
149  FingerSegment(12.0);
150  glPopMatrix();
151 
152  // pinky
153  glPushMatrix();
154  glTranslated(15.0,22.5,11.0);
155  glRotated(30.0-0.5*encoders[nEnc+1],0.0,0.0,1.0);
156  glRotated(90.0+encoders[nEnc+9],0.0,1.0,0.0);
157  FingerSegment(27.0);
158 
159  glRotated(encoders[nEnc+9],0.0,1.0,0.0);
160  FingerSegment(17.0);
161 
162  glRotated(encoders[nEnc+9],0.0,1.0,0.0);
163  FingerSegment(10.0);
164  glPopMatrix();
165 
166  if (pMesh)
167  {
168  glColor4f(0.9,0.8,0.7,1.0);
169  pMesh->Draw();
170  }
171 
172  glPopMatrix();
173  }
174 };
175 
176 #endif
double dAlpha
Definition: bvhnodedh.h:105
double dTheta0
Definition: bvhnodedh.h:105
double dD
Definition: bvhnodedh.h:105
double dA
Definition: bvhnodedh.h:105
virtual void draw(double *encoders, BVHNode *pSelected)
BVHNodeLEFTHAND(const QString &name, int enc, double a, double d, double alpha, double theta0, iCubMesh *mesh=0)
void FingerSegment(double length)
const QString & name() const
Definition: bvhnode.h:221
iCubMesh * pMesh
Definition: bvhnode.h:286
int nEnc
Definition: bvhnode.h:285
void drawArrows()
Definition: bvhnode.h:265
GLUquadricObj * cyl
Definition: bvhnode.h:281
Definition: mesh.h:54
void Draw()
Definition: mesh.h:187