8 #include <argos3/core/utility/math/vector2.h>
9 #include <argos3/plugins/simulator/entities/led_equipped_entity.h>
10 #include <argos3/plugins/simulator/entities/box_entity.h>
11 #include <argos3/plugins/simulator/visualizations/qt-opengl/qtopengl_widget.h>
18 static const Real LED_RADIUS = 0.01f;
21 const GLfloat
SPECULAR[] = { 0.0f, 0.0f, 0.0f, 1.0f };
23 const GLfloat
EMISSION[] = { 0.0f, 0.0f, 0.0f, 1.0f };
32 m_unBaseList = glGenLists(2);
33 m_unBodyList = m_unBaseList;
34 m_unLEDList = m_unBaseList + 1;
37 glNewList(m_unBodyList, GL_COMPILE);
42 glNewList(m_unLEDList, GL_COMPILE);
52 glDeleteLists(m_unBaseList, 2);
60 GLfloat pfColor[] = { 0.0f, 0.0f, 0.0f, 1.0f };
61 const GLfloat pfSpecular[] = { 0.0f, 0.0f, 0.0f, 1.0f };
62 const GLfloat pfShininess[] = { 100.0f };
63 const GLfloat pfEmission[] = { 0.0f, 0.0f, 0.0f, 1.0f };
64 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, pfSpecular);
65 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS, pfShininess);
66 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, pfEmission);
68 for(
UInt32 i = 0; i < cLEDEquippedEntity.
GetLEDs().size(); ++i) {
72 pfColor[0] = cColor.
GetRed() / 255.0f;
73 pfColor[1] = cColor.
GetGreen() / 255.0f;
74 pfColor[2] = cColor.
GetBlue() / 255.0f;
75 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, pfColor);
78 glTranslated(cPosition.
GetX(), cPosition.
GetY(), cPosition.
GetZ());
80 glCallList(m_unLEDList);
91 glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE,
MOVABLE_COLOR);
98 glCallList(m_unBodyList);
105 void CQTOpenGLBox::MakeBody() {
108 glEnable(GL_NORMALIZE);
111 glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR,
SPECULAR);
112 glMaterialfv(GL_FRONT_AND_BACK, GL_SHININESS,
SHININESS);
113 glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION,
EMISSION);
120 glNormal3d(0.0f, 0.0f, -1.0f);
121 glVertex3d( 0.5f, 0.5f, 0.0f);
122 glVertex3d( 0.5f, -0.5f, 0.0f);
123 glVertex3d(-0.5f, -0.5f, 0.0f);
124 glVertex3d(-0.5f, 0.5f, 0.0f);
126 glNormal3d(0.0f, 0.0f, 1.0f);
127 glVertex3d(-0.5f, -0.5f, 1.0f);
128 glVertex3d( 0.5f, -0.5f, 1.0f);
129 glVertex3d( 0.5f, 0.5f, 1.0f);
130 glVertex3d(-0.5f, 0.5f, 1.0f);
135 glNormal3d(0.0f, -1.0f, 0.0f);
136 glVertex3d(-0.5f, -0.5f, 1.0f);
137 glVertex3d(-0.5f, -0.5f, 0.0f);
138 glVertex3d( 0.5f, -0.5f, 0.0f);
139 glVertex3d( 0.5f, -0.5f, 1.0f);
141 glNormal3d(1.0f, 0.0f, 0.0f);
142 glVertex3d( 0.5f, -0.5f, 1.0f);
143 glVertex3d( 0.5f, -0.5f, 0.0f);
144 glVertex3d( 0.5f, 0.5f, 0.0f);
145 glVertex3d( 0.5f, 0.5f, 1.0f);
147 glNormal3d(0.0f, 1.0f, 0.0f);
148 glVertex3d( 0.5f, 0.5f, 1.0f);
149 glVertex3d( 0.5f, 0.5f, 0.0f);
150 glVertex3d(-0.5f, 0.5f, 0.0f);
151 glVertex3d(-0.5f, 0.5f, 1.0f);
153 glNormal3d(-1.0f, 0.0f, 0.0f);
154 glVertex3d(-0.5f, 0.5f, 1.0f);
155 glVertex3d(-0.5f, 0.5f, 0.0f);
156 glVertex3d(-0.5f, -0.5f, 0.0f);
157 glVertex3d(-0.5f, -0.5f, 1.0f);
162 glDisable(GL_NORMALIZE);
168 void CQTOpenGLBox::MakeLED() {
169 CVector3 cNormal, cPoint;
172 glBegin(GL_TRIANGLE_STRIP);
173 for(CRadians cInclination; cInclination <=
CRadians::PI; cInclination += cSlice) {
176 cNormal.FromSphericalCoords(1.0f, cInclination, cAzimuth);
177 cPoint = LED_RADIUS * cNormal;
178 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
179 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
181 cNormal.FromSphericalCoords(1.0f, cInclination + cSlice, cAzimuth);
182 cPoint = LED_RADIUS * cNormal;
183 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
184 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
186 cNormal.FromSphericalCoords(1.0f, cInclination, cAzimuth + cSlice);
187 cPoint = LED_RADIUS * cNormal;
188 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
189 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
191 cNormal.FromSphericalCoords(1.0f, cInclination + cSlice, cAzimuth + cSlice);
192 cPoint = LED_RADIUS * cNormal;
193 glNormal3d(cNormal.GetX(), cNormal.GetY(), cNormal.GetZ());
194 glVertex3d(cPoint.GetX(), cPoint.GetY(), cPoint.GetZ());
210 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.
const GLfloat MOVABLE_COLOR[]
REGISTER_QTOPENGL_ENTITY_OPERATION(CQTOpenGLOperationDrawNormal, CQTOpenGLOperationDrawEPuckNormal, CEPuckEntity)
const GLfloat SHININESS[]
const GLfloat NONMOVABLE_COLOR[]
bool IsMovable() const
Returns true if the entity is movable.
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.
static const CRadians PI
The PI constant.
static const CRadians TWO_PI
Set to PI * 2.
Real GetX() const
Returns the x coordinate of this vector.
Real GetY() const
Returns the y coordinate of this vector.
Real GetZ() const
Returns the z coordinate of this vector.
CEmbodiedEntity & GetEmbodiedEntity()
CLEDEquippedEntity & GetLEDEquippedEntity()
const CVector3 & GetSize() const
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.
SActuator::TList & GetLEDs()
Returns all the LEDs.
const CVector3 & GetLEDOffset(size_t un_idx) const
Returns the offset position of the given LED.
void ApplyTo(CQTOpenGLWidget &c_visualization, CBoxEntity &c_entity)
void ApplyTo(CQTOpenGLWidget &c_visualization, CBoxEntity &c_entity)
virtual void DrawLEDs(CBoxEntity &c_entity)
virtual void Draw(const CBoxEntity &c_entity)
void DrawEntity(CPositionalEntity &c_entity)
Draws a positional entity.
void DrawBoundingBox(CEmbodiedEntity &c_entity)
Draws the bounding box of an embodied entity.