9 #include <argos3/core/simulator/entity/embodied_entity.h>
10 #include <argos3/core/utility/math/vector2.h>
11 #include <argos3/core/utility/math/vector3.h>
12 #include <argos3/plugins/simulator/entities/led_equipped_entity.h>
13 #include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h>
23 static const Real LEG_HEIGHT = 0.166f;
24 static const Real LEG_WIDTH = 0.02f;
25 static const Real LEG_HALF_WIDTH = LEG_WIDTH * 0.5f;
26 static const Real LEG_DEPTH = 0.005f;
27 static const Real LEG_HALF_DEPTH = LEG_DEPTH * 0.5f;
30 static const Real RING_OUTER_RADIUS = 0.25f;
31 static const Real RING_INNER_RADIUS = 0.237f;
32 static const Real RING_HEIGHT = 0.015f;
33 static const Real RING_ELEVATION = LEG_HEIGHT - RING_HEIGHT;
36 static const Real LED_HEIGHT = 0.01f;
37 static const Real LED_SIDE = RING_HEIGHT;
38 static const Real LED_HALF_SIDE = LED_SIDE * 0.5f;
39 static const Real LED_SIDE_RING_ELEVATION = RING_ELEVATION + LED_HALF_SIDE;
40 static const Real LED_BOTTOM_RING_ELEVATION = RING_ELEVATION - LED_HEIGHT;
41 static const Real LED_BOTTOM_RING_DISTANCE = RING_OUTER_RADIUS - LEG_HALF_WIDTH;
44 static const Real ROD_SIDE = 0.07f;
45 static const Real ROD_HALF_SIDE = ROD_SIDE * 0.5f;
46 static const Real ROD_HEIGHT = 0.4f;
47 static const Real ROD_ELEVATION = LEG_HEIGHT;
54 m_fLEDAngleSlice(360.0f / 16.0f) {
56 m_unLists = glGenLists(4);
59 m_unLegList = m_unLists;
60 m_unBodyList = m_unLists + 1;
61 m_unSideLEDList = m_unLists + 2;
62 m_unBottomLEDList = m_unLists + 3;
65 glNewList(m_unLegList, GL_COMPILE);
70 glNewList(m_unBodyList, GL_COMPILE);
75 glNewList(m_unSideLEDList, GL_COMPILE);
80 glNewList(m_unBottomLEDList, GL_COMPILE);
89 glDeleteLists(m_unLists, 4);
99 glRotated(45.0f, 0.0f, 0.0f, 1.0f);
100 glTranslated(RING_OUTER_RADIUS, 0.0f, 0.0f);
101 glCallList(m_unLegList);
104 glRotated(135.0f, 0.0f, 0.0f, 1.0f);
105 glTranslated(RING_OUTER_RADIUS, 0.0f, 0.0f);
106 glCallList(m_unLegList);
109 glRotated(225.0f, 0.0f, 0.0f, 1.0f);
110 glTranslated(RING_OUTER_RADIUS, 0.0f, 0.0f);
111 glCallList(m_unLegList);
114 glRotated(315.0f, 0.0f, 0.0f, 1.0f);
115 glTranslated(RING_OUTER_RADIUS, 0.0f, 0.0f);
116 glCallList(m_unLegList);
119 glCallList(m_unBodyList);
123 glRotated(m_fLEDAngleSlice * 0.5f, 0.0f, 0.0f, 1.0f);
129 glCallList(m_unSideLEDList);
133 glCallList(m_unBottomLEDList);
134 for(
UInt32 i = 1; i < 16; i++) {
135 glRotated(m_fLEDAngleSlice, 0.0f, 0.0f, 1.0f);
141 glCallList(m_unSideLEDList);
145 glCallList(m_unBottomLEDList);
147 glRotated(135.0f, 0.0f, 0.0f, 1.0f);
148 glTranslated(-0.3*RING_OUTER_RADIUS, 0.0f, 0.0f);
153 glCallList(m_unBottomLEDList);
161 const GLfloat pfColor[] = { f_red, f_green, f_blue, 1.0f };
162 const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
163 const GLfloat pfShininess[] = { 0.0f };
164 const GLfloat pfEmission[] = { f_red, f_green, f_blue, 1.0f };
165 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
166 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
167 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
168 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
175 const GLfloat pfColor[] = { 0.25f, 0.25f, 0.25f, 1.0f };
176 const GLfloat pfSpecular[] = { 0.9f, 0.9f, 0.9f, 1.0f };
177 const GLfloat pfShininess[] = { 100.0f };
178 const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
179 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
180 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
181 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
182 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
191 glNormal3d(0.0f, 0.0f, 1.0f);
192 glVertex3d(-LEG_HALF_WIDTH, -LEG_HALF_DEPTH, LEG_HEIGHT);
193 glVertex3d( LEG_HALF_WIDTH, -LEG_HALF_DEPTH, LEG_HEIGHT);
194 glVertex3d( LEG_HALF_WIDTH, LEG_HALF_DEPTH, LEG_HEIGHT);
195 glVertex3d(-LEG_HALF_WIDTH, LEG_HALF_DEPTH, LEG_HEIGHT);
199 glNormal3d(0.0f, 0.0f, -1.0f);
200 glVertex3d(-LEG_HALF_WIDTH, -LEG_HALF_DEPTH, 0.0f);
201 glVertex3d(-LEG_HALF_WIDTH, LEG_HALF_DEPTH, 0.0f);
202 glVertex3d( LEG_HALF_WIDTH, LEG_HALF_DEPTH, 0.0f);
203 glVertex3d( LEG_HALF_WIDTH, -LEG_HALF_DEPTH, 0.0f);
206 glBegin(GL_QUAD_STRIP);
208 glNormal3d(0.0f, -1.0f, 0.0f);
209 glVertex3d(-LEG_HALF_WIDTH, -LEG_HALF_DEPTH, LEG_HEIGHT);
210 glVertex3d(-LEG_HALF_WIDTH, -LEG_HALF_DEPTH, 0.0f);
212 glVertex3d( LEG_HALF_WIDTH, -LEG_HALF_DEPTH, LEG_HEIGHT);
213 glVertex3d( LEG_HALF_WIDTH, -LEG_HALF_DEPTH, 0.0f);
215 glNormal3d(1.0f, 0.0f, 0.0f);
216 glVertex3d( LEG_HALF_WIDTH, LEG_HALF_DEPTH, LEG_HEIGHT);
217 glVertex3d( LEG_HALF_WIDTH, LEG_HALF_DEPTH, 0.0f);
219 glNormal3d(0.0f, 1.0f, 0.0f);
220 glVertex3d(-LEG_HALF_WIDTH, LEG_HALF_DEPTH, LEG_HEIGHT);
221 glVertex3d(-LEG_HALF_WIDTH, LEG_HALF_DEPTH, 0.0f);
223 glNormal3d(-1.0f, 0.0f, 0.0f);
224 glVertex3d(-LEG_HALF_WIDTH, -LEG_HALF_DEPTH, LEG_HEIGHT);
225 glVertex3d(-LEG_HALF_WIDTH, -LEG_HALF_DEPTH, 0.0f);
235 glBegin(GL_TRIANGLES);
237 glVertex3d(LED_HEIGHT + RING_OUTER_RADIUS, 0.0f, LED_SIDE_RING_ELEVATION );
238 glVertex3d( RING_OUTER_RADIUS, LED_HALF_SIDE, LED_SIDE_RING_ELEVATION + LED_HALF_SIDE);
239 glVertex3d( RING_OUTER_RADIUS, -LED_HALF_SIDE, LED_SIDE_RING_ELEVATION + LED_HALF_SIDE);
241 glVertex3d(LED_HEIGHT + RING_OUTER_RADIUS, 0.0f, LED_SIDE_RING_ELEVATION );
242 glVertex3d( RING_OUTER_RADIUS, -LED_HALF_SIDE, LED_SIDE_RING_ELEVATION - LED_HALF_SIDE);
243 glVertex3d( RING_OUTER_RADIUS, LED_HALF_SIDE, LED_SIDE_RING_ELEVATION - LED_HALF_SIDE);
245 glVertex3d(LED_HEIGHT + RING_OUTER_RADIUS, 0.0f, LED_SIDE_RING_ELEVATION );
246 glVertex3d( RING_OUTER_RADIUS, LED_HALF_SIDE, LED_SIDE_RING_ELEVATION - LED_HALF_SIDE);
247 glVertex3d( RING_OUTER_RADIUS, LED_HALF_SIDE, LED_SIDE_RING_ELEVATION + LED_HALF_SIDE);
249 glVertex3d(LED_HEIGHT + RING_OUTER_RADIUS, 0.0f, LED_SIDE_RING_ELEVATION );
250 glVertex3d( RING_OUTER_RADIUS, -LED_HALF_SIDE, LED_SIDE_RING_ELEVATION + LED_HALF_SIDE);
251 glVertex3d( RING_OUTER_RADIUS, -LED_HALF_SIDE, LED_SIDE_RING_ELEVATION - LED_HALF_SIDE);
261 glBegin(GL_TRIANGLES);
263 glVertex3d(LED_BOTTOM_RING_DISTANCE, 0.0f, LED_BOTTOM_RING_ELEVATION);
264 glVertex3d(RING_OUTER_RADIUS, LED_HALF_SIDE, RING_ELEVATION);
265 glVertex3d(RING_OUTER_RADIUS, -LED_HALF_SIDE, RING_ELEVATION);
267 glVertex3d(LED_BOTTOM_RING_DISTANCE, 0.0f, LED_BOTTOM_RING_ELEVATION);
268 glVertex3d(RING_OUTER_RADIUS - LED_SIDE, -LED_HALF_SIDE, RING_ELEVATION);
269 glVertex3d(RING_OUTER_RADIUS - LED_SIDE, LED_HALF_SIDE, RING_ELEVATION);
271 glVertex3d(LED_BOTTOM_RING_DISTANCE, 0.0f, LED_BOTTOM_RING_ELEVATION);
272 glVertex3d(RING_OUTER_RADIUS - LED_SIDE, LED_HALF_SIDE, RING_ELEVATION);
273 glVertex3d(RING_OUTER_RADIUS , LED_HALF_SIDE, RING_ELEVATION);
275 glVertex3d(LED_BOTTOM_RING_DISTANCE, 0.0f, LED_BOTTOM_RING_ELEVATION);
276 glVertex3d(RING_OUTER_RADIUS , -LED_HALF_SIDE, RING_ELEVATION);
277 glVertex3d(RING_OUTER_RADIUS - LED_SIDE, -LED_HALF_SIDE, RING_ELEVATION);
286 CVector2 cVertex(RING_OUTER_RADIUS, 0.0f);
290 glNormal3d(0.0f, 0.0f, -1.0f);
291 for(GLuint i = 0; i <= m_unVertices; i++) {
292 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), RING_ELEVATION);
299 cVertex.
Set(RING_OUTER_RADIUS, 0.0f);
300 glBegin(GL_QUAD_STRIP);
301 for(GLuint i = 0; i <= m_unVertices; i++) {
302 glNormal3d(cNormal.
GetX(), cNormal.
GetY(), 0.0f);
303 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), RING_ELEVATION + RING_HEIGHT);
304 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), RING_ELEVATION);
311 glNormal3d(0.0f, 0.0f, 1.0f);
312 cVertex.
Set(RING_OUTER_RADIUS, 0.0f);
313 for(GLuint i = 0; i <= m_unVertices; i++) {
314 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), RING_ELEVATION + RING_HEIGHT);
321 glNormal3d(0.0f, 0.0f, 1.0f);
322 glVertex3d(-ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
323 glVertex3d( ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
324 glVertex3d( ROD_HALF_SIDE, ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
325 glVertex3d(-ROD_HALF_SIDE, ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
328 glBegin(GL_QUAD_STRIP);
330 glNormal3d(0.0f, -1.0f, 0.0f);
331 glVertex3d(-ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
332 glVertex3d(-ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION);
334 glVertex3d( ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
335 glVertex3d( ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION);
337 glNormal3d(1.0f, 0.0f, 0.0f);
338 glVertex3d( ROD_HALF_SIDE, ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
339 glVertex3d( ROD_HALF_SIDE, ROD_HALF_SIDE, ROD_ELEVATION);
341 glNormal3d(0.0f, 1.0f, 0.0f);
342 glVertex3d(-ROD_HALF_SIDE, ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
343 glVertex3d(-ROD_HALF_SIDE, ROD_HALF_SIDE, ROD_ELEVATION);
345 glNormal3d(-1.0f, 0.0f, 0.0f);
346 glVertex3d(-ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION+ROD_HEIGHT);
347 glVertex3d(-ROD_HALF_SIDE, -ROD_HALF_SIDE, ROD_ELEVATION);
361 m_cModel.
Draw(c_entity);
unsigned int UInt32
32-bit unsigned integer.
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
REGISTER_QTOPENGL_ENTITY_OPERATION(CQTOpenGLOperationDrawNormal, CQTOpenGLOperationDrawEPuckNormal, CEPuckEntity)
UInt8 GetBlue() const
Returns the blue channel of the color.
UInt8 GetGreen() const
Returns the green channel of the color.
UInt8 GetRed() const
Returns the red channel of the color.
It defines the basic type CRadians, used to store an angle value in radians.
static const CRadians TWO_PI
Set to PI * 2.
Real GetY() const
Returns the y coordinate of this vector.
CVector2 & Rotate(const CRadians &c_angle)
Rotates this vector by the wanted angle.
void Set(Real f_x, Real f_y)
Sets the vector contents from Cartesian coordinates.
Real GetX() const
Returns the x coordinate of this vector.
CEmbodiedEntity & GetEmbodiedEntity()
CControllableEntity & GetControllableEntity()
CLEDEquippedEntity & GetLEDEquippedEntity()
void ApplyTo(CQTOpenGLWidget &c_visualization, CEyeBotEntity &c_entity)
void ApplyTo(CQTOpenGLWidget &c_visualization, CEyeBotEntity &c_entity)
void SetBodyMaterial()
Sets a shiny gray material.
void DrawBody()
The eye-bot body.
void DrawBottomLED()
A single LED of the bottom ring.
virtual ~CQTOpenGLEyeBot()
void DrawSideLED()
A single LED of the side ring.
virtual void Draw(CEyeBotEntity &c_entity)
void MakeLeg()
An eye-bot leg.
void SetLEDMaterial(GLfloat f_red, GLfloat f_green, GLfloat f_blue)
Sets a colored LED material.
const CColor & GetColor() const
Returns the current color of the LED.
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.