qtopengl_footbot.cpp
Go to the documentation of this file.
1 
7 #include "qtopengl_footbot.h"
8 #include "footbot_entity.h"
10 #include "footbot_turret_entity.h"
11 #include <argos3/core/simulator/entity/embodied_entity.h>
12 #include <argos3/core/utility/math/vector2.h>
13 #include <argos3/core/utility/math/vector3.h>
14 #include <argos3/plugins/simulator/entities/led_equipped_entity.h>
15 #include <argos3/plugins/simulator/entities/gripper_equipped_entity.h>
16 #include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h>
17 
18 namespace argos {
19 
20  /****************************************/
21  /****************************************/
22 
23  /* All measures are in meters */
24 
25  /* General */
26  static const Real INTER_MODULE_GAP = 0.0015f;
27  static const Real HEIGHT = 0.258f;
28  /* Wheel measures */
29  static const Real WHEEL_WIDTH = 0.022031354f;
30  static const Real HALF_WHEEL_WIDTH = WHEEL_WIDTH * 0.5f;
31  static const Real WHEEL_RADIUS = 0.029112741f;
32  static const Real WHEEL_DIAMETER = WHEEL_RADIUS * 2.0f;
33  static const Real INTERWHEEL_DISTANCE = 0.127f;
34  static const Real HALF_INTERWHEEL_DISTANCE = INTERWHEEL_DISTANCE * 0.5f;
35  /* Track measures */
36  static const Real INTERTRACK_DISTANCE = 0.064600514f;
37  static const Real HALF_INTERTRACK_DISTANCE = INTERTRACK_DISTANCE * 0.5f;
38  static const Real TRACK_WHEELS_DISTANCE = 0.100156677f;
39  static const Real HALF_TRACK_WHEELS_DISTANCE = TRACK_WHEELS_DISTANCE * 0.5f;
40  /* Base module measures */
41  static const Real BATTERY_SOCKET_ELEVATION = 0.006f;
42  static const Real BATTERY_SOCKET_LENGTH = 0.150302467f;
43  static const Real HALF_BATTERY_SOCKET_LENGTH = BATTERY_SOCKET_LENGTH * 0.5f;
44  static const Real BATTERY_SOCKET_WIDTH = 0.037600133f;
45  static const Real HALF_BATTERY_SOCKET_WIDTH = BATTERY_SOCKET_WIDTH * 0.5f;
46  static const Real BASE_MODULE_HEIGHT = 0.0055f;
47  static const Real BASE_MODULE_RADIUS = 0.085036758f;
48  static const Real PROXIMITY_SENSOR_HEIGHT = 0.004f; // unused
49  static const Real PROXIMITY_SENSOR_WIDTH = 0.007f; // unused
50  static const Real PROXIMITY_SENSOR_DEPTH = 0.0025f; // unused
51  /* Gripper module measures */
52  static const Real GRIPPER_MODULE_ELEVATION = BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER + BASE_MODULE_HEIGHT + INTER_MODULE_GAP;
53  static const Real GRIPPER_MODULE_HEIGHT = 0.027f;
54  static const Real GRIPPER_MODULE_HALF_HEIGHT = GRIPPER_MODULE_HEIGHT * 0.5f;
55  static const Real GRIPPER_MODULE_INNER_RADIUS = 0.069f;
56  static const Real GRIPPER_MODULE_BARRIER_HEIGHT = 0.0075f;
57  static const Real GRIPPER_MECHANICS_LENGTH = 0.026094485f;
58  static const Real GRIPPER_MECHANICS_WIDTH = 0.02f;
59  static const Real GRIPPER_MECHANICS_HALF_WIDTH = GRIPPER_MECHANICS_WIDTH * 0.5f;
60  static const Real GRIPPER_CLAW_LENGTH = 0.01f;
61  static const Real GRIPPER_CLAW_WIDTH = 0.013f;
62  static const Real GRIPPER_CLAW_HALF_WIDTH = GRIPPER_CLAW_WIDTH * 0.5f;
63  static const Real GRIPPER_CLAW_OFFSET = GRIPPER_MODULE_INNER_RADIUS + GRIPPER_MECHANICS_LENGTH;
64  static const Real GRIPPER_CLAW_ELEVATION = GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HALF_HEIGHT;
65  /* RAB measures */
66  static const Real RAB_ELEVATION = GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT + INTER_MODULE_GAP;
67  static const Real RAB_HEIGHT = 0.0086f;
68  static const Real RAB_MAX_RADIUS = 0.08f;
69  static const Real RAB_MIN_RADIUS = 0.075f;
70  /* Distance scanner measures */
71  static const Real DISTANCE_SCANNER_ELEVATION = RAB_ELEVATION + RAB_HEIGHT;
72  static const Real DISTANCE_SCANNER_RADIUS = 0.05f;
73  static const Real DISTANCE_SCANNER_HEIGHT = 0.0235f;
74  static const Real DISTANCE_SCANNER_SENSOR_WIDTH = 0.035858477f;
75  static const Real DISTANCE_SCANNER_SENSOR_HALF_WIDTH = DISTANCE_SCANNER_SENSOR_WIDTH * 0.5f;
76  static const Real DISTANCE_SCANNER_SENSOR_HEIGHT = 0.021124933f;
77  static const Real DISTANCE_SCANNER_SENSOR_DEPTH = 0.018f;
78  /* iMX module */
79  static const Real IMX_MODULE_ELEVATION = DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT;
80  static const Real IMX_MODULE_RADIUS = 0.065f;
81  static const Real IMX_MODULE_HEIGHT = 0.010199866f;
82  /* Beacon */
83  static const Real BEACON_ELEVATION = IMX_MODULE_ELEVATION + IMX_MODULE_HEIGHT;
84  static const Real BEACON_RADIUS = 0.021f;
85  static const Real BEACON_HEIGHT = 0.0201f;
86  /* Camera */
87  static const Real CAMERA_ELEVATION = BEACON_ELEVATION + BEACON_HEIGHT;
88  static const Real CAMERA_RADIUS = BEACON_RADIUS;
89  static const Real CAMERA_HEIGHT = 0.104f;
90 
91  /****************************************/
92  /****************************************/
93 
95  m_unVertices(40),
96  m_fLEDAngleSlice(360.0f / 12.0f) {
97  /* Reserve the needed display lists */
98  m_unLists = glGenLists(13);
99 
100  /* Assign indices for better referencing (later) */
101  m_unBasicWheelList = m_unLists;
102  m_unWheelList = m_unLists + 1;
103  m_unTrackList = m_unLists + 2;
104  m_unBaseList = m_unLists + 3;
105  m_unGrippableSliceList = m_unLists + 4;
106  m_unGripperMechanicsList = m_unLists + 5;
107  m_unGripperClawList = m_unLists + 6;
108  m_unRABList = m_unLists + 7;
109  m_unDistanceScannerSensorList = m_unLists + 8;
110  m_unDistanceScannerList = m_unLists + 9;
111  m_unIMXList = m_unLists + 10;
112  m_unBeaconList = m_unLists + 11;
113  m_unCameraList = m_unLists + 12;
114 
115  /* Create the materialless wheel display list */
116  glNewList(m_unBasicWheelList, GL_COMPILE);
117  MakeWheel();
118  glEndList();
119 
120  /* Create the wheel display list */
121  glNewList(m_unWheelList, GL_COMPILE);
122  RenderWheel();
123  glEndList();
124 
125  /* Create the track display list */
126  glNewList(m_unTrackList, GL_COMPILE);
127  RenderTrack();
128  glEndList();
129 
130  /* Create the base module display list */
131  glNewList(m_unBaseList, GL_COMPILE);
132  RenderBase();
133  glEndList();
134 
135  /* Create the grippable slice display list */
136  glNewList(m_unGrippableSliceList, GL_COMPILE);
138  glEndList();
139 
140  /* Create the gripper mechanics display list */
141  glNewList(m_unGripperMechanicsList, GL_COMPILE);
143  glEndList();
144 
145  /* Create the gripper claw display list */
146  glNewList(m_unGripperClawList, GL_COMPILE);
148  glEndList();
149 
150  /* Create the gripper claw display list */
151  glNewList(m_unRABList, GL_COMPILE);
152  RenderRAB();
153  glEndList();
154 
155  /* Create the single distance scanner sensor display list */
156  glNewList(m_unDistanceScannerSensorList, GL_COMPILE);
158  glEndList();
159 
160  /* Create the distance scanner display list */
161  glNewList(m_unDistanceScannerList, GL_COMPILE);
163  glEndList();
164 
165  /* Create the iMX display list */
166  glNewList(m_unIMXList, GL_COMPILE);
167  RenderIMX();
168  glEndList();
169 
170  /* Create the beacon display list */
171  glNewList(m_unBeaconList, GL_COMPILE);
172  RenderBeacon();
173  glEndList();
174 
175  /* Create the camera display list */
176  glNewList(m_unCameraList, GL_COMPILE);
177  RenderCamera();
178  glEndList();
179  }
180 
181  /****************************************/
182  /****************************************/
183 
185  glDeleteLists(m_unLists, 13);
186  }
187 
188  /****************************************/
189  /****************************************/
190 
192  /* Place the wheels */
193  glPushMatrix();
194  glTranslated(0.0f, HALF_INTERWHEEL_DISTANCE, 0.0f);
195  glCallList(m_unWheelList);
196  glPopMatrix();
197  glPushMatrix();
198  glTranslated(0.0f, -HALF_INTERWHEEL_DISTANCE, 0.0f);
199  glCallList(m_unWheelList);
200  glPopMatrix();
201  /* Place the tracks */
202  glPushMatrix();
203  glTranslated(0.0f, HALF_INTERTRACK_DISTANCE, 0.0f);
204  glCallList(m_unTrackList);
205  glPopMatrix();
206  glPushMatrix();
207  glTranslated(0.0f, -HALF_INTERTRACK_DISTANCE, 0.0f);
208  glCallList(m_unTrackList);
209  glPopMatrix();
210  /* Place the tracks */
211  glCallList(m_unBaseList);
212  /* Place the gripper module */
213  glPushMatrix();
214  /* Read gripper orientation from footbot entity */
215  GLdouble fGripperOrientation = ToDegrees(c_entity.GetTurretEntity().GetRotation()).GetValue();
216  glRotated(fGripperOrientation, 0.0f, 0.0f, 1.0f);
217  /* Place the grippable part of the gripper module (LEDs) */
218  glPushMatrix();
219  CLEDEquippedEntity& cLEDEquippedEntity = c_entity.GetLEDEquippedEntity();
220  for(UInt32 i = 0; i < 12; i++) {
221  const CColor& cColor = cLEDEquippedEntity.GetLED(i).GetColor();
222  glRotated(m_fLEDAngleSlice, 0.0f, 0.0f, 1.0f);
223  SetLEDMaterial(cColor.GetRed() / 255.0f,
224  cColor.GetGreen() / 255.0f,
225  cColor.GetBlue() / 255.0f);
226  glCallList(m_unGrippableSliceList);
227  }
228  glPopMatrix();
229  /* Place the gripper mechanics */
230  glCallList(m_unGripperMechanicsList);
231  /* Place the gripper claws */
232  /* Read the gripper aperture from footbot entity */
233  GLdouble fGripperAperture = c_entity.GetGripperEquippedEntity().GetLockState() * 90.0f;
234  glTranslated(GRIPPER_CLAW_OFFSET, 0.0f, GRIPPER_CLAW_ELEVATION);
235  glPushMatrix();
236  glRotated(fGripperAperture, 0.0f, 1.0f, 0.0f);
237  glCallList(m_unGripperClawList);
238  glPopMatrix();
239  glPushMatrix();
240  glRotated(-fGripperAperture, 0.0f, 1.0f, 0.0f);
241  glCallList(m_unGripperClawList);
242  glPopMatrix();
243  glPopMatrix();
244  /* Place the RAB */
245  glCallList(m_unRABList);
246  /* Place the distance scanner */
247  glCallList(m_unDistanceScannerList);
248  glPushMatrix();
249  /* Read dist scanner orientation from footbot entity */
250  GLdouble fDistanceScannerOrientation = ToDegrees(c_entity.GetDistanceScannerEquippedEntity().GetRotation()).GetValue();
251  glRotated(fDistanceScannerOrientation, 0.0f, 0.0f, 1.0f);
252  glCallList(m_unDistanceScannerSensorList);
253  glRotated(90.0f, 0.0f, 0.0f, 1.0f);
254  glCallList(m_unDistanceScannerSensorList);
255  glRotated(90.0f, 0.0f, 0.0f, 1.0f);
256  glCallList(m_unDistanceScannerSensorList);
257  glRotated(90.0f, 0.0f, 0.0f, 1.0f);
258  glCallList(m_unDistanceScannerSensorList);
259  glPopMatrix();
260  /* Place the iMX module */
261  glCallList(m_unIMXList);
262  /* Place the beacon */
263  const CColor& cBeaconColor = cLEDEquippedEntity.GetLED(12).GetColor();
264  SetLEDMaterial(cBeaconColor.GetRed() / 255.0f,
265  cBeaconColor.GetGreen() / 255.0f,
266  cBeaconColor.GetBlue() / 255.0f);
267  glCallList(m_unBeaconList);
268  /* Place the camera */
269  glCallList(m_unCameraList);
270  }
271 
272  /****************************************/
273  /****************************************/
274 
276  /* Right side */
277  CVector2 cVertex(WHEEL_RADIUS, 0.0f);
278  CRadians cAngle(CRadians::TWO_PI / m_unVertices);
279  CVector3 cNormal(-1.0f, -1.0f, 0.0f);
280  cNormal.Normalize();
281  glBegin(GL_POLYGON);
282  for(GLuint i = 0; i <= m_unVertices; i++) {
283  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
284  glVertex3d(cVertex.GetX(), -HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
285  cVertex.Rotate(cAngle);
286  cNormal.RotateY(cAngle);
287  }
288  glEnd();
289  /* Left side */
290  cVertex.Set(WHEEL_RADIUS, 0.0f);
291  cNormal.Set(-1.0f, 1.0f, 0.0f);
292  cNormal.Normalize();
293  cAngle = -cAngle;
294  glBegin(GL_POLYGON);
295  for(GLuint i = 0; i <= m_unVertices; i++) {
296  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
297  glVertex3d(cVertex.GetX(), HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
298  cVertex.Rotate(cAngle);
299  cNormal.RotateY(cAngle);
300  }
301  glEnd();
302  /* Tire */
303  cNormal.Set(1.0f, 0.0f, 0.0f);
304  cVertex.Set(WHEEL_RADIUS, 0.0f);
305  cAngle = -cAngle;
306  glBegin(GL_QUAD_STRIP);
307  for(GLuint i = 0; i <= m_unVertices; i++) {
308  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
309  glVertex3d(cVertex.GetX(), -HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
310  glVertex3d(cVertex.GetX(), HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
311  cVertex.Rotate(cAngle);
312  cNormal.RotateY(cAngle);
313  }
314  glEnd();
315  }
316 
317  /****************************************/
318  /****************************************/
319 
321  const GLfloat pfColor[] = { 1.0f, 1.0f, 1.0f, 1.0f };
322  const GLfloat pfSpecular[] = { 0.9f, 0.9f, 0.9f, 1.0f };
323  const GLfloat pfShininess[] = { 100.0f };
324  const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
325  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
326  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
327  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
328  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
329  }
330 
331  /****************************************/
332  /****************************************/
333 
335  const GLfloat pfColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
336  const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
337  const GLfloat pfShininess[] = { 0.0f };
338  const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
339  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
340  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
341  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
342  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
343  }
344 
345  /****************************************/
346  /****************************************/
347 
349  const GLfloat pfColor[] = { 0.0f, 0.0f, 1.0f, 1.0f };
350  const GLfloat pfSpecular[] = { 0.5f, 0.5f, 1.0f, 1.0f };
351  const GLfloat pfShininess[] = { 10.0f };
352  const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
353  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
354  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
355  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
356  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
357  }
358 
359  /****************************************/
360  /****************************************/
361 
362  void CQTOpenGLFootBot::SetLEDMaterial(GLfloat f_red, GLfloat f_green, GLfloat f_blue) {
363  const GLfloat pfColor[] = { f_red, f_green, f_blue, 1.0f };
364  const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
365  const GLfloat pfShininess[] = { 0.0f };
366  const GLfloat pfEmission[] = { f_red, f_green, f_blue, 1.0f };
367  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
368  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
369  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
370  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
371  }
372 
373  /****************************************/
374  /****************************************/
375 
377  /* Set material */
379  /* Right side */
380  CVector2 cVertex(WHEEL_RADIUS, 0.0f);
381  CRadians cAngle(CRadians::TWO_PI / m_unVertices);
382  CVector3 cNormal(-1.0f, -1.0f, 0.0f);
383  cNormal.Normalize();
384  glBegin(GL_POLYGON);
385  for(GLuint i = 0; i <= m_unVertices; i++) {
386  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
387  glVertex3d(cVertex.GetX(), -HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
388  cVertex.Rotate(cAngle);
389  cNormal.RotateY(cAngle);
390  }
391  glEnd();
392  /* Left side */
393  cVertex.Set(WHEEL_RADIUS, 0.0f);
394  cAngle = -cAngle;
395  cNormal.Set(-1.0f, 1.0f, 0.0f);
396  cNormal.Normalize();
397  glBegin(GL_POLYGON);
398  for(GLuint i = 0; i <= m_unVertices; i++) {
399  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
400  glVertex3d(cVertex.GetX(), HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
401  cVertex.Rotate(cAngle);
402  cNormal.RotateY(cAngle);
403  }
404  glEnd();
405  /* Tire */
407  cNormal.Set(1.0f, 0.0f, 0.0f);
408  cVertex.Set(WHEEL_RADIUS, 0.0f);
409  cAngle = -cAngle;
410  glBegin(GL_QUAD_STRIP);
411  for(GLuint i = 0; i <= m_unVertices; i++) {
412  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
413  glVertex3d(cVertex.GetX(), -HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
414  glVertex3d(cVertex.GetX(), HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
415  cVertex.Rotate(cAngle);
416  cNormal.RotateY(cAngle);
417  }
418  glEnd();
419  }
420 
421  /****************************************/
422  /****************************************/
423 
425  /* Set material */
427  /* Place two basic wheels */
428  glPushMatrix();
429  glTranslated(HALF_TRACK_WHEELS_DISTANCE, 0.0f, 0.0f);
430  glCallList(m_unBasicWheelList);
431  glPopMatrix();
432  glPushMatrix();
433  glTranslated(-HALF_TRACK_WHEELS_DISTANCE, 0.0f, 0.0f);
434  glCallList(m_unBasicWheelList);
435  glPopMatrix();
436  /* Render the track itself */
437  /* Set material */
439  glEnable(GL_POLYGON_OFFSET_FILL); // Correct flickering due to overlapping surfaces
440  glPolygonOffset(-0.1f, 1.0f); // Correct flickering due to overlapping surfaces
441  /* Top part */
442  glBegin(GL_POLYGON);
443  glVertex3d(-HALF_TRACK_WHEELS_DISTANCE, -HALF_WHEEL_WIDTH, WHEEL_DIAMETER);
444  glVertex3d( HALF_TRACK_WHEELS_DISTANCE, -HALF_WHEEL_WIDTH, WHEEL_DIAMETER);
445  glVertex3d( HALF_TRACK_WHEELS_DISTANCE, HALF_WHEEL_WIDTH, WHEEL_DIAMETER);
446  glVertex3d(-HALF_TRACK_WHEELS_DISTANCE, HALF_WHEEL_WIDTH, WHEEL_DIAMETER);
447  glEnd();
448  /* Bottom part */
449  glBegin(GL_POLYGON);
450  glVertex3d(-HALF_TRACK_WHEELS_DISTANCE, -HALF_WHEEL_WIDTH, 0.0f);
451  glVertex3d( HALF_TRACK_WHEELS_DISTANCE, -HALF_WHEEL_WIDTH, 0.0f);
452  glVertex3d( HALF_TRACK_WHEELS_DISTANCE, HALF_WHEEL_WIDTH, 0.0f);
453  glVertex3d(-HALF_TRACK_WHEELS_DISTANCE, HALF_WHEEL_WIDTH, 0.0f);
454  glEnd();
455  /* Round parts */
456  CVector2 cVertex(0.0f, WHEEL_RADIUS);
457  CVector2 cNormal(0.0f, 1.0f);
458  CRadians cAngle(CRadians::TWO_PI / m_unVertices);
459  /* Front */
460  glBegin(GL_QUAD_STRIP);
461  for(GLuint i = 0; i <= m_unVertices / 2; i++) {
462  glNormal3d(cNormal.GetX(), 0.0f, cNormal.GetY());
463  glVertex3d(-HALF_TRACK_WHEELS_DISTANCE + cVertex.GetX(), -HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
464  glVertex3d(-HALF_TRACK_WHEELS_DISTANCE + cVertex.GetX(), HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
465  cVertex.Rotate(cAngle);
466  cNormal.Rotate(cAngle);
467  }
468  glEnd();
469  /* Back */
470  glBegin(GL_QUAD_STRIP);
471  for(GLuint i = 0; i <= m_unVertices / 2; i++) {
472  glNormal3d(cNormal.GetX(), 0.0f, cNormal.GetY());
473  glVertex3d(HALF_TRACK_WHEELS_DISTANCE + cVertex.GetX(), -HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
474  glVertex3d(HALF_TRACK_WHEELS_DISTANCE + cVertex.GetX(), HALF_WHEEL_WIDTH, WHEEL_RADIUS + cVertex.GetY());
475  cVertex.Rotate(cAngle);
476  cNormal.Rotate(cAngle);
477  }
478  glEnd();
479  glDisable(GL_POLYGON_OFFSET_FILL); // Not needed anymore
480  }
481 
482  /****************************************/
483  /****************************************/
484 
486  /* Battery socket */
487  /* Set material */
489  /* This part covers the top and bottom faces (parallel to XY) */
490  glBegin(GL_QUADS);
491  /* Bottom face */
492  glNormal3d(0.0f, 0.0f, -1.0f);
493  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
494  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
495  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
496  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
497  /* Top face */
498  glNormal3d(0.0f, 0.0f, 1.0f);
499  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
500  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
501  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
502  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
503  glEnd();
504  /* This part covers the faces (South, East, North, West) */
505  glBegin(GL_QUAD_STRIP);
506  /* Starting side */
507  glNormal3d(-1.0f, 0.0f, 0.0f);
508  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
509  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
510  /* South face */
511  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
512  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
513  /* East face */
514  glNormal3d(0.0f, -1.0f, 0.0f);
515  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
516  glVertex3d( HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
517  /* North face */
518  glNormal3d(1.0f, 0.0f, 0.0f);
519  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
520  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
521  /* West face */
522  glNormal3d(0.0f, 1.0f, 0.0f);
523  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
524  glVertex3d(-HALF_BATTERY_SOCKET_LENGTH, -HALF_BATTERY_SOCKET_WIDTH, BATTERY_SOCKET_ELEVATION);
525  glEnd();
526  /* Circuit board */
527  CVector2 cVertex(BASE_MODULE_RADIUS, 0.0f);
528  CRadians cAngle(-CRadians::TWO_PI / m_unVertices);
529  /* Bottom part */
530  glBegin(GL_POLYGON);
531  glNormal3d(0.0f, 0.0f, -1.0f);
532  for(GLuint i = 0; i <= m_unVertices; i++) {
533  glVertex3d(cVertex.GetX(), cVertex.GetY(), BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
534  cVertex.Rotate(cAngle);
535  }
536  glEnd();
537  /* Side surface */
538  cAngle = -cAngle;
539  CVector2 cNormal(1.0f, 0.0f);
540  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
541  glBegin(GL_QUAD_STRIP);
542  for(GLuint i = 0; i <= m_unVertices; i++) {
543  glNormal3d(cNormal.GetX(), cNormal.GetY(), 0.0f);
544  glVertex3d(cVertex.GetX(), cVertex.GetY(), BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER + BASE_MODULE_HEIGHT);
545  glVertex3d(cVertex.GetX(), cVertex.GetY(), BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER);
546  cVertex.Rotate(cAngle);
547  cNormal.Rotate(cAngle);
548  }
549  glEnd();
550  /* Top part */
551  /* Set material */
553  glBegin(GL_POLYGON);
554  glNormal3d(0.0f, 0.0f, 1.0f);
555  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
556  for(GLuint i = 0; i <= m_unVertices; i++) {
557  glVertex3d(cVertex.GetX(), cVertex.GetY(), BATTERY_SOCKET_ELEVATION + WHEEL_DIAMETER + BASE_MODULE_HEIGHT);
558  cVertex.Rotate(cAngle);
559  }
560  glEnd();
561  }
562 
563  /****************************************/
564  /****************************************/
565 
567  glDisable(GL_CULL_FACE); // This way we can see both faces of the grippable slice
568  /* Bottom part */
569  CVector2 cVertex(BASE_MODULE_RADIUS, 0.0f);
570  cVertex.Rotate(-CRadians::TWO_PI / 12);
571  CRadians cAngle(CRadians::TWO_PI / (m_unVertices * 12));
572  glBegin(GL_TRIANGLE_FAN);
573  glNormal3d(0.0f, 0.0f, -1.0f);
574  glVertex3d(0.0f, 0.0f, GRIPPER_MODULE_ELEVATION);
575  for(GLuint i = 0; i <= m_unVertices; i++) {
576  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION);
577  cVertex.Rotate(cAngle);
578  }
579  glEnd();
580  cAngle = -CRadians::TWO_PI / (m_unVertices * 12);
581  /* Side barrier surface (bottom) */
582  CVector2 cNormal(1.0f, 0.0f);
583  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
584  glBegin(GL_QUAD_STRIP);
585  for(GLuint i = 0; i <= m_unVertices; i++) {
586  glNormal3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
587  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_BARRIER_HEIGHT);
588  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION);
589  cVertex.Rotate(cAngle);
590  cNormal.Rotate(cAngle);
591  }
592  glEnd();
593  /* Side barrier surface (top) */
594  cNormal.Set(1.0f, 0.0f);
595  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
596  glBegin(GL_QUAD_STRIP);
597  for(GLuint i = 0; i <= m_unVertices; i++) {
598  glNormal3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
599  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
600  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT - GRIPPER_MODULE_BARRIER_HEIGHT);
601  cVertex.Rotate(cAngle);
602  cNormal.Rotate(cAngle);
603  }
604  glEnd();
605  /* Internal rod (bottom) */
606  cNormal.Set(BASE_MODULE_RADIUS - GRIPPER_MODULE_INNER_RADIUS,
607  GRIPPER_MODULE_HALF_HEIGHT);
608  cNormal.Normalize();
609  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
610  CVector2 cVertex2(GRIPPER_MODULE_INNER_RADIUS, 0.0f);
611  glBegin(GL_QUAD_STRIP);
612  for(GLuint i = 0; i <= m_unVertices; i++) {
613  glNormal3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
614  glVertex3d(cVertex2.GetX(), cVertex2.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HALF_HEIGHT);
615  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION);
616  cVertex.Rotate(cAngle);
617  cVertex2.Rotate(cAngle);
618  cNormal.Rotate(cAngle);
619  }
620  glEnd();
621  /* Internal rod (top) */
622  cNormal.Set( BASE_MODULE_RADIUS - GRIPPER_MODULE_INNER_RADIUS,
623  -GRIPPER_MODULE_HALF_HEIGHT);
624  cNormal.Normalize();
625  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
626  cVertex2.Set(GRIPPER_MODULE_INNER_RADIUS, 0.0f);
627  glBegin(GL_QUAD_STRIP);
628  for(GLuint i = 0; i <= m_unVertices; i++) {
629  glNormal3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
630  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
631  glVertex3d(cVertex2.GetX(), cVertex2.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HALF_HEIGHT);
632  cVertex.Rotate(cAngle);
633  cVertex2.Rotate(cAngle);
634  cNormal.Rotate(cAngle);
635  }
636  glEnd();
637  /* Top part */
638  cVertex.Set(BASE_MODULE_RADIUS, 0.0f);
639  glBegin(GL_TRIANGLE_FAN);
640  glNormal3d(0.0f, 0.0f, 1.0f);
641  glVertex3d(0.0f, 0.0f, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
642  for(GLuint i = 0; i <= m_unVertices; i++) {
643  glVertex3d(cVertex.GetX(), cVertex.GetY(), GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
644  cVertex.Rotate(cAngle);
645  }
646  glEnd();
647  glEnable(GL_CULL_FACE); // Back to normal setting: cull back faces
648  }
649 
650  /****************************************/
651  /****************************************/
652 
654  /* Set material */
655  const GLfloat pfColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
656  const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
657  const GLfloat pfShininess[] = { 0.0f };
658  const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
659  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
660  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
661  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
662  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
663  /* This part covers the top and bottom faces (parallel to XY) */
664  glEnable(GL_POLYGON_OFFSET_FILL); // Correct flickering due to overlapping surfaces
665  glPolygonOffset(-0.1f, 1.0f); // Correct flickering due to overlapping surfaces
666  glBegin(GL_QUADS);
667  /* Bottom face */
668  glNormal3d(0.0f, 0.0f, -1.0f);
669  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
670  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
671  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
672  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
673  /* Top face */
674  glNormal3d(0.0f, 0.0f, 1.0f);
675  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
676  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
677  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
678  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
679  glEnd();
680  glDisable(GL_POLYGON_OFFSET_FILL); // Not needed anymore
681  /* This part covers the faces (South, East, North, West) */
682  glBegin(GL_QUAD_STRIP);
683  glNormal3d(0.0f, -1.0f, 0.0f);
684  /* Starting vertex */
685  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
686  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
687  /* East face */
688  glNormal3d(1.0f, 0.0f, 0.0f);
689  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
690  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, -GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
691  /* North face */
692  glNormal3d(0.0f, 1.0f, 0.0f);
693  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
694  glVertex3d(GRIPPER_MECHANICS_LENGTH + GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
695  /* West face */
696  glNormal3d(-1.0f, 0.0f, 0.0f);
697  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION + GRIPPER_MODULE_HEIGHT);
698  glVertex3d( GRIPPER_MODULE_INNER_RADIUS, GRIPPER_MECHANICS_HALF_WIDTH, GRIPPER_MODULE_ELEVATION);
699  glEnd();
700  }
701 
702  /****************************************/
703  /****************************************/
704 
706  /* Set material */
707  const GLfloat pfColor[] = { 0.5f, 0.5f, 0.5f, 1.0f };
708  const GLfloat pfSpecular[] = { 0.5f, 0.5f, 0.5f, 1.0f };
709  const GLfloat pfShininess[] = { 10.0f };
710  const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
711  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
712  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
713  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
714  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
715  /* Draw the claw */
716  glDisable(GL_CULL_FACE); // In this way, we can see both sides of the claw
717  glNormal3d(0.0f, 0.0f, 1.0f);
718  glBegin(GL_QUADS);
719  glVertex3d( 0.0f, GRIPPER_CLAW_HALF_WIDTH, 0.0f);
720  glVertex3d( 0.0f, -GRIPPER_CLAW_HALF_WIDTH, 0.0f);
721  glVertex3d(GRIPPER_CLAW_LENGTH, -GRIPPER_CLAW_HALF_WIDTH, 0.0f);
722  glVertex3d(GRIPPER_CLAW_LENGTH, GRIPPER_CLAW_HALF_WIDTH, 0.0f);
723  glEnd();
724  glEnable(GL_CULL_FACE); // Restore back face culling
725  }
726 
727  /****************************************/
728  /****************************************/
729 
731  /* Set material */
733  /* Bottom part */
734  CVector2 cVertex(RAB_MAX_RADIUS, 0.0f);
735  CRadians cAngle(-CRadians::TWO_PI / m_unVertices);
736  glBegin(GL_POLYGON);
737  glNormal3d(0.0f, 0.0f, -1.0f);
738  for(GLuint i = 0; i <= m_unVertices; i++) {
739  glVertex3d(cVertex.GetX(), cVertex.GetY(), RAB_ELEVATION);
740  cVertex.Rotate(cAngle);
741  }
742  glEnd();
743  /* Side surface */
744  cAngle = -cAngle;
745  CVector3 cNormal(RAB_MAX_RADIUS - RAB_MIN_RADIUS, 0.0f, RAB_HEIGHT);
746  cNormal.Normalize();
747  cVertex.Set(RAB_MAX_RADIUS, 0.0f);
748  CVector2 cVertex2(RAB_MIN_RADIUS, 0.0f);
749  glBegin(GL_QUAD_STRIP);
750  for(GLuint i = 0; i <= m_unVertices; i++) {
751  glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
752  glVertex3d(cVertex2.GetX(), cVertex2.GetY(), RAB_ELEVATION + RAB_HEIGHT);
753  glVertex3d(cVertex.GetX(), cVertex.GetY(), RAB_ELEVATION);
754  cVertex.Rotate(cAngle);
755  cVertex2.Rotate(cAngle);
756  cNormal.RotateZ(cAngle);
757  }
758  glEnd();
759  /* Top part */
760  /* Set material */
762  cVertex.Set(RAB_MIN_RADIUS, 0.0f);
763  glBegin(GL_POLYGON);
764  glNormal3d(0.0f, 0.0f, 1.0f);
765  for(GLuint i = 0; i <= m_unVertices; i++) {
766  glVertex3d(cVertex.GetX(), cVertex.GetY(), RAB_ELEVATION + RAB_HEIGHT);
767  cVertex.Rotate(cAngle);
768  }
769  glEnd();
770  }
771 
772  /****************************************/
773  /****************************************/
774 
776  /* Set material */
777  const GLfloat pfColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
778  const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
779  const GLfloat pfShininess[] = { 0.0f };
780  const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
781  glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
782  glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
783  glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
784  glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
785  /* This part covers the top and bottom faces (parallel to XY) */
786  glBegin(GL_QUADS);
787  /* Bottom face */
788  glNormal3d(0.0f, 0.0f, -1.0f);
789  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
790  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
791  glVertex3d( DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
792  glVertex3d( DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
793  /* Top face */
794  glNormal3d(0.0f, 0.0f, 1.0f);
795  glVertex3d( DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
796  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
797  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
798  glVertex3d( DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
799  glEnd();
800  glDisable(GL_POLYGON_OFFSET_FILL); // Not needed anymore
801  /* This part covers the faces (South, East, North, West) */
802  glBegin(GL_QUAD_STRIP);
803  glNormal3d(0.0f, -1.0f, 0.0f);
804  /* Starting vertex */
805  glVertex3d( DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
806  glVertex3d( DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
807  /* South face */
808  glVertex3d( DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
809  glVertex3d( DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
810  /* East face */
811  glNormal3d(1.0f, 0.0f, 0.0f);
812  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
813  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, -DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
814  /* North face */
815  glNormal3d(0.0f, 1.0f, 0.0f);
816  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
817  glVertex3d(DISTANCE_SCANNER_SENSOR_DEPTH + DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
818  /* West face */
819  glNormal3d(-1.0f, 0.0f, 0.0f);
820  glVertex3d( DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
821  glVertex3d( DISTANCE_SCANNER_RADIUS, DISTANCE_SCANNER_SENSOR_HALF_WIDTH, DISTANCE_SCANNER_ELEVATION);
822  glEnd();
823  }
824 
825  /****************************************/
826  /****************************************/
827 
829  /* Set material */
831  /* Draw only side surface */
832  CVector2 cVertex(DISTANCE_SCANNER_RADIUS, 0.0f);
833  CRadians cAngle(CRadians::TWO_PI / m_unVertices);
834  CVector2 cNormal(1.0f, 0.0f);
835  glBegin(GL_QUAD_STRIP);
836  for(GLuint i = 0; i <= m_unVertices; i++) {
837  glNormal3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
838  glVertex3d(cVertex.GetX(), cVertex.GetY(), DISTANCE_SCANNER_ELEVATION + DISTANCE_SCANNER_HEIGHT);
839  glVertex3d(cVertex.GetX(), cVertex.GetY(), DISTANCE_SCANNER_ELEVATION);
840  cVertex.Rotate(cAngle);
841  cNormal.Rotate(cAngle);
842  }
843  glEnd();
844  }
845 
846  /****************************************/
847  /****************************************/
848 
850  /* Set material */
852  CVector2 cVertex(IMX_MODULE_RADIUS, 0.0f);
853  CRadians cAngle(-CRadians::TWO_PI / m_unVertices);
854  /* Bottom part */
855  glBegin(GL_POLYGON);
856  glNormal3d(0.0f, 0.0f, -1.0f);
857  for(GLuint i = 0; i <= m_unVertices; i++) {
858  glVertex3d(cVertex.GetX(), cVertex.GetY(), IMX_MODULE_ELEVATION);
859  cVertex.Rotate(cAngle);
860  }
861  glEnd();
862  /* Side surface */
863  cAngle = -cAngle;
864  CVector2 cNormal(1.0f, 0.0f);
865  cVertex.Set(IMX_MODULE_RADIUS, 0.0f);
866  glBegin(GL_QUAD_STRIP);
867  for(GLuint i = 0; i <= m_unVertices; i++) {
868  glNormal3d(cNormal.GetX(), cNormal.GetY(), 0.0f);
869  glVertex3d(cVertex.GetX(), cVertex.GetY(), IMX_MODULE_ELEVATION + IMX_MODULE_HEIGHT);
870  glVertex3d(cVertex.GetX(), cVertex.GetY(), IMX_MODULE_ELEVATION);
871  cVertex.Rotate(cAngle);
872  cNormal.Rotate(cAngle);
873  }
874  glEnd();
875  /* Top part */
876  /* Set material */
878  glBegin(GL_POLYGON);
879  glNormal3d(0.0f, 0.0f, 1.0f);
880  cVertex.Set(IMX_MODULE_RADIUS, 0.0f);
881  for(GLuint i = 0; i <= m_unVertices; i++) {
882  glVertex3d(cVertex.GetX(), cVertex.GetY(), IMX_MODULE_ELEVATION + IMX_MODULE_HEIGHT);
883  cVertex.Rotate(cAngle);
884  }
885  glEnd();
886  }
887 
888  /****************************************/
889  /****************************************/
890 
892  CVector2 cVertex(BEACON_RADIUS, 0.0f);
893  CRadians cAngle(-CRadians::TWO_PI / m_unVertices);
894  /* Bottom part */
895  glBegin(GL_POLYGON);
896  glNormal3d(0.0f, 0.0f, -1.0f);
897  for(GLuint i = 0; i <= m_unVertices; i++) {
898  glVertex3d(cVertex.GetX(), cVertex.GetY(), BEACON_ELEVATION);
899  cVertex.Rotate(cAngle);
900  }
901  glEnd();
902  /* Side surface */
903  cAngle = -cAngle;
904  CVector2 cNormal(1.0f, 0.0f);
905  cVertex.Set(BEACON_RADIUS, 0.0f);
906  glBegin(GL_QUAD_STRIP);
907  for(GLuint i = 0; i <= m_unVertices; i++) {
908  glNormal3d(cNormal.GetX(), cNormal.GetY(), 0.0f);
909  glVertex3d(cVertex.GetX(), cVertex.GetY(), BEACON_ELEVATION + BEACON_HEIGHT);
910  glVertex3d(cVertex.GetX(), cVertex.GetY(), BEACON_ELEVATION);
911  cVertex.Rotate(cAngle);
912  cNormal.Rotate(cAngle);
913  }
914  glEnd();
915  /* Top part */
916  glBegin(GL_POLYGON);
917  glNormal3d(0.0f, 0.0f, 1.0f);
918  cVertex.Set(BEACON_RADIUS, 0.0f);
919  for(GLuint i = 0; i <= m_unVertices; i++) {
920  glVertex3d(cVertex.GetX(), cVertex.GetY(), BEACON_ELEVATION + BEACON_HEIGHT);
921  cVertex.Rotate(cAngle);
922  }
923  glEnd();
924  }
925 
926  /****************************************/
927  /****************************************/
928 
930  /* Set material */
932  CVector2 cVertex(CAMERA_RADIUS, 0.0f);
933  CRadians cAngle(-CRadians::TWO_PI / m_unVertices);
934  /* Bottom part */
935  glBegin(GL_POLYGON);
936  glNormal3d(0.0f, 0.0f, -1.0f);
937  for(GLuint i = 0; i <= m_unVertices; i++) {
938  glVertex3d(cVertex.GetX(), cVertex.GetY(), CAMERA_ELEVATION);
939  cVertex.Rotate(cAngle);
940  }
941  glEnd();
942  /* Side surface */
943  cAngle = -cAngle;
944  CVector2 cNormal(1.0f, 0.0f);
945  cVertex.Set(CAMERA_RADIUS, 0.0f);
946  glBegin(GL_QUAD_STRIP);
947  for(GLuint i = 0; i <= m_unVertices; i++) {
948  glNormal3d(cNormal.GetX(), cNormal.GetY(), 0.0f);
949  glVertex3d(cVertex.GetX(), cVertex.GetY(), CAMERA_ELEVATION + CAMERA_HEIGHT);
950  glVertex3d(cVertex.GetX(), cVertex.GetY(), CAMERA_ELEVATION);
951  cVertex.Rotate(cAngle);
952  cNormal.Rotate(cAngle);
953  }
954  glEnd();
955  /* Top part */
956  glBegin(GL_POLYGON);
957  glNormal3d(0.0f, 0.0f, 1.0f);
958  cVertex.Set(CAMERA_RADIUS, 0.0f);
959  for(GLuint i = 0; i <= m_unVertices; i++) {
960  glVertex3d(cVertex.GetX(), cVertex.GetY(), CAMERA_ELEVATION + CAMERA_HEIGHT);
961  cVertex.Rotate(cAngle);
962  }
963  glEnd();
964  }
965 
966  /****************************************/
967  /****************************************/
968 
970  public:
971  void ApplyTo(CQTOpenGLWidget& c_visualization,
972  CFootBotEntity& c_entity) {
973  static CQTOpenGLFootBot m_cModel;
974  c_visualization.DrawRays(c_entity.GetControllableEntity());
975  c_visualization.DrawEntity(c_entity.GetEmbodiedEntity());
976  m_cModel.Draw(c_entity);
977  }
978  };
979 
981  public:
982  void ApplyTo(CQTOpenGLWidget& c_visualization,
983  CFootBotEntity& c_entity) {
984  c_visualization.DrawBoundingBox(c_entity.GetEmbodiedEntity());
985  }
986  };
987 
989 
991 
992  /****************************************/
993  /****************************************/
994 
995 }
unsigned int UInt32
32-bit unsigned integer.
Definition: datatypes.h:97
float Real
Collects all ARGoS code.
Definition: datatypes.h:39
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
REGISTER_QTOPENGL_ENTITY_OPERATION(CQTOpenGLOperationDrawNormal, CQTOpenGLOperationDrawEPuckNormal, CEPuckEntity)
CDegrees ToDegrees(const CRadians &c_radians)
Converts CRadians to CDegrees.
Definition: angles.h:489
The basic color type.
Definition: color.h:25
UInt8 GetBlue() const
Returns the blue channel of the color.
Definition: color.h:101
UInt8 GetGreen() const
Returns the green channel of the color.
Definition: color.h:90
UInt8 GetRed() const
Returns the red channel of the color.
Definition: color.h:79
It defines the basic type CRadians, used to store an angle value in radians.
Definition: angles.h:42
static const CRadians TWO_PI
Set to PI * 2.
Definition: angles.h:54
Real GetValue() const
Returns the value in degrees.
Definition: angles.h:322
A 2D vector class.
Definition: vector2.h:27
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector2.h:110
CVector2 & Rotate(const CRadians &c_angle)
Rotates this vector by the wanted angle.
Definition: vector2.h:194
CVector2 & Normalize()
Normalizes this vector.
Definition: vector2.h:176
void Set(Real f_x, Real f_y)
Sets the vector contents from Cartesian coordinates.
Definition: vector2.h:127
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector2.h:94
A 3D vector class.
Definition: vector3.h:31
Real GetX() const
Returns the x coordinate of this vector.
Definition: vector3.h:105
CVector3 & Normalize()
Normalizes this vector.
Definition: vector3.h:237
void Set(const Real f_x, const Real f_y, const Real f_z)
Sets the vector contents from Cartesian coordinates.
Definition: vector3.h:155
Real GetY() const
Returns the y coordinate of this vector.
Definition: vector3.h:121
Real GetZ() const
Returns the z coordinate of this vector.
Definition: vector3.h:137
CVector3 & RotateZ(const CRadians &c_angle)
Rotates this vector wrt the z axis.
Definition: vector3.h:287
CVector3 & RotateY(const CRadians &c_angle)
Rotates this vector wrt the y axis.
Definition: vector3.h:267
CFootBotTurretEntity & GetTurretEntity()
CGripperEquippedEntity & GetGripperEquippedEntity()
CEmbodiedEntity & GetEmbodiedEntity()
CLEDEquippedEntity & GetLEDEquippedEntity()
CControllableEntity & GetControllableEntity()
CFootBotDistanceScannerEquippedEntity & GetDistanceScannerEquippedEntity()
void ApplyTo(CQTOpenGLWidget &c_visualization, CFootBotEntity &c_entity)
void ApplyTo(CQTOpenGLWidget &c_visualization, CFootBotEntity &c_entity)
void RenderCamera()
Renders the camera.
void SetLEDMaterial(GLfloat f_red, GLfloat f_green, GLfloat f_blue)
Sets a colored LED material.
void RenderIMX()
Renders the iMX module.
void SetCircuitBoardMaterial()
Sets a circuit board material.
void RenderTrack()
Renders the tracks.
void RenderDistanceScannerSensor()
Renders a single sensor of the distance scanner.
void RenderRAB()
Renders the RAB module.
void RenderGripperClaw()
Renders the gripper.
void RenderGripperMechanics()
Renders the gripper.
void MakeWheel()
Renders a materialless wheel.
void RenderBase()
Renders the base (apart from the wheels)
void SetWhitePlasticMaterial()
Sets a white plastic material.
virtual void Draw(CFootBotEntity &c_entity)
void RenderGrippableSlice()
Renders a slice of the gripper module (LEDs)
void RenderDistanceScanner()
Renders the distance scanner.
void SetBlackTireMaterial()
Sets a black tire material.
void RenderWheel()
Renders the wheels.
void RenderBeacon()
Renders the beacon.
Real GetLockState() const
Returns the lock state of the gripper.
const CColor & GetColor() const
Returns the current color of the LED.
Definition: led_entity.h:58
A container of CLEDEntity.
CLEDEntity & GetLED(UInt32 un_index)
Returns an LED by numeric index.
void DrawRays(CControllableEntity &c_entity)
Draws a ray.
void DrawEntity(CPositionalEntity &c_entity)
Draws a positional entity.
void DrawBoundingBox(CEmbodiedEntity &c_entity)
Draws the bounding box of an embodied entity.