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-2020 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>
21 #include <fx.h>
22 
27 #include "GLHelper.h"
28 #include "GUIBaseVehicleHelper.h"
29 
30 
31 // ===========================================================================
32 // data definitions
33 // ===========================================================================
34 /* -------------------------------------------------------------------------
35  * drawed shapes
36  * ----------------------------------------------------------------------- */
37 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 };
38 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 };
39 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 };
40 double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
41 double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
42 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 };
43 double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
44 double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
45 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 };
46 double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
47 double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
48 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 };
49 
50 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 };
51 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 };
52 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 };
53 double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
54 double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
55 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 };
56 
57 double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
58 double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
59 
60 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 };
61 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 };
62 double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
63 double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
64 
65 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 };
66 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 };
67 //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 };
68 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 };
69 
70 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 };
71 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 };
72 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 };
73 
74 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 };
75 
76 double vehiclePoly_EmergencySign[] = { .2, .5, -.2, .5, -.2, -.5, .2, -.5, -10000 };
77 double vehiclePoly_Emergency[] = { .1, .1, -.1, .1, -.1, -.1, .1, -.1, -10000 };
78 double vehiclePoly_Emergency2[] = { .04, .3, -.04, .3, -.04, -.3, .04, -.3, -10000 };
79 
80 double vehiclePoly_EmergencyLadder[] = { -.5, .3, .5, .3, .5, .2, -.5, .2, -10000 };
81 double vehiclePoly_EmergencyLadder2[] = { -.5, -.3, .5, -.3, .5, -.2, -.5, -.2, -10000 };
82 double vehiclePoly_EmergencyLadder3[] = { -.45, .3, -.4, .3, -.4, -.3, -.45, -.3, -10000 };
83 double vehiclePoly_EmergencyLadder4[] = { .45, .3, .4, .3, .4, -.3, .45, -.3, -10000 };
84 double vehiclePoly_EmergencyLadder5[] = { .05, .3, .0, .3, .0, -.3, .05, -.3, -10000 };
85 double vehiclePoly_EmergencyLadder6[] = { -.25, .3, -.2, .3, -.2, -.3, -.25, -.3, -10000 };
86 double vehiclePoly_EmergencyLadder7[] = { .25, .3, .2, .3, .2, -.3, .25, -.3, -10000 };
87 
88 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 };
89 
90 // ===========================================================================
91 // method definitions
92 // ===========================================================================
93 
94 void
95 GUIBaseVehicleHelper::drawPoly(const double* poses, const double offset) {
96  glPushMatrix();
97  glTranslated(0, 0, offset * .1);
98  glPolygonOffset(0, (GLfloat) - offset);
99  glBegin(GL_TRIANGLE_FAN);
100  int i = 0;
101  while (poses[i] > -999) {
102  glVertex2d(poses[i], poses[i + 1]);
103  i = i + 2;
104  }
105  glEnd();
106  glPopMatrix();
107 }
108 
109 void
110 GUIBaseVehicleHelper::drawAction_drawVehicleAsBoxPlus(const double width, const double length) {
111  glPushMatrix();
112  glScaled(width, length, 1.);
113  glBegin(GL_TRIANGLE_STRIP);
114  glVertex2d(0., 0.);
115  glVertex2d(-.5, .15);
116  glVertex2d(.5, .15);
117  glVertex2d(-.5, 1.);
118  glVertex2d(.5, 1.);
119  glEnd();
120  glPopMatrix();
121 }
122 
123 
124 void
125 GUIBaseVehicleHelper::drawAction_drawVehicleAsTrianglePlus(const double width, const double length) {
126  if (length >= 8.) {
127  drawAction_drawVehicleAsBoxPlus(width, length);
128  return;
129  }
130  glPushMatrix();
131  glScaled(width, length, 1.);
132  glBegin(GL_TRIANGLES);
133  glVertex2d(0., 0.);
134  glVertex2d(-.5, 1.);
135  glVertex2d(.5, 1.);
136  glEnd();
137  glPopMatrix();
138 }
139 
140 
141 void
142 GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(const GUIVisualizationSettings& s, const SUMOVehicleShape shape, const double width, const double length,
143  int carriageIndex) {
144  UNUSED_PARAMETER(s);
145  RGBColor current = GLHelper::getColor();
146  RGBColor lighter = current.changedBrightness(51);
147  RGBColor darker = current.changedBrightness(-51);
148  glPushMatrix();
149  glRotated(90, 0, 0, 1);
150  glScaled(length, width, 1.);
151 
152  // draw main body
153  switch (shape) {
154  case SVS_UNKNOWN:
156  GLHelper::setColor(lighter);
158  glColor3d(0, 0, 0);
160  break;
161  case SVS_PEDESTRIAN:
162  glTranslated(0, 0, .045);
164  glTranslated(0, 0, -.045);
165  glScaled(.7, 2, 1);
166  glTranslated(0, 0, .04);
167  GLHelper::setColor(lighter);
169  glTranslated(0, 0, -.04);
170  break;
171  case SVS_BICYCLE:
172  case SVS_MOPED:
173  case SVS_MOTORCYCLE: {
174  RGBColor darker = current.changedBrightness(-50);
175  // body
177  // head
178  glPushMatrix();
179  glTranslated(0.4, 0, .5);
180  glScaled(0.1, 0.2, 1);
181  GLHelper::setColor(darker);
183  glPopMatrix();
184  // bike frame
186  glPushMatrix();
187  glTranslated(0.5, 0, .3);
188  glScaled(0.5, 0.05, 1);
190  glPopMatrix();
191  // handle bar
192  glPushMatrix();
193  glTranslated(0.25, 0, .3);
194  glScaled(0.02, 0.5, 1);
196  glPopMatrix();
197  }
198  break;
199  case SVS_PASSENGER:
200  case SVS_PASSENGER_SEDAN:
202  case SVS_PASSENGER_WAGON:
204  GLHelper::setColor(lighter);
206  glColor3d(0, 0, 0);
208  break;
209  case SVS_PASSENGER_VAN:
211  GLHelper::setColor(lighter);
213  glColor3d(0, 0, 0);
218  break;
219  case SVS_DELIVERY:
221  GLHelper::setColor(lighter);
223  glColor3d(0, 0, 0);
227  break;
228  case SVS_TRUCK:
230  case SVS_TRUCK_1TRAILER:
231  if (carriageIndex < 1) {
232  glScaled(1. / (length), 1, 1.);
234  glColor3d(0, 0, 0);
238  }
239  break;
240  case SVS_BUS:
241  case SVS_BUS_COACH:
242  case SVS_BUS_TROLLEY: {
243  double ml = length;
244  glScaled(1. / (length), 1, 1.);
245  glTranslated(0, 0, .04);
246  glBegin(GL_TRIANGLE_FAN);
247  glVertex2d(ml / 2., 0);
248  glVertex2d(0, 0);
249  glVertex2d(0, -.45);
250  glVertex2d(0 + .05, -.5);
251  glVertex2d(ml - .05, -.5);
252  glVertex2d(ml, -.45);
253  glVertex2d(ml, .45);
254  glVertex2d(ml - .05, .5);
255  glVertex2d(0 + .05, .5);
256  glVertex2d(0, .45);
257  glVertex2d(0, 0);
258  glEnd();
259  glTranslated(0, 0, -.04);
260 
261  glTranslated(0, 0, .045);
262  glColor3d(0, 0, 0);
263  glBegin(GL_QUADS);
264  glVertex2d(0 + .05, .48);
265  glVertex2d(0 + .05, -.48);
266  glVertex2d(0 + .15, -.48);
267  glVertex2d(0 + .15, .48);
268 
269  glVertex2d(ml - .1, .45);
270  glVertex2d(ml - .1, -.45);
271  glVertex2d(ml - .05, -.45);
272  glVertex2d(ml - .05, .45);
273 
274  glVertex2d(0 + .20, .49);
275  glVertex2d(0 + .20, .45);
276  glVertex2d(ml - .20, .45);
277  glVertex2d(ml - .20, .49);
278 
279  glVertex2d(0 + .20, -.49);
280  glVertex2d(0 + .20, -.45);
281  glVertex2d(ml - .20, -.45);
282  glVertex2d(ml - .20, -.49);
283 
284  glEnd();
285  glTranslated(0, 0, -.045);
286  }
287  break;
288  case SVS_BUS_FLEXIBLE:
289  case SVS_RAIL:
290  case SVS_RAIL_CAR:
291  case SVS_RAIL_CARGO:
292  case SVS_E_VEHICLE:
294  glColor3d(0, 0, 0);
296  glTranslated(0, 0, .048);
297  GLHelper::setColor(current);
298  glBegin(GL_QUADS);
299  glVertex2d(.3, .5);
300  glVertex2d(.35, .5);
301  glVertex2d(.35, -.5);
302  glVertex2d(.3, -.5);
303 
304  glVertex2d(.3, -.05);
305  glVertex2d(.7, -.05);
306  glVertex2d(.7, .05);
307  glVertex2d(.3, .05);
308 
309  glVertex2d(.7, .5);
310  glVertex2d(.65, .5);
311  glVertex2d(.65, -.5);
312  glVertex2d(.7, -.5);
313  glEnd();
314  glTranslated(0, 0, -.048);
315  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
316  break;
317  case SVS_ANT:
318  glPushMatrix();
319  // ant is stretched via vehicle length
320  GLHelper::setColor(darker);
321  // draw left side
322  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
323  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
324  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
325  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
326  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
327  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
328  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
329  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
330  // draw right side
331  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
332  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
333  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
334  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
335  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
336  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
337  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
338  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
339  // draw body
340  GLHelper::setColor(current);
341  glTranslated(0, 0, 0.1);
343  glTranslated(.4, 0, 0);
345  glTranslated(.4, 0, 0);
347  glPopMatrix();
348  break;
349  case SVS_SHIP: {
350  RGBColor darker = current.changedBrightness(-30);
351  RGBColor darker2 = current.changedBrightness(-70);
353  GLHelper::setColor(darker);
355  GLHelper::setColor(darker2);
357  break;
358  }
359  case SVS_EMERGENCY: // similar to delivery
361  GLHelper::setColor(darker);
363  glColor3d(0, 0, 0);
367  // first aid sign
368  glTranslated(0.7, 0, 0);
369  glColor3d(.18, .55, .34);
371  glColor3d(1, 1, 1);
374  break;
375  case SVS_FIREBRIGADE: // similar to delivery in red orange
377  GLHelper::setColor(lighter);
379  glColor3d(0, 0, 0);
383  // draw ladder
384  glTranslated(0.7, 0, 0);
385  glColor3d(1, .5, 0);
387  glColor3d(.5, .5, .5);
395  break;
396  case SVS_POLICE: // similar to passenger grey with blue
398  GLHelper::setColor(lighter);
400  glColor3d(0, 0, 0);
402  // first aid sign
403  glTranslated(0.7, 0, 0);
404  glColor3d(.5, .5, .5);
406  glColor3d(0, 0, 1);
409  break;
410  case SVS_RICKSHAW: // Rickshaw
412  // wheels
413  GLHelper::setColor(darker);
414  glPushMatrix();
415  glTranslated(.5, .5, -0.1);
417  glPopMatrix();
418  //other wheel
419  glPushMatrix();
420  glTranslated(.5, -.5, -0.1);
422  glPopMatrix();
423  break;
424  default: // same as passenger
426  glColor3d(1, 1, 1);
428  glColor3d(0, 0, 0);
430  break;
431  }
432 
433  // draw decorations
434  switch (shape) {
435  case SVS_PEDESTRIAN:
436  break;
437  case SVS_BICYCLE:
438  //glScaled(length, 1, 1.);
439  glBegin(GL_TRIANGLE_FAN);
440  glVertex2d(1 / 2., 0);
441  glVertex2d(0, 0);
442  glVertex2d(0, -.03);
443  glVertex2d(0 + .05, -.05);
444  glVertex2d(1 - .05, -.05);
445  glVertex2d(1, -.03);
446  glVertex2d(1, .03);
447  glVertex2d(1 - .05, .05);
448  glVertex2d(0 + .05, .05);
449  glVertex2d(0, .03);
450  glVertex2d(0, 0);
451  glEnd();
452  break;
453  case SVS_MOPED:
454  case SVS_MOTORCYCLE:
455  //glScaled(length, 1, 1.);
456  glBegin(GL_TRIANGLE_FAN);
457  glVertex2d(1 / 2., 0);
458  glVertex2d(0, 0);
459  glVertex2d(0, -.03);
460  glVertex2d(0 + .05, -.2);
461  glVertex2d(1 - .05, -.2);
462  glVertex2d(1, -.03);
463  glVertex2d(1, .03);
464  glVertex2d(1 - .05, .2);
465  glVertex2d(0 + .05, .2);
466  glVertex2d(0, .03);
467  glVertex2d(0, 0);
468  glEnd();
469  break;
470  case SVS_PASSENGER:
471  case SVS_PASSENGER_SEDAN:
475  break;
480  break;
481  case SVS_PASSENGER_WAGON:
485  break;
486  case SVS_PASSENGER_VAN:
487  case SVS_DELIVERY:
488  break;
489  case SVS_TRUCK:
490  GLHelper::setColor(current);
491  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
492  break;
494  if (carriageIndex < 0) {
495  GLHelper::setColor(current);
496  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
497  }
498  break;
499  case SVS_TRUCK_1TRAILER: {
500  GLHelper::setColor(current);
501  double l = length - 2.3;
502  if (carriageIndex != 0) {
503  l = l / 2.;
504  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
505  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
506  } else {
507  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
508  }
509  break;
510  }
511  case SVS_BUS_TROLLEY:
512  glPushMatrix();
513  glTranslated(0, 0, .1);
514  GLHelper::setColor(darker);
515  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
516  glTranslated(0, 0, .1);
517  glColor3d(0, 0, 0);
518  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
519  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
520  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
521  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
522  glPopMatrix();
523  break;
524  case SVS_BUS:
525  case SVS_BUS_COACH:
526  case SVS_BUS_FLEXIBLE:
527  case SVS_RAIL:
528  case SVS_RAIL_CAR:
529  case SVS_RAIL_CARGO:
530  case SVS_E_VEHICLE:
531  case SVS_ANT:
532  case SVS_SHIP:
533  case SVS_EMERGENCY:
534  case SVS_FIREBRIGADE:
535  case SVS_POLICE:
536  case SVS_RICKSHAW:
537  break;
538  default: // same as passenger/sedan
542  break;
543  }
544  /*
545  glBegin(GL_TRIANGLE_FAN);
546  glVertex2d(.5,.5); // center - strip begin
547  glVertex2d(0, .5); // center, front
548  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
549  glVertex2d(0.08, .94);
550  glVertex2d(0.25, 1.);
551  glVertex2d(0.95, 1.);
552  glVertex2d(1., .9);
553  glVertex2d(1., .1); // (vehicle left side)
554  glVertex2d(0.95, 0.);
555  glVertex2d(0.25, 0.);
556  glVertex2d(0.08, .06);
557  glVertex2d(0, .2); //
558  glVertex2d(0, .5); // center, front (close)
559  glEnd();
560 
561  glPolygonOffset(0, -4.5);
562  glColor3d(1, 1, 1); // front
563  glBegin(GL_TRIANGLE_FAN);
564  glVertex2d(0.1,0.5);
565  glVertex2d(0.025,0.5);
566  glVertex2d(0.025,0.75);
567  glVertex2d(0.27,0.9);
568  glVertex2d(0.27,0.1);
569  glVertex2d(0.025,0.25);
570  glVertex2d(0.025,0.5);
571  glEnd();
572 
573  glColor3d(0, 0, 0); // front glass
574  glBegin(GL_TRIANGLE_FAN);
575  glVertex2d(0.35,0.5);
576  glVertex2d(0.3,0.5);
577  glVertex2d(0.3,0.9);
578  glVertex2d(0.43,0.8);
579  glVertex2d(0.43,0.2);
580  glVertex2d(0.3,0.1);
581  glVertex2d(0.3,0.5);
582  glEnd();
583 
584  glBegin(GL_TRIANGLE_FAN); // back glass
585  glVertex2d(0.92,0.5);
586  glVertex2d(0.90,0.5);
587  glVertex2d(0.90,0.8);
588  glVertex2d(0.95,0.9);
589  glVertex2d(0.95,0.1);
590  glVertex2d(0.90,0.2);
591  glVertex2d(0.90,0.5);
592  glEnd();
593 
594  glBegin(GL_TRIANGLE_FAN); // right glass
595  glVertex2d(0.36,0.07);
596  glVertex2d(0.34,0.03);
597  glVertex2d(0.94,0.03);
598  glVertex2d(0.87,0.13);
599  glVertex2d(0.45,0.13);
600  glVertex2d(0.34,0.03);
601  glEnd();
602 
603  glBegin(GL_TRIANGLE_FAN); // left glass
604  glVertex2d(0.36,1.-0.07);
605  glVertex2d(0.34,1.-0.03);
606  glVertex2d(0.94,1.-0.03);
607  glVertex2d(0.87,1.-0.13);
608  glVertex2d(0.45,1.-0.13);
609  glVertex2d(0.34,1.-0.03);
610  glEnd();
611  */
612 
613  glPopMatrix();
614 }
615 
616 
617 bool
618 GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(const GUIVisualizationSettings& s, const std::string& file, const GUIGlObject* o, const double width, double length) {
619  if (file != "") {
620  int textureID = GUITexturesHelper::getTextureID(file);
621  if (textureID > 0) {
622  const double exaggeration = s.vehicleSize.getExaggeration(s, o);
623  const double halfWidth = width / 2.0 * exaggeration;
624  GUITexturesHelper::drawTexturedBox(textureID, -halfWidth, 0, halfWidth, length * exaggeration);
625  return true;
626  }
627  }
628  return false;
629 }
630 
631 
632 /****************************************************************************/
double vehiclePoly_EVehicleBackGlass[]
double vehiclePoly_PassengerVanBackGlass[]
double vehiclePoly_Emergency[]
double vehiclePoly_PassengerVanBodyFront[]
double vehiclePoly_EmergencyLadder[]
double vehiclePoly_PassengerCarBody[]
double vehiclePoly_PassengerWagonLeftGlass[]
double vehiclePoly_EmergencyLadder2[]
double vehiclePoly_EVehicleBody[]
double vehiclePoly_ShipSuperStructure[]
double vehiclePoly_ShipDeck[]
double vehiclePoly_DeliveryMediumRightGlass[]
double vehiclePoly_PassengerSedanBackGlass[]
double vehiclePoly_EmergencyLadder5[]
double vehiclePoly_PassengerWagonRightGlass[]
double vehiclePoly_Emergency2[]
double vehiclePoly_EmergencyLadder4[]
double vehiclePoly_DeliveryMediumLeftGlass[]
double vehiclePoly_PassengerCarBodyFront[]
double vehiclePoly_EmergencyLadder3[]
double vehiclePoly_PassengerHatchbackBackGlass[]
double vehiclePoly_PassengerVanLeftGlass[]
double vehiclePoly_EmergencyLadder6[]
double vehiclePoly_TransportFrontGlass[]
double vehiclePoly_EmergencySign[]
double vehiclePoly_TransportBody[]
double vehiclePoly_EmergencyLadder7[]
double vehiclePoly_Cyclist[]
double vehiclePoly_TransportRightGlass[]
double vehiclePoly_PassengerSedanRightGlass[]
double vehiclePoly_PassengerVanFrontGlass[]
double vehiclePoly_TransportLeftGlass[]
double vehiclePoly_PassengerSedanLeftGlass[]
double vehiclePoly_EVehicleFrontGlass[]
double vehiclePoly_PassengerVanBody[]
double vehiclePoly_Rickshaw[]
double vehiclePoly_PassengerWagonBackGlass[]
double vehiclePoly_PassengerHatchbackRightGlass[]
double vehiclePoly_PassengerVanRightGlass[]
double vehiclePoly_PassengerFrontGlass[]
double vehiclePoly_Ship[]
double vehiclePoly_PassengerHatchbackLeftGlass[]
SUMOVehicleShape
Definition of vehicle classes to differ between different appearences.
@ SVS_BICYCLE
render as a bicycle
@ SVS_FIREBRIGADE
render as a fire brigade
@ SVS_ANT
render as a giant ant
@ SVS_PASSENGER_HATCHBACK
render as a hatchback passenger vehicle ("Fliessheck")
@ SVS_TRUCK_SEMITRAILER
render as a semi-trailer transport vehicle ("Sattelschlepper")
@ SVS_RAIL
render as a rail
@ SVS_EMERGENCY
render as an emergency vehicle
@ SVS_DELIVERY
automated car (with cruise controllers)
@ SVS_MOTORCYCLE
render as a motorcycle
@ SVS_UNKNOWN
not defined
@ SVS_PASSENGER
render as a passenger vehicle
@ SVS_TRUCK
render as a transport vehicle
@ SVS_PASSENGER_SEDAN
render as a sedan passenger vehicle ("Stufenheck")
@ SVS_BUS
render as a bus
@ SVS_MOPED
render as a moped
@ SVS_E_VEHICLE
render as a (futuristic) e-vehicle
@ SVS_BUS_FLEXIBLE
render as a flexible city bus
@ SVS_BUS_TROLLEY
render as a trolley bus
@ SVS_RAIL_CARGO
render as a cargo train
@ SVS_BUS_COACH
render as a coach
@ SVS_SHIP
render as a arbitrary ship
@ SVS_RAIL_CAR
render as a (city) rail without locomotive
@ SVS_PASSENGER_WAGON
render as a wagon passenger vehicle ("Combi")
@ SVS_PASSENGER_VAN
render as a van
@ SVS_PEDESTRIAN
render as a pedestrian
@ SVS_POLICE
render as a police car
@ SVS_RICKSHAW
render as a rickshaw
@ SVS_TRUCK_1TRAILER
render as a transport vehicle with one trailer
#define UNUSED_PARAMETER(x)
Definition: StdDefs.h:29
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:446
static void drawFilledCircle(double width, int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:347
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:452
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:135
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1)
draw vehicle as a polygon
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 sucessful
static void drawPoly(const double *poses, const double offset)
draw poly
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.
GUIVisualizationSizeSettings vehicleSize
A point in 2D or 3D with translation and scaling methods.
Definition: Position.h:36
static const RGBColor GREY
Definition: RGBColor.h:189
RGBColor changedBrightness(int change, int toChange=3) const
Returns a new color with altered brightness.
Definition: RGBColor.cpp:145
double getExaggeration(const GUIVisualizationSettings &s, const GUIGlObject *o, double factor=20) const
return the drawing size including exaggeration and constantSize values