ARGoS 3
A parallel, multi-engine simulator for swarm robotics
qtopengl_prototype.cpp
Go to the documentation of this file.
1
9#include <argos3/core/utility/math/vector2.h>
10#include <argos3/core/simulator/entity/embodied_entity.h>
11#include <argos3/plugins/robots/prototype/simulator/prototype_entity.h>
12#include <argos3/plugins/robots/prototype/simulator/prototype_link_equipped_entity.h>
13#include <argos3/plugins/simulator/entities/directional_led_equipped_entity.h>
14#include <argos3/plugins/simulator/entities/led_equipped_entity.h>
15#include <argos3/plugins/simulator/entities/magnet_equipped_entity.h>
16#include <argos3/plugins/simulator/entities/tag_equipped_entity.h>
17#include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h>
18
19namespace argos {
20
21 /****************************************/
22 /****************************************/
23
24 const GLfloat BODY_COLOR[] = { 0.5f, 0.5f, 0.5f, 1.0f };
25 const GLfloat SPECULAR[] = { 0.0f, 0.0f, 0.0f, 1.0f };
26 const GLfloat SHININESS[] = { 0.0f };
27 const GLfloat EMISSION[] = { 0.0f, 0.0f, 0.0f, 1.0f };
28 static const Real LED_RADIUS = 0.0025f;
29#ifndef NDEBUG
30 static const Real FIELD_SCALE_FACTOR = 0.0005f;
31#endif
32
33 /****************************************/
34 /****************************************/
35
37 m_unVertices(20) {
38 /* Reserve the needed display lists */
39 m_unBaseList = glGenLists(6);
40 /* References to the display lists */
41 m_unBoxList = m_unBaseList;
42 m_unCylinderList = m_unBaseList + 1;
43 m_unSphereList = m_unBaseList + 2;
44 m_unLEDList = m_unBaseList + 3;
45 m_unPoleList = m_unBaseList + 4;
46 m_unTagList = m_unBaseList + 5;
47 /* Make box list */
48 glNewList(m_unBoxList, GL_COMPILE);
49 MakeBox();
50 glEndList();
51 /* Make cylinder list */
52 glNewList(m_unCylinderList, GL_COMPILE);
53 MakeCylinder();
54 glEndList();
55 /* Make sphere list */
56 glNewList(m_unSphereList, GL_COMPILE);
57 MakeSphere();
58 glEndList();
59 /* Make LED list */
60 glNewList(m_unLEDList, GL_COMPILE);
61 MakeLED();
62 glEndList();
63 /* Make Poles list */
64 glNewList(m_unPoleList, GL_COMPILE);
65 MakePoles();
66 glEndList();
67 /* Make Tag list */
68 MakeTagTexture();
69 glNewList(m_unTagList, GL_COMPILE);
70 MakeTag();
71 glEndList();
72 }
73
74 /****************************************/
75 /****************************************/
76
78 glDeleteLists(m_unBaseList, 6);
79 }
80
81 /****************************************/
82 /****************************************/
83
84 void CQTOpenGLPrototype::MakeLED() {
85 CVector3 cNormal, cPoint;
86 CRadians cSlice(CRadians::TWO_PI / m_unVertices);
87
88 glBegin(GL_TRIANGLE_STRIP);
89 for(CRadians cInclination; cInclination <= CRadians::PI; cInclination += cSlice) {
90 for(CRadians cAzimuth; cAzimuth <= CRadians::TWO_PI; cAzimuth += cSlice) {
91 cNormal.FromSphericalCoords(1.0f, cInclination, cAzimuth);
92 cPoint = LED_RADIUS * cNormal;
93 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
94 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
95 cNormal.FromSphericalCoords(1.0f, cInclination + cSlice, cAzimuth);
96 cPoint = LED_RADIUS * cNormal;
97 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
98 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
99 cNormal.FromSphericalCoords(1.0f, cInclination, cAzimuth + cSlice);
100 cPoint = LED_RADIUS * cNormal;
101 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
102 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
103 cNormal.FromSphericalCoords(1.0f, cInclination + cSlice, cAzimuth + cSlice);
104 cPoint = LED_RADIUS * cNormal;
105 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
106 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
107 }
108 }
109 glEnd();
110 }
111
112 /****************************************/
113 /****************************************/
114
116 /* Draw the links */
117 for(CPrototypeLinkEntity* pcLink : c_entity.GetLinkEquippedEntity().GetLinks()){
118 /* Configure the body material */
119 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, BODY_COLOR);
120 /* Get the position of the link */
121 const CVector3& cPosition = pcLink->GetAnchor().Position;
122 /* Get the orientation of the link */
123 const CQuaternion& cOrientation = pcLink->GetAnchor().Orientation;
124 CRadians cZAngle, cYAngle, cXAngle;
125 cOrientation.ToEulerAngles(cZAngle, cYAngle, cXAngle);
126 glPushMatrix();
127 glTranslated(cPosition.GetX(), cPosition.GetY(), cPosition.GetZ());
128 glRotated(ToDegrees(cXAngle).GetValue(), 1.0f, 0.0f, 0.0f);
129 glRotated(ToDegrees(cYAngle).GetValue(), 0.0f, 1.0f, 0.0f);
130 glRotated(ToDegrees(cZAngle).GetValue(), 0.0f, 0.0f, 1.0f);
131 /* Draw the link */
132 switch(pcLink->GetGeometry()) {
134 glScaled(pcLink->GetExtents().GetX(),
135 pcLink->GetExtents().GetY(),
136 pcLink->GetExtents().GetZ());
137 glCallList(m_unBoxList);
138 break;
140 glScaled(pcLink->GetExtents().GetX(),
141 pcLink->GetExtents().GetY(),
142 pcLink->GetExtents().GetZ());
143 glCallList(m_unCylinderList);
144 break;
146 glScaled(pcLink->GetExtents().GetX(),
147 pcLink->GetExtents().GetY(),
148 pcLink->GetExtents().GetZ());
149 glCallList(m_unSphereList);
150 break;
152 DrawConvexHull(pcLink->GetConvexHullPoints(),
153 pcLink->GetConvexHullFaces());
154 break;
155 }
156 glPopMatrix();
157 }
158 }
159
160 /****************************************/
161 /****************************************/
162
164 /* Draw the directional LEDs */
165 if(c_entity.HasDirectionalLEDEquippedEntity()) {
166 GLfloat pfColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
167 const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
168 const GLfloat pfShininess[] = { 100.0f };
169 const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
170 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
171 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
172 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
173 const CDirectionalLEDEquippedEntity& cDirectionalLEDEquippedEntity =
175 for(const CDirectionalLEDEquippedEntity::SInstance& s_instance :
176 cDirectionalLEDEquippedEntity.GetInstances()) {
177 glPushMatrix();
178 /* Set the material */
179 const CColor& cColor = s_instance.LED.GetColor();
180 pfColor[0] = cColor.GetRed() / 255.0f;
181 pfColor[1] = cColor.GetGreen() / 255.0f;
182 pfColor[2] = cColor.GetBlue() / 255.0f;
183 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
184 /* Perform rototranslation */
185 const CVector3& cPosition = s_instance.LED.GetPosition();
186 glTranslated(cPosition.GetX(), cPosition.GetY(), cPosition.GetZ());
187 /* Draw the LED */
188 glCallList(m_unLEDList);
189 glPopMatrix();
190 }
191 }
192 /* Draw the LEDs */
193 if(c_entity.HasLEDEquippedEntity()) {
194 GLfloat pfColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
195 const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
196 const GLfloat pfShininess[] = { 100.0f };
197 const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
198 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
199 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
200 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
201 for(const CLEDEquippedEntity::SActuator* ps_actuator :
202 c_entity.GetLEDEquippedEntity().GetLEDs()) {
203 glPushMatrix();
204 /* Set the material */
205 const CColor& cColor = ps_actuator->LED.GetColor();
206 pfColor[0] = cColor.GetRed() / 255.0f;
207 pfColor[1] = cColor.GetGreen() / 255.0f;
208 pfColor[2] = cColor.GetBlue() / 255.0f;
209 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
210 /* Perform rototranslation */
211 const CVector3& cPosition = ps_actuator->LED.GetPosition();
212 glTranslated(cPosition.GetX(), cPosition.GetY(), cPosition.GetZ());
213 /* Draw the LED */
214 glCallList(m_unLEDList);
215 glPopMatrix();
216 }
217 }
218 /* Draw the tags */
219 if(c_entity.HasTagEquippedEntity()) {
220 const CTagEquippedEntity& cTagEquippedEntity =
221 c_entity.GetTagEquippedEntity();
222 CRadians cZ, cY, cX;
223 for(const CTagEquippedEntity::SInstance& s_instance :
224 cTagEquippedEntity.GetInstances()) {
225 const CVector3& cTagPosition = s_instance.Tag.GetPosition();
226 const CQuaternion& cTagOrientation = s_instance.Tag.GetOrientation();
227 cTagOrientation.ToEulerAngles(cZ, cY, cX);
228 Real fScaling = s_instance.Tag.GetSideLength();
229 glPushMatrix();
230 glTranslated(cTagPosition.GetX(),
231 cTagPosition.GetY(),
232 cTagPosition.GetZ());
233 glRotated(ToDegrees(cX).GetValue(), 1.0f, 0.0f, 0.0f);
234 glRotated(ToDegrees(cY).GetValue(), 0.0f, 1.0f, 0.0f);
235 glRotated(ToDegrees(cZ).GetValue(), 0.0f, 0.0f, 1.0f);
236 glScaled(fScaling, fScaling, 1.0f);
237 glCallList(m_unTagList);
238 glPopMatrix();
239 }
240 }
241#ifndef NDEBUG
242 /* Draw the magnetic poles */
243 if(c_entity.HasMagnetEquippedEntity()) {
244 CMagnetEquippedEntity& cMagnetEquippedEntity =
245 c_entity.GetMagnetEquippedEntity();
246 CVector3 cFieldOrigin;
247 CQuaternion cFieldOrientation;
248 CRadians cFieldOrientationZ, cFieldOrientationY, cFieldOrientationX;
249 for(CMagnetEquippedEntity::SInstance& s_instance :
250 cMagnetEquippedEntity.GetInstances()) {
251 cFieldOrigin = s_instance.Offset;
252 cFieldOrigin.Rotate(s_instance.Anchor.Orientation);
253 cFieldOrigin += s_instance.Anchor.Position;
254 const CVector3& cField = s_instance.Magnet.GetField();
255 cFieldOrientation = s_instance.Anchor.Orientation *
256 CQuaternion(CVector3::Z, cField);
257 cFieldOrientation.ToEulerAngles(cFieldOrientationZ,
258 cFieldOrientationY,
259 cFieldOrientationX);
260 glPushMatrix();
261 glTranslated(cFieldOrigin.GetX(),
262 cFieldOrigin.GetY(),
263 cFieldOrigin.GetZ());
264 glRotated(ToDegrees(cFieldOrientationX).GetValue(), 1.0f, 0.0f, 0.0f);
265 glRotated(ToDegrees(cFieldOrientationY).GetValue(), 0.0f, 1.0f, 0.0f);
266 glRotated(ToDegrees(cFieldOrientationZ).GetValue(), 0.0f, 0.0f, 1.0f);
267 glScaled(1.0f, 1.0f, cField.Length() * FIELD_SCALE_FACTOR);
268 glCallList(m_unPoleList);
269 glPopMatrix();
270 }
271 }
272#endif
273 }
274
275 /****************************************/
276 /****************************************/
277
278 void CQTOpenGLPrototype::MakeBox() {
279 glEnable(GL_NORMALIZE);
280 /* Set the material */
281 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SPECULAR);
282 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, SHININESS);
283 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, EMISSION);
284 /* This part covers the top and bottom faces (parallel to XY) */
285 glBegin(GL_QUADS);
286 /* Bottom face */
287 glNormal3d(0.0f, 0.0f, -1.0f);
288 glVertex3d( 0.5f, 0.5f, 0.0f);
289 glVertex3d( 0.5f, -0.5f, 0.0f);
290 glVertex3d(-0.5f, -0.5f, 0.0f);
291 glVertex3d(-0.5f, 0.5f, 0.0f);
292 /* Top face */
293 glNormal3d(0.0f, 0.0f, 1.0f);
294 glVertex3d(-0.5f, -0.5f, 1.0f);
295 glVertex3d( 0.5f, -0.5f, 1.0f);
296 glVertex3d( 0.5f, 0.5f, 1.0f);
297 glVertex3d(-0.5f, 0.5f, 1.0f);
298 glEnd();
299 /* This part covers the faces (South, East, North, West) */
300 glBegin(GL_QUADS);
301 /* South face */
302 glNormal3d(0.0f, -1.0f, 0.0f);
303 glVertex3d(-0.5f, -0.5f, 1.0f);
304 glVertex3d(-0.5f, -0.5f, 0.0f);
305 glVertex3d( 0.5f, -0.5f, 0.0f);
306 glVertex3d( 0.5f, -0.5f, 1.0f);
307 /* East face */
308 glNormal3d(1.0f, 0.0f, 0.0f);
309 glVertex3d( 0.5f, -0.5f, 1.0f);
310 glVertex3d( 0.5f, -0.5f, 0.0f);
311 glVertex3d( 0.5f, 0.5f, 0.0f);
312 glVertex3d( 0.5f, 0.5f, 1.0f);
313 /* North face */
314 glNormal3d(0.0f, 1.0f, 0.0f);
315 glVertex3d( 0.5f, 0.5f, 1.0f);
316 glVertex3d( 0.5f, 0.5f, 0.0f);
317 glVertex3d(-0.5f, 0.5f, 0.0f);
318 glVertex3d(-0.5f, 0.5f, 1.0f);
319 /* West face */
320 glNormal3d(-1.0f, 0.0f, 0.0f);
321 glVertex3d(-0.5f, 0.5f, 1.0f);
322 glVertex3d(-0.5f, 0.5f, 0.0f);
323 glVertex3d(-0.5f, -0.5f, 0.0f);
324 glVertex3d(-0.5f, -0.5f, 1.0f);
325 glEnd();
326 glDisable(GL_NORMALIZE);
327 }
328
329 /****************************************/
330 /****************************************/
331
332 void CQTOpenGLPrototype::MakeCylinder() {
333 glEnable(GL_NORMALIZE);
334 /* Set the material */
335 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SPECULAR);
336 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, SHININESS);
337 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, EMISSION);
338 /* Side surface */
339 CVector2 cVertex(0.5f, 0.0f);
340 CRadians cAngle(CRadians::TWO_PI / m_unVertices);
341 glBegin(GL_QUAD_STRIP);
342 for(GLuint i = 0; i <= m_unVertices; i++) {
343 glNormal3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
344 glVertex3d(cVertex.GetX(), cVertex.GetY(), 1.0f);
345 glVertex3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
346 cVertex.Rotate(cAngle);
347 }
348 glEnd();
349 /* Top disk */
350 cVertex.Set(0.5f, 0.0f);
351 glBegin(GL_POLYGON);
352 glNormal3d(0.0f, 0.0f, 1.0f);
353 for(GLuint i = 0; i <= m_unVertices; i++) {
354 glVertex3d(cVertex.GetX(), cVertex.GetY(), 1.0f);
355 cVertex.Rotate(cAngle);
356 }
357 glEnd();
358 /* Bottom disk */
359 cVertex.Set(0.5f, 0.0f);
360 cAngle = -cAngle;
361 glBegin(GL_POLYGON);
362 glNormal3d(0.0f, 0.0f, -1.0f);
363 for(GLuint i = 0; i <= m_unVertices; i++) {
364 glVertex3d(cVertex.GetX(), cVertex.GetY(), 0.0f);
365 cVertex.Rotate(cAngle);
366 }
367 glEnd();
368 glDisable(GL_NORMALIZE);
369 }
370
371 /****************************************/
372 /****************************************/
373
374 void CQTOpenGLPrototype::MakeSphere() {
375 glEnable(GL_NORMALIZE);
376 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SPECULAR);
377 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, SHININESS);
378 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, EMISSION);
379 CVector3 cNormal, cPoint;
380 CRadians cSlice(CRadians::TWO_PI / m_unVertices);
381 glBegin(GL_TRIANGLE_STRIP);
382 for(CRadians cInclination; cInclination <= CRadians::PI; cInclination += cSlice) {
383 for(CRadians cAzimuth; cAzimuth <= CRadians::TWO_PI; cAzimuth += cSlice) {
384 cPoint.FromSphericalCoords(0.5f, cInclination, cAzimuth);
385 glNormal3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
386 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
387 cPoint.FromSphericalCoords(0.5f, cInclination + cSlice, cAzimuth);
388 glNormal3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
389 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
390 cPoint.FromSphericalCoords(0.5f, cInclination, cAzimuth + cSlice);
391 glNormal3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
392 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
393 cPoint.FromSphericalCoords(0.5f, cInclination + cSlice, cAzimuth + cSlice);
394 glNormal3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
395 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ() + 0.5f);
396 }
397 }
398 glEnd();
399 glDisable(GL_NORMALIZE);
400 }
401
402 /****************************************/
403 /****************************************/
404
405 void CQTOpenGLPrototype::DrawConvexHull(const std::vector<CVector3>& vec_points,
406 const std::vector<CConvexHull::SFace>& vec_faces) {
407 glEnable(GL_NORMALIZE);
408 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, SPECULAR);
409 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, SHININESS);
410 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, EMISSION);
411 glBegin(GL_TRIANGLES);
412 for(const CConvexHull::SFace& s_face : vec_faces) {
413 const CVector3& cVertex1 = vec_points[s_face.VertexIndices[0]];
414 const CVector3& cVertex2 = vec_points[s_face.VertexIndices[1]];
415 const CVector3& cVertex3 = vec_points[s_face.VertexIndices[2]];
416 CVector3 cNormal(cVertex2 - cVertex1);
417 cNormal.CrossProduct(cVertex3 - cVertex1);
418 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
419 glVertex3d(cVertex1.GetX(), cVertex1.GetY(), cVertex1.GetZ());
420 glVertex3d(cVertex2.GetX(), cVertex2.GetY(), cVertex2.GetZ());
421 glVertex3d(cVertex3.GetX(), cVertex3.GetY(), cVertex3.GetZ());
422 }
423 glEnd();
424 glDisable(GL_NORMALIZE);
425 }
426
427 /****************************************/
428 /****************************************/
429
430 void CQTOpenGLPrototype::MakeTagTexture() {
431 glGenTextures(1, &m_unTagTex);
432 glBindTexture(GL_TEXTURE_2D, m_unTagTex);
433 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, 4, 4, 0, GL_RGB, GL_FLOAT, m_fTagTexture);
434 }
435
436 /****************************************/
437 /****************************************/
438
439 void CQTOpenGLPrototype::MakeTag() {
440 glEnable(GL_NORMALIZE);
441 glDisable(GL_LIGHTING);
442 glEnable(GL_TEXTURE_2D);
443 glBindTexture(GL_TEXTURE_2D, m_unTagTex);
444 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
445 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
446 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
447 glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
448 glBegin(GL_QUADS);
449 glNormal3d(0.0f, 0.0f, 1.0f);
450 glTexCoord2f(1.0f, 1.0f); glVertex2f( 0.5f, 0.5f);
451 glTexCoord2f(0.03f, 1.0f); glVertex2f(-0.5f, 0.5f);
452 glTexCoord2f(0.03f, 0.03f); glVertex2f(-0.5f, -0.5f);
453 glTexCoord2f(1.0f, 0.03f); glVertex2f( 0.5f, -0.5f);
454 glEnd();
455 glDisable(GL_TEXTURE_2D);
456 glEnable(GL_LIGHTING);
457 glDisable(GL_NORMALIZE);
458 }
459
460 /****************************************/
461 /****************************************/
462
463 void CQTOpenGLPrototype::MakePoles() {
464 glEnable(GL_NORMALIZE);
465 glDisable(GL_LIGHTING);
466 glLineWidth(4.0f);
467 glBegin(GL_LINES);
468 /* south pole */
469 glColor3f(1.0, 0.0, 0.0);
470 glVertex3d(0.0f, 0.0f, 0.0f);
471 glVertex3d(0.0f, 0.0f, 0.5f);
472 /* north pole */
473 glColor3f(0.0, 0.0, 1.0);
474 glVertex3d(0.0f, 0.0f, 0.0f);
475 glVertex3d(0.0f, 0.0f, -0.5f);
476 glEnd();
477 glLineWidth(1.0f);
478 glEnable(GL_LIGHTING);
479 glDisable(GL_NORMALIZE);
480 }
481
482 /****************************************/
483 /****************************************/
484
486 public:
487 void ApplyTo(CQTOpenGLWidget& c_visualization,
488 CPrototypeEntity& c_entity) {
489 static CQTOpenGLPrototype m_cModel;
490 if(c_entity.HasControllableEntity()) {
491 c_visualization.DrawRays(c_entity.GetControllableEntity());
492 }
493 m_cModel.DrawEntity(c_entity);
494 m_cModel.DrawDevices(c_entity);
495 }
496 };
497
498 /****************************************/
499 /****************************************/
500
502 public:
503 void ApplyTo(CQTOpenGLWidget& c_visualization,
504 CPrototypeEntity& c_entity) {
505 c_visualization.DrawBoundingBox(c_entity.GetEmbodiedEntity());
506 }
507 };
508
510
512
513 /****************************************/
514 /****************************************/
515
516}
float Real
Collects all ARGoS code.
Definition datatypes.h:39
#define REGISTER_ENTITY_OPERATION(LABEL, PLUGIN, OPERATION, RETURN_VALUE, DERIVED)
Convenience macro to register vtable entity operations.
Definition entity.h:451
The namespace containing all the ARGoS related code.
Definition ci_actuator.h:12
const GLfloat SHININESS[]
const GLfloat SPECULAR[]
const GLfloat EMISSION[]
const GLfloat BODY_COLOR[]
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 PI
The PI constant.
Definition angles.h:49
static const CRadians TWO_PI
Set to PI * 2.
Definition angles.h:54
void ToEulerAngles(CRadians &c_z_angle, CRadians &c_y_angle, CRadians &c_x_angle) const
Definition quaternion.h:172
A 3D vector class.
Definition vector3.h:31
Real Length() const
Returns the length of this vector.
Definition vector3.h:227
CVector3 & Rotate(const CQuaternion &c_quaternion)
Rotates this vector by the given quaternion.
Definition vector3.cpp:23
Real GetX() const
Returns the x coordinate of this vector.
Definition vector3.h:105
CVector3 & FromSphericalCoords(Real f_length, const CRadians &c_inclination, const CRadians &c_azimuth)
Sets the vector contents from spherical coordinates.
Definition vector3.h:180
Real GetY() const
Returns the y coordinate of this vector.
Definition vector3.h:121
static const CVector3 Z
The z axis.
Definition vector3.h:42
Real GetZ() const
Returns the z coordinate of this vector.
Definition vector3.h:137
bool HasLEDEquippedEntity() const
bool HasControllableEntity() const
CControllableEntity & GetControllableEntity()
CDirectionalLEDEquippedEntity & GetDirectionalLEDEquippedEntity()
CEmbodiedEntity & GetEmbodiedEntity()
CMagnetEquippedEntity & GetMagnetEquippedEntity()
bool HasTagEquippedEntity() const
CLEDEquippedEntity & GetLEDEquippedEntity()
bool HasDirectionalLEDEquippedEntity() const
bool HasMagnetEquippedEntity() const
CTagEquippedEntity & GetTagEquippedEntity()
CPrototypeLinkEquippedEntity & GetLinkEquippedEntity()
void ApplyTo(CQTOpenGLWidget &c_visualization, CPrototypeEntity &c_entity)
void ApplyTo(CQTOpenGLWidget &c_visualization, CPrototypeEntity &c_entity)
virtual void DrawEntity(CPrototypeEntity &c_entity)
virtual void DrawDevices(CPrototypeEntity &c_entity)
A container of CDirectionalLEDEntity.
SInstance::TVector & GetInstances()
Returns all the LEDs.
SActuator::TList & GetLEDs()
Returns all the LEDs.
A container of CMagnetEntity.
SInstance::TVector & GetInstances()
A container of CTagEntity.
SInstance::TVector & GetInstances()
Returns the tags.
void DrawRays(CControllableEntity &c_entity)
Draws a ray.
void DrawBoundingBox(CEmbodiedEntity &c_entity)
Draws the bounding box of an embodied entity.