9 #include <argos3/core/utility/math/vector2.h>
10 #include <argos3/core/utility/math/vector3.h>
11 #include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h>
20 static const Real BOARD_HALF_DIAGONAL = 0.029f;
21 static const Real BOARD_HEIGHT = 0.005f;
23 static const Real ARM_HALF_LENGTH = 0.063f;
24 static const Real ARM_HEIGHT = 0.003f;
25 static const Real ARM_HALF_WIDTH = 0.0015f;
26 static const Real ARM_BOTTOM = 0.001f;
27 static const Real ARM_TOP = ARM_BOTTOM + ARM_HEIGHT;
29 static const Real PROPELLER_ROD_RADIUS = 0.013f;
30 static const Real PROPELLER_ROD_HEIGHT = 0.011f;
31 static const Real PROPELLER_ROD_BOTTOM = ARM_TOP;
32 static const Real PROPELLER_ROD_TOP = PROPELLER_ROD_BOTTOM + PROPELLER_ROD_HEIGHT;
34 static const Real PROPELLER_BLADE_RADIUS = 0.041f;
35 static const Real PROPELLER_BLADE_ELEVATION = 0.0105f;
37 static const Real ONE_OVER_SR2 = 1.0f /
Sqrt(2.0f);
45 m_unLists = glGenLists(1);
47 glNewList(m_unLists, GL_COMPILE);
56 glDeleteLists(m_unLists, 1);
64 glCallList(m_unLists);
71 const GLfloat pfColor[] = { 0.00f, 0.00f, 0.00f, 1.00f };
72 const GLfloat pfSpecular[] = { 0.90f, 0.90f, 0.90f, 1.00f };
73 const GLfloat pfShininess[] = { 100.00f };
74 const GLfloat pfEmission[] = { 0.00f, 0.00f, 0.00f, 1.00f };
75 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
76 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
77 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
78 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
85 const GLfloat pfColor[] = { 0.00f, 1.00f, 0.00f, 1.00f };
86 const GLfloat pfSpecular[] = { 0.90f, 0.90f, 0.90f, 1.00f };
87 const GLfloat pfShininess[] = { 100.00f };
88 const GLfloat pfEmission[] = { 0.00f, 0.00f, 0.00f, 1.00f };
89 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
90 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
91 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
92 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
99 const GLfloat pfColor[] = { 0.75f, 0.75f, 0.75f, 1.00f };
100 const GLfloat pfSpecular[] = { 0.90f, 0.90f, 0.90f, 1.00f };
101 const GLfloat pfShininess[] = { 100.00f };
102 const GLfloat pfEmission[] = { 0.00f, 0.00f, 0.00f, 1.00f };
103 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
104 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
105 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
106 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
119 glRotated(90.0f, 0.0f, 0.0f, 1.0f);
125 glTranslated(0.0f, ARM_HALF_LENGTH - PROPELLER_ROD_RADIUS, 0.0f);
130 glTranslated(ARM_HALF_LENGTH - PROPELLER_ROD_RADIUS, 0.0f, 0.0f);
135 glTranslated(0.0f, -ARM_HALF_LENGTH + PROPELLER_ROD_RADIUS, 0.0f);
140 glTranslated(-ARM_HALF_LENGTH + PROPELLER_ROD_RADIUS, 0.0f, 0.0f);
152 glNormal3d(0.0f, 0.0f, -1.0f);
153 glVertex3d( 0.0f, BOARD_HALF_DIAGONAL, 0.0f );
154 glVertex3d( BOARD_HALF_DIAGONAL, 0.0f, 0.0f );
155 glVertex3d( 0.0f, -BOARD_HALF_DIAGONAL, 0.0f );
156 glVertex3d(-BOARD_HALF_DIAGONAL, 0.0f, 0.0f );
158 glNormal3d(0.0f, 0.0f, 1.0f);
159 glVertex3d( 0.0f, BOARD_HALF_DIAGONAL, BOARD_HEIGHT);
160 glVertex3d(-BOARD_HALF_DIAGONAL, 0.0f, BOARD_HEIGHT);
161 glVertex3d( 0.0f, -BOARD_HALF_DIAGONAL, BOARD_HEIGHT);
162 glVertex3d( BOARD_HALF_DIAGONAL, 0.0f, BOARD_HEIGHT);
165 glNormal3d( ONE_OVER_SR2, ONE_OVER_SR2, 0.0f );
166 glVertex3d( 0.0f, BOARD_HALF_DIAGONAL, 0.0f );
167 glVertex3d( 0.0f, BOARD_HALF_DIAGONAL, BOARD_HEIGHT);
168 glVertex3d( BOARD_HALF_DIAGONAL, 0.0f, BOARD_HEIGHT);
169 glVertex3d( BOARD_HALF_DIAGONAL, 0.0f, 0.0f );
171 glNormal3d( ONE_OVER_SR2, -ONE_OVER_SR2, 0.0f );
172 glVertex3d( BOARD_HALF_DIAGONAL, 0.0f, 0.0f );
173 glVertex3d( BOARD_HALF_DIAGONAL, 0.0f, BOARD_HEIGHT);
174 glVertex3d( 0.0f, -BOARD_HALF_DIAGONAL, BOARD_HEIGHT);
175 glVertex3d( 0.0f, -BOARD_HALF_DIAGONAL, 0.0f );
177 glNormal3d( -ONE_OVER_SR2, -ONE_OVER_SR2, 0.0f );
178 glVertex3d( 0.0f, -BOARD_HALF_DIAGONAL, 0.0f );
179 glVertex3d( 0.0f, -BOARD_HALF_DIAGONAL, BOARD_HEIGHT);
180 glVertex3d(-BOARD_HALF_DIAGONAL, 0.0f, BOARD_HEIGHT);
181 glVertex3d(-BOARD_HALF_DIAGONAL, 0.0f, 0.0f );
183 glNormal3d( -ONE_OVER_SR2, ONE_OVER_SR2, 0.0f );
184 glVertex3d(-BOARD_HALF_DIAGONAL, 0.0f, 0.0f );
185 glVertex3d(-BOARD_HALF_DIAGONAL, 0.0f, BOARD_HEIGHT);
186 glVertex3d( 0.0f, BOARD_HALF_DIAGONAL, BOARD_HEIGHT);
187 glVertex3d( 0.0f, BOARD_HALF_DIAGONAL, 0.0f );
198 glNormal3d( 0.0f, 0.0f, -1.0f );
199 glVertex3d( ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_BOTTOM);
200 glVertex3d( ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_BOTTOM);
201 glVertex3d(-ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_BOTTOM);
202 glVertex3d(-ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_BOTTOM);
204 glNormal3d( 0.0f, 0.0f, 1.0f );
205 glVertex3d( ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_TOP );
206 glVertex3d(-ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_TOP );
207 glVertex3d(-ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_TOP );
208 glVertex3d( ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_TOP );
211 glNormal3d( 1.0f, 0.0f, 0.0f );
212 glVertex3d( ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_TOP );
213 glVertex3d( ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_BOTTOM);
214 glVertex3d(-ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_BOTTOM);
215 glVertex3d(-ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_TOP );
217 glNormal3d( 0.0f, 1.0f, 0.0f );
218 glVertex3d( ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_TOP );
219 glVertex3d( ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_TOP );
220 glVertex3d( ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_BOTTOM);
221 glVertex3d( ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_BOTTOM);
223 glNormal3d(-1.0f, 0.0f, 0.0f );
224 glVertex3d( ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_TOP );
225 glVertex3d(-ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_TOP );
226 glVertex3d(-ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_BOTTOM);
227 glVertex3d( ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_BOTTOM);
229 glNormal3d( 0.0f, -1.0f, 0.0f );
230 glVertex3d(-ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_TOP );
231 glVertex3d(-ARM_HALF_WIDTH, ARM_HALF_LENGTH, ARM_BOTTOM);
232 glVertex3d(-ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_BOTTOM);
233 glVertex3d(-ARM_HALF_WIDTH, -ARM_HALF_LENGTH, ARM_TOP );
246 glBegin(GL_QUAD_STRIP);
247 for(GLuint i = 0; i <= m_unVertices; i++) {
248 glNormal3d(cNormal.
GetX(), cNormal.
GetY(), 0.0f);
250 cVertex *= PROPELLER_ROD_RADIUS;
251 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), PROPELLER_ROD_TOP);
252 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), PROPELLER_ROD_BOTTOM);
257 cVertex.
Set(PROPELLER_ROD_RADIUS, 0.0f);
259 glNormal3d(0.0f, 0.0f, 1.0f);
260 for(GLuint i = 0; i <= m_unVertices; i++) {
261 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), PROPELLER_ROD_TOP);
266 cVertex.
Set(PROPELLER_ROD_RADIUS, 0.0f);
269 glNormal3d(0.0f, 0.0f, -1.0f);
270 for(GLuint i = 0; i <= m_unVertices; i++) {
271 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), PROPELLER_ROD_BOTTOM);
277 cVertex.
Set(PROPELLER_BLADE_RADIUS, 0.0f);
279 glDisable(GL_CULL_FACE);
281 glNormal3d(0.0f, 0.0f, 1.0f);
282 for(GLuint i = 0; i <= m_unVertices; i++) {
283 glVertex3d(cVertex.
GetX(), cVertex.
GetY(), PROPELLER_BLADE_ELEVATION);
287 glEnable(GL_CULL_FACE);
300 m_cModel.
Draw(c_entity);
float Real
Collects all ARGoS code.
The namespace containing all the ARGoS related code.
REGISTER_QTOPENGL_ENTITY_OPERATION(CQTOpenGLOperationDrawNormal, CQTOpenGLOperationDrawEPuckNormal, CEPuckEntity)
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()
void ApplyTo(CQTOpenGLWidget &c_visualization, CMiniQuadrotorEntity &c_entity)
void ApplyTo(CQTOpenGLWidget &c_visualization, CMiniQuadrotorEntity &c_entity)
void MakePropeller()
One of the four propellers.
virtual void Draw(CMiniQuadrotorEntity &c_entity)
void SetBoardMaterial()
Sets the board material.
virtual ~CQTOpenGLMiniQuadrotor()
void MakeBody()
The robot body.
void MakeArm()
On of the two trasversal arms to which propellers are attached.
void MakeBoard()
The robot board.
void SetBladeMaterial()
Sets the blade material.
void SetBodyMaterial()
Sets the body material.
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.