Eclipse SUMO - Simulation of Urban MObility
GUIBaseVehicleHelper.cpp
Go to the documentation of this file.
1/****************************************************************************/
2// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.org/sumo
3// Copyright (C) 2001-2022 German Aerospace Center (DLR) and others.
4// This program and the accompanying materials are made available under the
5// terms of the Eclipse Public License 2.0 which is available at
6// https://www.eclipse.org/legal/epl-2.0/
7// This Source Code may also be made available under the following Secondary
8// Licenses when the conditions for such availability set forth in the Eclipse
9// Public License 2.0 are satisfied: GNU General Public License, version 2
10// or later which is available at
11// https://www.gnu.org/licenses/old-licenses/gpl-2.0-standalone.html
12// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-or-later
13/****************************************************************************/
18// Functions used in GUIBaseVehicleHelper and GNEVehicle
19/****************************************************************************/
20#include <config.h>
22
28#include "GLHelper.h"
30
31
32// ===========================================================================
33// data definitions
34// ===========================================================================
35/* -------------------------------------------------------------------------
36 * drawed shapes
37 * ----------------------------------------------------------------------- */
38static const double vehiclePoly_PassengerCarBody[] = { .5, 0, 0, 0, 0, .3, 0.08, .44, 0.25, .5, 0.95, .5, 1., .4, 1., -.4, 0.95, -.5, 0.25, -.5, 0.08, -.44, 0, -.3, 0, 0, -10000 };
39static const double vehiclePoly_PassengerCarBodyFront[] = { 0.1, 0, 0.025, 0, 0.025, 0.25, 0.27, 0.4, 0.27, -.4, 0.025, -0.25, 0.025, 0, -10000 };
40static const double vehiclePoly_PassengerFrontGlass[] = { 0.35, 0, 0.3, 0, 0.3, 0.4, 0.43, 0.3, 0.43, -0.3, 0.3, -0.4, 0.3, 0, -10000 };
41static const double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
42static const double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
43static const double vehiclePoly_PassengerSedanBackGlass[] = { 0.80, 0, 0.70, 0, 0.70, 0.3, 0.83, 0.4, 0.83, -.4, 0.70, -.3, 0.70, 0, -10000 };
44static const double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
45static const double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
46static const double vehiclePoly_PassengerHatchbackBackGlass[] = { 0.92, 0, 0.80, 0, 0.80, 0.3, 0.95, 0.4, 0.95, -.4, 0.80, -.3, 0.80, 0, -10000 };
47static const double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
48static const double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
49static const double vehiclePoly_PassengerWagonBackGlass[] = { 0.92, 0, 0.90, 0, 0.90, 0.3, 0.95, 0.4, 0.95, -.4, 0.90, -.3, 0.90, 0, -10000 };
50
51static const double vehiclePoly_PassengerVanBody[] = { .5, 0, 0, 0, 0, .4, 0.1, .5, 0.97, .5, 1., .47, 1., -.47, 0.97, -.5, 0.1, -.5, 0, -.4, 0, 0, -10000 };
52static const double vehiclePoly_PassengerVanBodyFront[] = { 0.1, 0, 0.025, 0, 0.025, 0.25, 0.13, 0.4, 0.13, -.4, 0.025, -0.25, 0.025, 0, -10000 };
53static const double vehiclePoly_PassengerVanFrontGlass[] = { 0.21, 0, 0.16, 0, 0.16, 0.4, 0.29, 0.3, 0.29, -0.3, 0.16, -0.4, 0.16, 0, -10000 };
54static const double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
55static const double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
56static const double vehiclePoly_PassengerVanBackGlass[] = { 0.95, 0, 0.94, 0, 0.94, 0.3, 0.98, 0.4, 0.98, -.4, 0.94, -.3, 0.94, 0, -10000 };
57
58static const double vehiclePoly_TaxiSign[] = { .56, .241, .56, -.241, .49, -.241, .49, .241, -10000 };
59
60static const double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
61static const double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
62
63static const double vehiclePoly_TransportBody[] = { .5, 0, 0, 0, 0, .45, 0.05, .5, 2.25, .5, 2.25, -.5, 0.05, -.5, 0, -.45, 0, 0, -10000 };
64static const double vehiclePoly_TransportFrontGlass[] = { 0.1, 0, 0.05, 0, 0.05, 0.45, 0.25, 0.4, 0.25, -.4, 0.05, -0.45, 0.05, 0, -10000 };
65static const double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
66static const double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
67
68static const double vehiclePoly_EVehicleBody[] = { .5, 0, 0, 0, 0, .3, 0.08, .44, 0.25, .5, 0.75, .5, .92, .44, 1, .3, 1, -.3, .92, -.44, .75, -.5, .25, -.5, 0.08, -.44, 0, -.3, 0, 0, -1000 };
69static const double vehiclePoly_EVehicleFrontGlass[] = { .5, 0, 0.05, .05, 0.05, .25, 0.13, .39, 0.3, .45, 0.70, .45, .87, .39, .95, .25, .95, -.25, .87, -.39, .70, -.45, .3, -.45, 0.13, -.39, 0.05, -.25, 0.05, 0.05, -1000 };
70//static const double vehiclePoly_EVehicleFrontGlass[] = { 0.35,0, 0.1,0, 0.1,0.4, 0.43,0.3, 0.43,-0.3, 0.1,-0.4, 0.1,0, -10000 };
71//static const double vehiclePoly_EVehicleBackGlass[] = { 0.65, 0, 0.9, 0, 0.9, 0.4, 0.57, 0.3, 0.57, -0.3, 0.9, -0.4, 0.9, 0, -10000 };
72
73static const double vehiclePoly_Ship[] = { 0.25, 0, 0, 0, 0.1, 0.25, 0.2, 0.45, 0.25, 0.5, 0.95, 0.5, 1.0, 0.45, 1.0, -0.45, 0.95, -0.5, 0.25, -0.5, 0.2, -0.45, 0.1, -0.25, 0, 0, -10000 };
74static const double vehiclePoly_ShipDeck[] = { 0.5, 0, 0.25, 0.4, 0.95, 0.4, 0.95, -0.4, 0.25, -0.4, 0.25, 0.4, -10000 };
75static const double vehiclePoly_ShipSuperStructure[] = { 0.8, 0, 0.5, 0.3, 0.85, 0.3, 0.85, -0.3, 0.5, -0.3, 0.5, 0.3, -10000 };
76
77static const double vehiclePoly_Cyclist[] = { 0.5, 0, 0.25, 0.45, 0.25, 0.5, 0.8, 0.15, 0.8, -0.15, 0.25, -0.5, 0.25, -0.45, -10000 };
78static const double vehiclePoly_BicycleSeat[] = { 0.565, 0, 0.570, 0.03, 0.575, 0.05, 0.585, 0.06, 0.645, 0.06, 0.665, 0.07, 0.685, 0.10, 0.695, 0.13, 0.715, 0.16, 0.735, 0.18, 0.742, 0.17, 0.745, 0.16, 0.755, 0.13, 0.76, 0.11, 0.765, 0, 0.76, -0.11, 0.755, -0.13, 0.745, -0.16, 0.742, -0.17, 0.735, -0.18, 0.715, -0.16, 0.695, -0.13, 0.685, -0.10, 0.665, -0.07, 0.645, -0.06, 0.585, -0.06, 0.575, -0.05, 0.57, -0.03, -10000 };
79static const double vehiclePoly_MotorcycleSeat[] = { 0.5, 0, 0.503, 0.072, 0.506, 0.097, 0.518, 0.135, 0.539, 0.162, 0.567, 0.183, 0.641, 0.194, 0.698, 0.202, 0.706, 0.194, 0.713, 0.189, 0.721, 0.162, 0.729, 0.132, 0.732, 0.097, 0.734, 0.051, 0.735, 0, 0.734, -0.051, 0.732, -0.097, 0.729, -0.132, 0.721, -0.162, 0.713, -0.189, 0.706, -0.194, 0.698, -0.202, 0.641, -0.194, 0.567, -0.183, 0.539, -0.162, 0.518, -0.135, 0.506, -0.097, 0.503, -0.072, -10000 };
80
81static const double vehiclePoly_EmergencySign[] = { .2, .5, -.2, .5, -.2, -.5, .2, -.5, -10000 };
82static const double vehiclePoly_Emergency[] = { .1, .1, -.1, .1, -.1, -.1, .1, -.1, -10000 };
83static const double vehiclePoly_Emergency2[] = { .04, .3, -.04, .3, -.04, -.3, .04, -.3, -10000 };
84
85static const double vehiclePoly_EmergencyLadder[] = { -.5, .3, .5, .3, .5, .2, -.5, .2, -10000 };
86static const double vehiclePoly_EmergencyLadder2[] = { -.5, -.3, .5, -.3, .5, -.2, -.5, -.2, -10000 };
87static const double vehiclePoly_EmergencyLadder3[] = { -.45, .3, -.4, .3, -.4, -.3, -.45, -.3, -10000 };
88static const double vehiclePoly_EmergencyLadder4[] = { .45, .3, .4, .3, .4, -.3, .45, -.3, -10000 };
89static const double vehiclePoly_EmergencyLadder5[] = { .05, .3, .0, .3, .0, -.3, .05, -.3, -10000 };
90static const double vehiclePoly_EmergencyLadder6[] = { -.25, .3, -.2, .3, -.2, -.3, -.25, -.3, -10000 };
91static const double vehiclePoly_EmergencyLadder7[] = { .25, .3, .2, .3, .2, -.3, .25, -.3, -10000 };
92
93static const double vehiclePoly_scooterBase[] = { -.17, .3, -.2, .3, -.2, -.3, -.17, -.3, -10000 };
94static const double vehiclePoly_scooterBase2[] = { .27, .03, .28, .03, .28, -.03, .27, -.03, -10000 };
95static const double vehiclePoly_scooterBase3[] = { -.5, .6, .5, .6, .5, -.6, -.5, -.6, -10000 };
96
97//static const double vehiclePoly_Rickshaw[] = { 0.5, 0, 0.25, 0.45, 0.25, 0.5, 0.8, 0.15, 0.8, -0.15, 0.25, -0.5, 0.25, -0.45, -10000 };
98
99// ===========================================================================
100// method definitions
101// ===========================================================================
102
103void
104GUIBaseVehicleHelper::drawPoly(const double* poses, const double offset) {
106 glTranslated(0, 0, offset * .1);
107 glPolygonOffset(0, (GLfloat) - offset);
108 glBegin(GL_TRIANGLE_FAN);
109 int i = 0;
110 while (poses[i] > -999) {
111 glVertex2d(poses[i], poses[i + 1]);
112 i = i + 2;
113 }
114 glEnd();
116}
117
118void
119GUIBaseVehicleHelper::drawAction_drawVehicleAsBoxPlus(const double width, const double length) {
121 glScaled(width, length, 1.);
122 glBegin(GL_TRIANGLE_STRIP);
123 glVertex2d(0., 0.);
124 glVertex2d(-.5, .15);
125 glVertex2d(.5, .15);
126 glVertex2d(-.5, 1.);
127 glVertex2d(.5, 1.);
128 glEnd();
130}
131
132
133void
134GUIBaseVehicleHelper::drawAction_drawVehicleAsTrianglePlus(const double width, const double length) {
135 if (length >= 8.) {
136 drawAction_drawVehicleAsBoxPlus(width, length);
137 return;
138 }
140 glScaled(width, length, 1.);
141 glBegin(GL_TRIANGLES);
142 glVertex2d(0., 0.);
143 glVertex2d(-.5, 1.);
144 glVertex2d(.5, 1.);
145 glEnd();
147}
148
149
150void
152 const int steps = MIN2(MAX2(16, int(detail / 5)), 64);
153 GLHelper::drawFilledCircle(width / 2, steps);
154}
155
156void
157GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(const GUIVisualizationSettings& s, const SUMOVehicleShape shape, const double width, const double length,
158 int carriageIndex, bool isStopped) {
160 RGBColor current = GLHelper::getColor();
161 RGBColor lighter = current.changedBrightness(51);
162 RGBColor darker = current.changedBrightness(-51);
164 glRotated(90, 0, 0, 1);
165 glScaled(length, width, 1.);
166
167 // draw main body
168 switch (shape) {
171 GLHelper::setColor(lighter);
173 glColor3d(0, 0, 0);
175 break;
177 glTranslated(0, 0, .045);
179 glTranslated(0, 0, -.045);
180 glScaled(.7, 2, 1);
181 glTranslated(0, 0, .04);
182 GLHelper::setColor(lighter);
184 glTranslated(0, 0, -.04);
185 break;
189 darker = current.changedBrightness(-50);
190 if (!isStopped) {
191 // body
193 // head
195 glTranslated(0.4, 0, .5);
196 glScaled(0.1, 0.2, 1);
197 GLHelper::setColor(darker);
200 } else if (shape == SUMOVehicleShape::BICYCLE) {
201 // seat
202 GLHelper::setColor(darker);
204 } else {
205 // seat
206 GLHelper::setColor(darker);
208 }
209 // bike frame
212 glTranslated(0.5, 0, .3);
213 glScaled(0.5, 0.05, 1);
216 // handle bar
218 glTranslated(0.25, 0, .3);
219 glScaled(0.02, 0.5, 1);
222 }
223 break;
230 GLHelper::setColor(lighter);
232 glColor3d(0, 0, 0);
234 break;
237 GLHelper::setColor(lighter);
239 glColor3d(0, 0, 0);
244 break;
247 GLHelper::setColor(lighter);
249 glColor3d(0, 0, 0);
253 break;
257 if (carriageIndex < 1) {
258 glScaled(1. / (length), 1, 1.);
260 glColor3d(0, 0, 0);
264 }
265 break;
269 double ml = length;
270 glScaled(1. / (length), 1, 1.);
271 glTranslated(0, 0, .04);
272 glBegin(GL_TRIANGLE_FAN);
273 glVertex2d(ml / 2., 0);
274 glVertex2d(0, 0);
275 glVertex2d(0, -.45);
276 glVertex2d(0 + .05, -.5);
277 glVertex2d(ml - .05, -.5);
278 glVertex2d(ml, -.45);
279 glVertex2d(ml, .45);
280 glVertex2d(ml - .05, .5);
281 glVertex2d(0 + .05, .5);
282 glVertex2d(0, .45);
283 glVertex2d(0, 0);
284 glEnd();
285 glTranslated(0, 0, -.04);
286
287 glTranslated(0, 0, .045);
288 glColor3d(0, 0, 0);
289 glBegin(GL_QUADS);
290 glVertex2d(0 + .05, .48);
291 glVertex2d(0 + .05, -.48);
292 glVertex2d(0 + .15, -.48);
293 glVertex2d(0 + .15, .48);
294
295 glVertex2d(ml - .1, .45);
296 glVertex2d(ml - .1, -.45);
297 glVertex2d(ml - .05, -.45);
298 glVertex2d(ml - .05, .45);
299
300 glVertex2d(0 + .20, .49);
301 glVertex2d(0 + .20, .45);
302 glVertex2d(ml - .20, .45);
303 glVertex2d(ml - .20, .49);
304
305 glVertex2d(0 + .20, -.49);
306 glVertex2d(0 + .20, -.45);
307 glVertex2d(ml - .20, -.45);
308 glVertex2d(ml - .20, -.49);
309
310 glEnd();
311 glTranslated(0, 0, -.045);
312 }
313 break;
318 // generic rail carriage (see GUIVehicle::drawAction_drawCarriageClass)
319 glRotated(-90, 0, 0, 1);
320 const double xCornerCut = 0.3 / width;
321 const double yCornerCut = 0.4 / length;
322 const double drawnCarriageLength = 1;
323 const double halfWidth = 0.5;
324 glBegin(GL_TRIANGLE_FAN);
325 glVertex2d(-halfWidth + xCornerCut, 0);
326 glVertex2d(-halfWidth, yCornerCut);
327 glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
328 glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
329 glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
330 glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
331 glVertex2d(halfWidth, yCornerCut);
332 glVertex2d(halfWidth - xCornerCut, 0);
333 glEnd();
334 // assume we are only rendering the head of the train (carriage rendering was disabled via param)
335 glTranslated(0, 0, 0.1);
336 glColor3d(0, 0, 0);
337 glBegin(GL_TRIANGLE_FAN);
338 glVertex2d(-halfWidth + 2 * xCornerCut, yCornerCut);
339 glVertex2d(-halfWidth + xCornerCut, 3 * yCornerCut);
340 glVertex2d(halfWidth - xCornerCut, 3 * yCornerCut);
341 glVertex2d(halfWidth - 2 * xCornerCut, yCornerCut);
342 glEnd();
343 }
344 break;
345
348 glColor3d(0, 0, 0);
350 glTranslated(0, 0, .048);
351 GLHelper::setColor(current);
352 glBegin(GL_QUADS);
353 glVertex2d(.3, .5);
354 glVertex2d(.35, .5);
355 glVertex2d(.35, -.5);
356 glVertex2d(.3, -.5);
357
358 glVertex2d(.3, -.05);
359 glVertex2d(.7, -.05);
360 glVertex2d(.7, .05);
361 glVertex2d(.3, .05);
362
363 glVertex2d(.7, .5);
364 glVertex2d(.65, .5);
365 glVertex2d(.65, -.5);
366 glVertex2d(.7, -.5);
367 glEnd();
368 glTranslated(0, 0, -.048);
369 //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
370 break;
373 // ant is stretched via vehicle length
374 GLHelper::setColor(darker);
375 // draw left side
376 GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
377 GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
378 GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
379 GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
380 GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
381 GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
382 GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
383 GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
384 // draw right side
385 GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
386 GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
387 GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
388 GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
389 GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
390 GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
391 GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
392 GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
393 // draw body
394 GLHelper::setColor(current);
395 glTranslated(0, 0, 0.1);
397 glTranslated(.4, 0, 0);
399 glTranslated(.4, 0, 0);
402 break;
409 break;
410 }
411 case SUMOVehicleShape::EMERGENCY: // similar to delivery
413 GLHelper::setColor(darker);
415 glColor3d(0, 0, 0);
419 // first aid sign
420 glTranslated(0.7, 0, 0);
421 glColor3d(.18, .55, .34);
423 glColor3d(1, 1, 1);
426 break;
427 case SUMOVehicleShape::FIREBRIGADE: // similar to delivery in red orange
429 GLHelper::setColor(lighter);
431 glColor3d(0, 0, 0);
435 // draw ladder
436 glTranslated(0.7, 0, 0);
437 glColor3d(1, .5, 0);
439 glColor3d(.5, .5, .5);
447 break;
448 case SUMOVehicleShape::POLICE: // similar to passenger grey with blue
450 GLHelper::setColor(lighter);
452 glColor3d(0, 0, 0);
454 // first aid sign
455 glTranslated(0.7, 0, 0);
456 glColor3d(.5, .5, .5);
458 glColor3d(0, 0, 1);
461 break;
462 case SUMOVehicleShape::RICKSHAW: // Rickshaw
464 // wheels
465 GLHelper::setColor(darker);
467 glTranslated(.5, .5, -0.1);
470 //other wheel
472 glTranslated(.5, -.5, -0.1);
475 break;
477 RGBColor darker2 = current.changedBrightness(-25);
479 // front small oval
480 GLHelper::setColor(darker);
481 glTranslated(-0.20, 0, 0.15);
482 glScaled(0.04, 0.06, 0.7);
485 // handlebar
487 glTranslated(0.0, 0, 0.1);
488 glColor3d(0.3, 0.3, 0.3);
491 // front oval
493 GLHelper::setColor(darker2);
494 glTranslated(-0.21, 0, 0.1);
495 glScaled(0.07, 0.08, 0.9);
498 // tail rectangle
500 glColor3d(0.3, 0.3, 0.3);
502 // tail oval
503 GLHelper::setColor(darker2);
504 glTranslated(0.21, 0, 0.1);
505 glScaled(0.07, 0.08, 0.9);
508 // base oval
510 GLHelper::setColor(lighter);
511 glScaled(0.28, 0.14, 0.9);
513 // center rectangle
514 glTranslated(0, 0, 0.1);
515 GLHelper::setColor(current);
518 break;
519 }
520 default: // same as passenger
522 glColor3d(1, 1, 1);
524 glColor3d(0, 0, 0);
526 break;
527 }
528
529 // draw decorations
530 switch (shape) {
532 break;
534 //glScaled(length, 1, 1.);
535 glBegin(GL_TRIANGLE_FAN);
536 glVertex2d(1 / 2., 0);
537 glVertex2d(0, 0);
538 glVertex2d(0, -.03);
539 glVertex2d(0 + .05, -.05);
540 glVertex2d(1 - .05, -.05);
541 glVertex2d(1, -.03);
542 glVertex2d(1, .03);
543 glVertex2d(1 - .05, .05);
544 glVertex2d(0 + .05, .05);
545 glVertex2d(0, .03);
546 glVertex2d(0, 0);
547 glEnd();
548 break;
551 //glScaled(length, 1, 1.);
552 glBegin(GL_TRIANGLE_FAN);
553 glVertex2d(1 / 2., 0);
554 glVertex2d(0, 0);
555 glVertex2d(0, -.03);
556 glVertex2d(0 + .05, -.2);
557 glVertex2d(1 - .05, -.2);
558 glVertex2d(1, -.03);
559 glVertex2d(1, .03);
560 glVertex2d(1 - .05, .2);
561 glVertex2d(0 + .05, .2);
562 glVertex2d(0, .03);
563 glVertex2d(0, 0);
564 glEnd();
565 break;
571 break;
576 break;
581 break;
584 break;
589
590 glTranslated(0, 0, 6);
591 glColor3d(0, 0, 0);
592 // square-pattern in front
593 glRectd(0.146, 0.24675, 0.171, 0.176);
594 glRectd(0.121, 0.176, 0.146, 0.1055);
595 glRectd(0.146, 0.1055, 0.171, 0.035);
596 glRectd(0.121, 0.035, 0.146, -0.035);
597 glRectd(0.146, -0.1055, 0.171, -0.035);
598 glRectd(0.121, -0.176, 0.146, -0.1055);
599 glRectd(0.146, -0.24675, 0.171, -0.176);
600 // square-pattern at the back
601 glRectd(0.913, 0.24675, 0.938, 0.176);
602 glRectd(0.888, 0.176, 0.913, 0.1055);
603 glRectd(0.888, 0.176, 0.913, 0.1055);
604 glRectd(0.913, 0.1055, 0.938, 0.035);
605 glRectd(0.888, 0.035, 0.913, -0.035);
606 glRectd(0.913, -0.1055, 0.938, -0.035);
607 glRectd(0.888, -0.176, 0.913, -0.1055);
608 glRectd(0.888, -0.176, 0.913, -0.1055);
609 glRectd(0.913, -0.24675, 0.938, -0.176);
610
611 GLHelper::setColor(darker);
613 glScaled(0.2, 0.5, 1);
614 GLHelper::drawText("TAXI", Position(2.58, 0), 5, 0.3, RGBColor::BLACK, 90);
615 break;
617 GLHelper::setColor(current);
618 GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
619 break;
621 if (carriageIndex < 0) {
622 GLHelper::setColor(current);
623 GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
624 }
625 break;
627 GLHelper::setColor(current);
628 double l = length - 2.3;
629 if (carriageIndex != 0) {
630 l = l / 2.;
631 GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
632 GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
633 } else {
634 GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
635 }
636 break;
637 }
640 glTranslated(0, 0, .1);
641 GLHelper::setColor(darker);
642 GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
643 glTranslated(0, 0, .1);
644 glColor3d(0, 0, 0);
645 GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
646 GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
647 GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
648 GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
650 break;
665 break;
666 default: // same as passenger/sedan
670 break;
671 }
672 /*
673 glBegin(GL_TRIANGLE_FAN);
674 glVertex2d(.5,.5); // center - strip begin
675 glVertex2d(0, .5); // center, front
676 glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
677 glVertex2d(0.08, .94);
678 glVertex2d(0.25, 1.);
679 glVertex2d(0.95, 1.);
680 glVertex2d(1., .9);
681 glVertex2d(1., .1); // (vehicle left side)
682 glVertex2d(0.95, 0.);
683 glVertex2d(0.25, 0.);
684 glVertex2d(0.08, .06);
685 glVertex2d(0, .2); //
686 glVertex2d(0, .5); // center, front (close)
687 glEnd();
688
689 glPolygonOffset(0, -4.5);
690 glColor3d(1, 1, 1); // front
691 glBegin(GL_TRIANGLE_FAN);
692 glVertex2d(0.1,0.5);
693 glVertex2d(0.025,0.5);
694 glVertex2d(0.025,0.75);
695 glVertex2d(0.27,0.9);
696 glVertex2d(0.27,0.1);
697 glVertex2d(0.025,0.25);
698 glVertex2d(0.025,0.5);
699 glEnd();
700
701 glColor3d(0, 0, 0); // front glass
702 glBegin(GL_TRIANGLE_FAN);
703 glVertex2d(0.35,0.5);
704 glVertex2d(0.3,0.5);
705 glVertex2d(0.3,0.9);
706 glVertex2d(0.43,0.8);
707 glVertex2d(0.43,0.2);
708 glVertex2d(0.3,0.1);
709 glVertex2d(0.3,0.5);
710 glEnd();
711
712 glBegin(GL_TRIANGLE_FAN); // back glass
713 glVertex2d(0.92,0.5);
714 glVertex2d(0.90,0.5);
715 glVertex2d(0.90,0.8);
716 glVertex2d(0.95,0.9);
717 glVertex2d(0.95,0.1);
718 glVertex2d(0.90,0.2);
719 glVertex2d(0.90,0.5);
720 glEnd();
721
722 glBegin(GL_TRIANGLE_FAN); // right glass
723 glVertex2d(0.36,0.07);
724 glVertex2d(0.34,0.03);
725 glVertex2d(0.94,0.03);
726 glVertex2d(0.87,0.13);
727 glVertex2d(0.45,0.13);
728 glVertex2d(0.34,0.03);
729 glEnd();
730
731 glBegin(GL_TRIANGLE_FAN); // left glass
732 glVertex2d(0.36,1.-0.07);
733 glVertex2d(0.34,1.-0.03);
734 glVertex2d(0.94,1.-0.03);
735 glVertex2d(0.87,1.-0.13);
736 glVertex2d(0.45,1.-0.13);
737 glVertex2d(0.34,1.-0.03);
738 glEnd();
739 */
740
742}
743
744
745bool
746GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(const GUIVisualizationSettings& /* s */, const std::string& file, const GUIGlObject* /* o */, const double width, double length) {
747 if (file != "") {
748 int textureID = GUITexturesHelper::getTextureID(file);
749 if (textureID > 0) {
750 GUITexturesHelper::drawTexturedBox(textureID, -width * 0.5, 0, width * 0.5, length);
751 return true;
752 }
753 }
754 return false;
755}
756
757
758/****************************************************************************/
static const double vehiclePoly_PassengerVanRightGlass[]
static const double vehiclePoly_EmergencyLadder3[]
static const double vehiclePoly_PassengerVanBodyFront[]
static const double vehiclePoly_EVehicleFrontGlass[]
static const double vehiclePoly_ShipSuperStructure[]
static const double vehiclePoly_scooterBase[]
static const double vehiclePoly_MotorcycleSeat[]
static const double vehiclePoly_PassengerVanBody[]
static const double vehiclePoly_PassengerWagonLeftGlass[]
static const double vehiclePoly_TransportFrontGlass[]
static const double vehiclePoly_PassengerHatchbackRightGlass[]
static const double vehiclePoly_DeliveryMediumRightGlass[]
static const double vehiclePoly_PassengerHatchbackLeftGlass[]
static const double vehiclePoly_Ship[]
static const double vehiclePoly_EmergencyLadder6[]
static const double vehiclePoly_PassengerSedanLeftGlass[]
static const double vehiclePoly_Emergency2[]
static const double vehiclePoly_PassengerVanBackGlass[]
static const double vehiclePoly_EmergencyLadder7[]
static const double vehiclePoly_PassengerHatchbackBackGlass[]
static const double vehiclePoly_EmergencyLadder4[]
static const double vehiclePoly_PassengerFrontGlass[]
static const double vehiclePoly_EmergencyLadder2[]
static const double vehiclePoly_TransportLeftGlass[]
static const double vehiclePoly_PassengerVanLeftGlass[]
static const double vehiclePoly_Cyclist[]
static const double vehiclePoly_PassengerWagonBackGlass[]
static const double vehiclePoly_PassengerSedanRightGlass[]
static const double vehiclePoly_PassengerCarBodyFront[]
static const double vehiclePoly_scooterBase2[]
static const double vehiclePoly_scooterBase3[]
static const double vehiclePoly_TaxiSign[]
static const double vehiclePoly_EmergencySign[]
static const double vehiclePoly_TransportBody[]
static const double vehiclePoly_EmergencyLadder[]
static const double vehiclePoly_PassengerWagonRightGlass[]
static const double vehiclePoly_DeliveryMediumLeftGlass[]
static const double vehiclePoly_TransportRightGlass[]
static const double vehiclePoly_PassengerSedanBackGlass[]
static const double vehiclePoly_Emergency[]
static const double vehiclePoly_PassengerVanFrontGlass[]
static const double vehiclePoly_ShipDeck[]
static const double vehiclePoly_PassengerCarBody[]
static const double vehiclePoly_EVehicleBody[]
static const double vehiclePoly_BicycleSeat[]
static const double vehiclePoly_EmergencyLadder5[]
SUMOVehicleShape
Definition of vehicle classes to differ between different appearances.
@ RICKSHAW
render as a rickshaw
@ BUS
render as a bus
@ RAIL_CARGO
render as a cargo train
@ EMERGENCY
render as an emergency vehicle
@ RAIL
render as a rail
@ PASSENGER_VAN
render as a van
@ PASSENGER
render as a passenger vehicle
@ SCOOTER
render as a scooter
@ RAIL_CAR
render as a (city) rail without locomotive
@ SHIP
render as a arbitrary ship
@ DELIVERY
render as a delivery vehicle
@ BICYCLE
render as a bicycle
@ MOTORCYCLE
render as a motorcycle
@ UNKNOWN
not defined
@ BUS_TROLLEY
render as a trolley bus
@ TAXI
automated car (with cruise controllers)
@ E_VEHICLE
render as a (futuristic) e-vehicle
@ ANT
render as a giant ant
@ TRUCK
render as a transport vehicle
@ FIREBRIGADE
render as a fire brigade
@ PASSENGER_HATCHBACK
render as a hatchback passenger vehicle ("Fliessheck")
@ MOPED
render as a moped
@ BUS_FLEXIBLE
render as a flexible city bus
@ TRUCK_1TRAILER
render as a transport vehicle with one trailer
@ PASSENGER_SEDAN
render as a sedan passenger vehicle ("Stufenheck")
@ BUS_COACH
render as a coach
@ POLICE
render as a police car
@ PASSENGER_WAGON
render as a wagon passenger vehicle ("Combi")
@ TRUCK_SEMITRAILER
render as a semi-trailer transport vehicle ("Sattelschlepper")
@ PEDESTRIAN
render as a pedestrian
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:30
T MIN2(T a, T b)
Definition: StdDefs.h:71
T MAX2(T a, T b)
Definition: StdDefs.h:77
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:583
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:498
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:589
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:277
static void pushMatrix()
push matrix
Definition: GLHelper.cpp:117
static void drawText(const std::string &text, const Position &pos, const double layer, const double size, const RGBColor &col=RGBColor::BLACK, const double angle=0, const int align=0, double width=-1)
Definition: GLHelper.cpp:685
static void drawAction_drawVehicleAsTrianglePlus(const double width, const double length)
draw vehicle as a triangle
static bool drawAction_drawVehicleAsImage(const GUIVisualizationSettings &s, const std::string &file, const GUIGlObject *o, const double width, double length)
try to draw vehicle as raster image and return true if successful
static void drawAction_drawVehicleAsCircle(const double width, double detail)
draw vehicle as a circle
static void drawPoly(const double *poses, const double offset)
draw poly
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length)
draw vehicle as a Box
static void drawTexturedBox(int which, double size)
Draws a named texture as a box with the given size.
static int getTextureID(const std::string &filename, const bool mirrorX=false)
return texture id for the given filename (initialize on first use)
Stores the information about how to visualize structures.
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:37
static const RGBColor GREY
Definition: RGBColor.h:194
static const RGBColor BLACK
Definition: RGBColor.h:193
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:200