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.dev/sumo
3 // Copyright (C) 2001-2024 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 /****************************************************************************/
19 // Functions used in GUIBaseVehicleHelper and GNEVehicle
20 /****************************************************************************/
21 #include <config.h>
23 
29 #include "GLHelper.h"
30 #include "GUIBaseVehicleHelper.h"
31 
32 
33 // ===========================================================================
34 // data definitions
35 // ===========================================================================
36 /* -------------------------------------------------------------------------
37  * drawed shapes
38  * ----------------------------------------------------------------------- */
39 static 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 };
40 static 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 };
41 static 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 };
42 static const double vehiclePoly_PassengerSedanRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.77, -.47, 0.67, -.37, 0.45, -.37, 0.34, -.47, -10000 };
43 static const double vehiclePoly_PassengerSedanLeftGlass[] = { 0.36, .43, 0.34, .47, 0.77, .47, 0.67, .37, 0.45, .37, 0.34, .47, -10000 };
44 static 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 };
45 static const double vehiclePoly_PassengerHatchbackRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.80, -.37, 0.45, -.37, 0.34, -.47, -10000 };
46 static const double vehiclePoly_PassengerHatchbackLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.80, .37, 0.45, .37, 0.34, .47, -10000 };
47 static 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 };
48 static const double vehiclePoly_PassengerWagonRightGlass[] = { 0.36, -.43, 0.34, -.47, 0.94, -.47, 0.87, -.37, 0.45, -.37, 0.34, -.47, -10000 };
49 static const double vehiclePoly_PassengerWagonLeftGlass[] = { 0.36, .43, 0.34, .47, 0.94, .47, 0.87, .37, 0.45, .37, 0.34, .47, -10000 };
50 static 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 };
51 
52 static 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 };
53 static 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 };
54 static 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 };
55 static const double vehiclePoly_PassengerVanRightGlass[] = { 0.36, -.43, 0.20, -.47, 0.98, -.47, 0.91, -.37, 0.31, -.37, 0.20, -.47, -10000 };
56 static const double vehiclePoly_PassengerVanLeftGlass[] = { 0.36, .43, 0.20, .47, 0.98, .47, 0.91, .37, 0.31, .37, 0.20, .47, -10000 };
57 static 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 };
58 
59 static const double vehiclePoly_TaxiSign[] = { .56, .241, .56, -.241, .49, -.241, .49, .241, -10000 };
60 
61 static const double vehiclePoly_DeliveryMediumRightGlass[] = { 0.21, -.43, 0.20, -.47, 0.38, -.47, 0.38, -.37, 0.31, -.37, 0.20, -.47, -10000 };
62 static const double vehiclePoly_DeliveryMediumLeftGlass[] = { 0.21, .43, 0.20, .47, 0.38, .47, 0.38, .37, 0.31, .37, 0.20, .47, -10000 };
63 
64 static 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 };
65 static 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 };
66 static const double vehiclePoly_TransportRightGlass[] = { 0.36, -.47, 0.10, -.48, 1.25, -.48, 1.25, -.4, 0.3, -.4, 0.10, -.48, -10000 };
67 static const double vehiclePoly_TransportLeftGlass[] = { 0.36, .47, 0.10, .48, 1.25, .48, 1.25, .4, 0.3, .4, 0.10, .48, -10000 };
68 
69 static 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 };
70 static 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 };
71 //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 };
72 //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 };
73 
74 static 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 };
75 static 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 };
76 static 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 };
77 
78 static 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 };
79 static 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 };
80 static 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 };
81 
82 static const double vehiclePoly_EmergencySign[] = { .2, .5, -.2, .5, -.2, -.5, .2, -.5, -10000 };
83 static const double vehiclePoly_Emergency[] = { .1, .1, -.1, .1, -.1, -.1, .1, -.1, -10000 };
84 static const double vehiclePoly_Emergency2[] = { .04, .3, -.04, .3, -.04, -.3, .04, -.3, -10000 };
85 
86 static const double vehiclePoly_EmergencyLadder[] = { -.5, .3, .5, .3, .5, .2, -.5, .2, -10000 };
87 static const double vehiclePoly_EmergencyLadder2[] = { -.5, -.3, .5, -.3, .5, -.2, -.5, -.2, -10000 };
88 static const double vehiclePoly_EmergencyLadder3[] = { -.45, .3, -.4, .3, -.4, -.3, -.45, -.3, -10000 };
89 static const double vehiclePoly_EmergencyLadder4[] = { .45, .3, .4, .3, .4, -.3, .45, -.3, -10000 };
90 static const double vehiclePoly_EmergencyLadder5[] = { .05, .3, .0, .3, .0, -.3, .05, -.3, -10000 };
91 static const double vehiclePoly_EmergencyLadder6[] = { -.25, .3, -.2, .3, -.2, -.3, -.25, -.3, -10000 };
92 static const double vehiclePoly_EmergencyLadder7[] = { .25, .3, .2, .3, .2, -.3, .25, -.3, -10000 };
93 
94 static const double vehiclePoly_scooterBase[] = { -.17, .5, -.2, .5, -.2, -.5, -.17, -.5, -10000 };
95 static const double vehiclePoly_scooterBase2[] = { .98, .05, 1., .05, 1., -.05, .98, -.05, -10000 };
96 static const double vehiclePoly_scooterBase3[] = { -.32, .6, .32, .6, .32, -.6, -.32, -.6, -10000 };
97 
98 static const double vehiclePoly_aircraft[] = {0.633, -0.500, 0.609, -0.465, 0.563, -0.460, 0.517, -0.168, 0.413, -0.156, 0.509, -0.053, 0.509, 0.053, 0.413, -0.156, 0.413, 0.156, 0.385, -0.101, 0.385, 0.101, 0.354, -0.058, 0.354, 0.058, 0.109, -0.050, 0.109, 0.050, 0, -0.003, 0, 0.003, 0, 0.003, 0.633, 0.500, 0.633, 0.500, 0.609, 0.465, 0.563, 0.460, 0.517, 0.168, 0.413, 0.156, 0.509, 0.053, 0.385, 0.101, 0.326, 0.158, 0.326, 0.108, 0.413, 0.156, 0.385, 0.101, 0.509, 0.053, 0.509, -0.053, 0.761, 0.043, 0.761, -0.043, 0.830, 0.030, 0.830, -0.030, 0.952, -0.196, 0.933, -0.196, 0.907, -0.008, 0.830, 0.030, 0.933, 0.196, 0.952, 0.196, 0.907, 0.008, 0.830, 0.030, 0.907, -0.008, 1.000, 0.003, 0.907, 0.008, 0.354, -0.058, 0.509, -0.053, 0.413, -0.156, 0.385, -0.101, 0.326, -0.158, 0.326, -0.108, 0.385, -0.101, -10000};
99 static const double vehiclePoly_aircraftEngines[] = {0.326, -0.158, 0.413, -0.156, 0.326, -0.108, 0.385, -0.101, 0.385, -0.101, 0.385, 0.101, 0.385, 0.101, 0.326, 0.108, 0.413, 0.156, 0.326, 0.158, -10000};
100 //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 };
101 
102 // ===========================================================================
103 // method definitions
104 // ===========================================================================
105 
106 void
107 GUIBaseVehicleHelper::drawPoly(const double* poses, const double offset) {
109  glTranslated(0, 0, offset * .1);
110  glPolygonOffset(0, (GLfloat) - offset);
111  glBegin(GL_TRIANGLE_FAN);
112  int i = 0;
113  while (poses[i] > -999) {
114  glVertex2d(poses[i], poses[i + 1]);
115  i = i + 2;
116  }
117  glEnd();
119 }
120 
121 void
122 GUIBaseVehicleHelper::drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed) {
124  glScaled(width, length, 1.);
125  glBegin(GL_TRIANGLE_STRIP);
126  if (amReversed) {
127  glVertex2d(-.5, 0.);
128  glVertex2d(.5, 0.);
129  glVertex2d(-.5, .85);
130  glVertex2d(.5, .85);
131  glVertex2d(0., 1.);
132  } else {
133  glVertex2d(0., 0.);
134  glVertex2d(-.5, .15);
135  glVertex2d(.5, .15);
136  glVertex2d(-.5, 1.);
137  glVertex2d(.5, 1.);
138  }
139  glEnd();
141 }
142 
143 
144 void
145 GUIBaseVehicleHelper::drawAction_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed) {
146  if (length >= 8.) {
147  drawAction_drawVehicleAsBoxPlus(width, length, amReversed);
148  return;
149  }
151  glScaled(width, length, 1.);
152  glBegin(GL_TRIANGLES);
153  if (amReversed) {
154  glVertex2d(0., 1.);
155  glVertex2d(-.5, 0.);
156  glVertex2d(.5, 0.);
157  } else {
158  glVertex2d(0., 0.);
159  glVertex2d(-.5, 1.);
160  glVertex2d(.5, 1.);
161  }
162  glEnd();
164 }
165 
166 
167 void
168 GUIBaseVehicleHelper::drawAction_drawVehicleAsCircle(const double width, double detail) {
169  const int steps = MIN2(MAX2(16, int(detail / 5)), 64);
170  GLHelper::drawFilledCircle(width / 2, steps);
171 }
172 
173 void
174 GUIBaseVehicleHelper::drawAction_drawVehicleAsPoly(const GUIVisualizationSettings& s, const SUMOVehicleShape shape, const double width, const double length,
175  int carriageIndex, bool isStopped, bool amReversed) {
176  UNUSED_PARAMETER(s);
177  RGBColor current = GLHelper::getColor();
178  RGBColor lighter = current.changedBrightness(51);
179  RGBColor darker = current.changedBrightness(-51);
181  glRotated(90, 0, 0, 1);
182 
183  glScaled(length, width, 1.);
184 
185  // If the vehicle is 'logically' reversed then reverse the drawing box
186  // NB at the moment the only vehicles that will have amReversed set true are trains. Here this supports a train with guiShape="aircraft"
187  if (amReversed) {
188  glRotatef(180, 0, 0, 1);
189  glTranslated(-1, 0, 0);
190  }
191 
192  // draw main body
193  switch (shape) {
196  GLHelper::setColor(lighter);
198  glColor3d(0, 0, 0);
200  break;
202  glTranslated(0, 0, .045);
204  glTranslated(0, 0, -.045);
205  glScaled(.7, 2, 1);
206  glTranslated(0, 0, .04);
207  GLHelper::setColor(lighter);
209  glTranslated(0, 0, -.04);
210  break;
214  darker = current.changedBrightness(-50);
215  if (!isStopped) {
216  // body
218  // head
220  glTranslated(0.4, 0, .5);
221  glScaled(0.1, 0.2, 1);
222  GLHelper::setColor(darker);
225  } else if (shape == SUMOVehicleShape::BICYCLE) {
226  // seat
227  GLHelper::setColor(darker);
229  } else {
230  // seat
231  GLHelper::setColor(darker);
233  }
234  // bike frame
237  glTranslated(0.5, 0, .3);
238  glScaled(0.5, 0.05, 1);
241  // handle bar
243  glTranslated(0.25, 0, .3);
244  glScaled(0.02, 0.5, 1);
247  }
248  break;
255  GLHelper::setColor(lighter);
257  glColor3d(0, 0, 0);
259  break;
262  GLHelper::setColor(lighter);
264  glColor3d(0, 0, 0);
269  break;
272  GLHelper::setColor(lighter);
274  glColor3d(0, 0, 0);
278  break;
282  if (carriageIndex < 1) {
283  glScaled(1. / (length), 1, 1.);
285  glColor3d(0, 0, 0);
289  }
290  break;
294  double ml = length;
295  glScaled(1. / (length), 1, 1.);
296  glTranslated(0, 0, .04);
297  glBegin(GL_TRIANGLE_FAN);
298  glVertex2d(ml / 2., 0);
299  glVertex2d(0, 0);
300  glVertex2d(0, -.45);
301  glVertex2d(0 + .05, -.5);
302  glVertex2d(ml - .05, -.5);
303  glVertex2d(ml, -.45);
304  glVertex2d(ml, .45);
305  glVertex2d(ml - .05, .5);
306  glVertex2d(0 + .05, .5);
307  glVertex2d(0, .45);
308  glVertex2d(0, 0);
309  glEnd();
310  glTranslated(0, 0, -.04);
311 
312  glTranslated(0, 0, .045);
313  glColor3d(0, 0, 0);
314  glBegin(GL_QUADS);
315  glVertex2d(0 + .05, .48);
316  glVertex2d(0 + .05, -.48);
317  glVertex2d(0 + .15, -.48);
318  glVertex2d(0 + .15, .48);
319 
320  glVertex2d(ml - .1, .45);
321  glVertex2d(ml - .1, -.45);
322  glVertex2d(ml - .05, -.45);
323  glVertex2d(ml - .05, .45);
324 
325  glVertex2d(0 + .20, .49);
326  glVertex2d(0 + .20, .45);
327  glVertex2d(ml - .20, .45);
328  glVertex2d(ml - .20, .49);
329 
330  glVertex2d(0 + .20, -.49);
331  glVertex2d(0 + .20, -.45);
332  glVertex2d(ml - .20, -.45);
333  glVertex2d(ml - .20, -.49);
334 
335  glEnd();
336  glTranslated(0, 0, -.045);
337  }
338  break;
343  // generic rail carriage (see GUIVehicle::drawAction_drawCarriageClass)
344  glRotated(-90, 0, 0, 1);
345  const double xCornerCut = 0.3 / width;
346  const double yCornerCut = 0.4 / length;
347  const double drawnCarriageLength = 1;
348  const double halfWidth = 0.5;
349  glBegin(GL_TRIANGLE_FAN);
350  glVertex2d(-halfWidth + xCornerCut, 0);
351  glVertex2d(-halfWidth, yCornerCut);
352  glVertex2d(-halfWidth, drawnCarriageLength - yCornerCut);
353  glVertex2d(-halfWidth + xCornerCut, drawnCarriageLength);
354  glVertex2d(halfWidth - xCornerCut, drawnCarriageLength);
355  glVertex2d(halfWidth, drawnCarriageLength - yCornerCut);
356  glVertex2d(halfWidth, yCornerCut);
357  glVertex2d(halfWidth - xCornerCut, 0);
358  glEnd();
359  // assume we are only rendering the head of the train (carriage rendering was disabled via param)
360  glTranslated(0, 0, 0.1);
361  glColor3d(0, 0, 0);
362  glBegin(GL_TRIANGLE_FAN);
363  glVertex2d(-halfWidth + 2 * xCornerCut, yCornerCut);
364  glVertex2d(-halfWidth + xCornerCut, 3 * yCornerCut);
365  glVertex2d(halfWidth - xCornerCut, 3 * yCornerCut);
366  glVertex2d(halfWidth - 2 * xCornerCut, yCornerCut);
367  glEnd();
368  }
369  break;
370 
373  glColor3d(0, 0, 0);
375  glTranslated(0, 0, .048);
376  GLHelper::setColor(current);
377  glBegin(GL_QUADS);
378  glVertex2d(.3, .5);
379  glVertex2d(.35, .5);
380  glVertex2d(.35, -.5);
381  glVertex2d(.3, -.5);
382 
383  glVertex2d(.3, -.05);
384  glVertex2d(.7, -.05);
385  glVertex2d(.7, .05);
386  glVertex2d(.3, .05);
387 
388  glVertex2d(.7, .5);
389  glVertex2d(.65, .5);
390  glVertex2d(.65, -.5);
391  glVertex2d(.7, -.5);
392  glEnd();
393  glTranslated(0, 0, -.048);
394  //drawPoly(vehiclePoly_EVehicleBackGlass, 4.5);
395  break;
398  // ant is stretched via vehicle length
399  GLHelper::setColor(darker);
400  // draw left side
401  GLHelper::drawBoxLine(Position(-0.2, -.10), 350, 0.5, .02);
402  GLHelper::drawBoxLine(Position(-0.3, -.50), 240, 0.4, .03);
403  GLHelper::drawBoxLine(Position(0.3, -.10), 340, 0.8, .03);
404  GLHelper::drawBoxLine(Position(0.05, -.80), 290, 0.6, .04);
405  GLHelper::drawBoxLine(Position(0.4, -.10), 20, 0.8, .03);
406  GLHelper::drawBoxLine(Position(0.65, -.80), 75, 0.6, .04);
407  GLHelper::drawBoxLine(Position(0.5, -.10), 55, 0.8, .04);
408  GLHelper::drawBoxLine(Position(1.1, -.55), 90, 0.6, .04);
409  // draw right side
410  GLHelper::drawBoxLine(Position(-0.2, .10), 190, 0.5, .02);
411  GLHelper::drawBoxLine(Position(-0.3, .50), 300, 0.4, .03);
412  GLHelper::drawBoxLine(Position(0.3, .10), 200, 0.8, .03);
413  GLHelper::drawBoxLine(Position(0.05, .80), 250, 0.6, .04);
414  GLHelper::drawBoxLine(Position(0.4, .10), 160, 0.8, .03);
415  GLHelper::drawBoxLine(Position(0.65, .80), 105, 0.6, .04);
416  GLHelper::drawBoxLine(Position(0.5, .10), 125, 0.8, .04);
417  GLHelper::drawBoxLine(Position(1.1, .55), 90, 0.6, .04);
418  // draw body
419  GLHelper::setColor(current);
420  glTranslated(0, 0, 0.1);
422  glTranslated(.4, 0, 0);
424  glTranslated(.4, 0, 0);
427  break;
428  case SUMOVehicleShape::SHIP: {
434  break;
435  }
436  case SUMOVehicleShape::EMERGENCY: // similar to delivery
438  GLHelper::setColor(darker);
440  glColor3d(0, 0, 0);
444  // first aid sign
445  glTranslated(0.7, 0, 0);
446  glColor3d(.18, .55, .34);
448  glColor3d(1, 1, 1);
451  break;
452  case SUMOVehicleShape::FIREBRIGADE: // similar to delivery in red orange
454  GLHelper::setColor(lighter);
456  glColor3d(0, 0, 0);
460  // draw ladder
461  glTranslated(0.7, 0, 0);
462  glColor3d(1, .5, 0);
464  glColor3d(.5, .5, .5);
472  break;
473  case SUMOVehicleShape::POLICE: // similar to passenger grey with blue
475  GLHelper::setColor(lighter);
477  glColor3d(0, 0, 0);
479  // first aid sign
480  glTranslated(0.7, 0, 0);
481  glColor3d(.5, .5, .5);
483  glColor3d(0, 0, 1);
486  break;
487  case SUMOVehicleShape::RICKSHAW: // Rickshaw
489  // wheels
490  GLHelper::setColor(darker);
492  glTranslated(.5, .5, -0.1);
495  //other wheel
497  glTranslated(.5, -.5, -0.1);
500  break;
501 
502  case SUMOVehicleShape::AIRCRAFT: // Aircraft polygon has many points but we do not expect to have high numbers of aircraft being visualised!
504  glBegin(GL_TRIANGLE_STRIP);
505  {
506  int i = 0;
507  while (vehiclePoly_aircraft[i] > -999) {
508  glVertex2d(vehiclePoly_aircraft[i], vehiclePoly_aircraft[i + 1]);
509  i = i + 2;
510  }
511  }
512  glEnd();
514  glTranslated(0, 0, 0.1);
515  glBegin(GL_TRIANGLE_STRIP);
516  {
517  int i = 0;
518  while (vehiclePoly_aircraftEngines[i] > -999) {
520  i = i + 2;
521  }
522  }
523  glEnd();
525  // navigation lights
526  glColor3d(1.f, 0, 0);
528  glTranslated(0.62, -0.49, 0.1);
531  glColor3d(0, 1.f, 0);
533  glTranslated(0.62, 0.49, 0.1);
536  break;
537 
539  RGBColor darker2 = current.changedBrightness(-25);
541  // front small oval
542  GLHelper::setColor(darker);
543  glTranslated(0.2, 0, 0.15); // glTranslated(0.3, 0, 0.15);
544  glScaled(0.09, 0.13, 0.7); // was glScaled(0.04, 0.06, 0.7);
547  // handlebar
549  glTranslated(0.42, 0, 0.1); // was glTranslated(0.5, 0, 0.1);
550  glColor3d(0.3, 0.3, 0.3);
553  // front oval
555  GLHelper::setColor(darker2);
556  glTranslated(0.17, 0, 0.1); // was glTranslated(0.29, 0, 0.1);
557  glScaled(0.17, 0.19, 0.9); // was glScaled(0.07, 0.08, 0.9);
560  // tail rectangle
562  glColor3d(0.3, 0.3, 0.3);
564  // tail oval
565  GLHelper::setColor(darker2);
566  glTranslated(0.83, 0, 0.1); // was glTranslated(0.71, 0, 0.1);
567  glScaled(0.17, 0.17, 0.9); // was glScaled(0.07, 0.08, 0.9);
570  // base oval
572  GLHelper::setColor(lighter);
573  glTranslated(0.5, 0, 0.1); // was glTranslated(0.5, 0, 0.1);
574  glScaled(0.5, 0.28, 0.9); // was glScaled(0.28, 0.14, 0.9);
576  // center rectangle
577  GLHelper::setColor(current);
580  break;
581  }
582  default: // same as passenger
584  glColor3d(1, 1, 1);
586  glColor3d(0, 0, 0);
588  break;
589  }
590 
591  // draw decorations
592  switch (shape) {
594  break;
596  //glScaled(length, 1, 1.);
597  glBegin(GL_TRIANGLE_FAN);
598  glVertex2d(1 / 2., 0);
599  glVertex2d(0, 0);
600  glVertex2d(0, -.03);
601  glVertex2d(0 + .05, -.05);
602  glVertex2d(1 - .05, -.05);
603  glVertex2d(1, -.03);
604  glVertex2d(1, .03);
605  glVertex2d(1 - .05, .05);
606  glVertex2d(0 + .05, .05);
607  glVertex2d(0, .03);
608  glVertex2d(0, 0);
609  glEnd();
610  break;
613  //glScaled(length, 1, 1.);
614  glBegin(GL_TRIANGLE_FAN);
615  glVertex2d(1 / 2., 0);
616  glVertex2d(0, 0);
617  glVertex2d(0, -.03);
618  glVertex2d(0 + .05, -.2);
619  glVertex2d(1 - .05, -.2);
620  glVertex2d(1, -.03);
621  glVertex2d(1, .03);
622  glVertex2d(1 - .05, .2);
623  glVertex2d(0 + .05, .2);
624  glVertex2d(0, .03);
625  glVertex2d(0, 0);
626  glEnd();
627  break;
633  break;
638  break;
643  break;
646  break;
651 
652  glTranslated(0, 0, 6);
653  glColor3d(0, 0, 0);
654  // square-pattern in front
655  glRectd(0.146, 0.24675, 0.171, 0.176);
656  glRectd(0.121, 0.176, 0.146, 0.1055);
657  glRectd(0.146, 0.1055, 0.171, 0.035);
658  glRectd(0.121, 0.035, 0.146, -0.035);
659  glRectd(0.146, -0.1055, 0.171, -0.035);
660  glRectd(0.121, -0.176, 0.146, -0.1055);
661  glRectd(0.146, -0.24675, 0.171, -0.176);
662  // square-pattern at the back
663  glRectd(0.913, 0.24675, 0.938, 0.176);
664  glRectd(0.888, 0.176, 0.913, 0.1055);
665  glRectd(0.888, 0.176, 0.913, 0.1055);
666  glRectd(0.913, 0.1055, 0.938, 0.035);
667  glRectd(0.888, 0.035, 0.913, -0.035);
668  glRectd(0.913, -0.1055, 0.938, -0.035);
669  glRectd(0.888, -0.176, 0.913, -0.1055);
670  glRectd(0.888, -0.176, 0.913, -0.1055);
671  glRectd(0.913, -0.24675, 0.938, -0.176);
672 
673  GLHelper::setColor(darker);
675  glScaled(0.2, 0.5, 1);
676  GLHelper::drawText("TAXI", Position(2.58, 0), 5, 0.3, RGBColor::BLACK, 90);
677  break;
679  GLHelper::setColor(current);
680  GLHelper::drawBoxLine(Position(2.3, 0), 90., length - 2.3, .5);
681  break;
683  if (carriageIndex < 0) {
684  GLHelper::setColor(current);
685  GLHelper::drawBoxLine(Position(2.8, 0), 90., length - 2.8, .5);
686  }
687  break;
689  GLHelper::setColor(current);
690  double l = length - 2.3;
691  if (carriageIndex != 0) {
692  l = l / 2.;
693  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
694  GLHelper::drawBoxLine(Position(2.3 + l + .5, 0), 90., l - .5, .5);
695  } else {
696  GLHelper::drawBoxLine(Position(2.3, 0), 90., l, .5);
697  }
698  break;
699  }
702  glTranslated(0, 0, .1);
703  GLHelper::setColor(darker);
704  GLHelper::drawBoxLine(Position(3.8, 0), 90., 1, .3);
705  glTranslated(0, 0, .1);
706  glColor3d(0, 0, 0);
707  GLHelper::drawBoxLine(Position(4.3, .2), 90., 1, .06);
708  GLHelper::drawBoxLine(Position(4.3, -.2), 90., 1, .06);
709  GLHelper::drawBoxLine(Position(5.3, .2), 90., 3, .03);
710  GLHelper::drawBoxLine(Position(5.3, -.2), 90., 3, .03);
712  break;
728  break;
729  default: // same as passenger/sedan
733  break;
734  }
735  /*
736  glBegin(GL_TRIANGLE_FAN);
737  glVertex2d(.5,.5); // center - strip begin
738  glVertex2d(0, .5); // center, front
739  glVertex2d(0, .8); // ... clockwise ... (vehicle right side)
740  glVertex2d(0.08, .94);
741  glVertex2d(0.25, 1.);
742  glVertex2d(0.95, 1.);
743  glVertex2d(1., .9);
744  glVertex2d(1., .1); // (vehicle left side)
745  glVertex2d(0.95, 0.);
746  glVertex2d(0.25, 0.);
747  glVertex2d(0.08, .06);
748  glVertex2d(0, .2); //
749  glVertex2d(0, .5); // center, front (close)
750  glEnd();
751 
752  glPolygonOffset(0, -4.5);
753  glColor3d(1, 1, 1); // front
754  glBegin(GL_TRIANGLE_FAN);
755  glVertex2d(0.1,0.5);
756  glVertex2d(0.025,0.5);
757  glVertex2d(0.025,0.75);
758  glVertex2d(0.27,0.9);
759  glVertex2d(0.27,0.1);
760  glVertex2d(0.025,0.25);
761  glVertex2d(0.025,0.5);
762  glEnd();
763 
764  glColor3d(0, 0, 0); // front glass
765  glBegin(GL_TRIANGLE_FAN);
766  glVertex2d(0.35,0.5);
767  glVertex2d(0.3,0.5);
768  glVertex2d(0.3,0.9);
769  glVertex2d(0.43,0.8);
770  glVertex2d(0.43,0.2);
771  glVertex2d(0.3,0.1);
772  glVertex2d(0.3,0.5);
773  glEnd();
774 
775  glBegin(GL_TRIANGLE_FAN); // back glass
776  glVertex2d(0.92,0.5);
777  glVertex2d(0.90,0.5);
778  glVertex2d(0.90,0.8);
779  glVertex2d(0.95,0.9);
780  glVertex2d(0.95,0.1);
781  glVertex2d(0.90,0.2);
782  glVertex2d(0.90,0.5);
783  glEnd();
784 
785  glBegin(GL_TRIANGLE_FAN); // right glass
786  glVertex2d(0.36,0.07);
787  glVertex2d(0.34,0.03);
788  glVertex2d(0.94,0.03);
789  glVertex2d(0.87,0.13);
790  glVertex2d(0.45,0.13);
791  glVertex2d(0.34,0.03);
792  glEnd();
793 
794  glBegin(GL_TRIANGLE_FAN); // left glass
795  glVertex2d(0.36,1.-0.07);
796  glVertex2d(0.34,1.-0.03);
797  glVertex2d(0.94,1.-0.03);
798  glVertex2d(0.87,1.-0.13);
799  glVertex2d(0.45,1.-0.13);
800  glVertex2d(0.34,1.-0.03);
801  glEnd();
802  */
803 
805 }
806 
807 
808 bool
809 GUIBaseVehicleHelper::drawAction_drawVehicleAsImage(const GUIVisualizationSettings& /* s */, const std::string& file, const GUIGlObject* /* o */, const double width, double length) {
810  if (file != "") {
811  int textureID = GUITexturesHelper::getTextureID(file);
812  if (textureID > 0) {
813  GUITexturesHelper::drawTexturedBox(textureID, -width * 0.5, 0, width * 0.5, length);
814  return true;
815  }
816  }
817  return false;
818 }
819 
820 
821 /****************************************************************************/
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_aircraftEngines[]
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_aircraft[]
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
@ AIRCRAFT
render as aircraft
@ 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:76
T MAX2(T a, T b)
Definition: StdDefs.h:82
static void setColor(const RGBColor &c)
Sets the gl-color to this value.
Definition: GLHelper.cpp:654
static void drawFilledCircle(const double widradiusth, const int steps=8)
Draws a filled circle around (0,0)
Definition: GLHelper.cpp:569
static void popMatrix()
pop matrix
Definition: GLHelper.cpp:130
static RGBColor getColor()
gets the gl-color
Definition: GLHelper.cpp:660
static void drawBoxLine(const Position &beg, double rot, double visLength, double width, double offset=0)
Draws a thick line.
Definition: GLHelper.cpp:295
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:756
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_drawVehicleAsTrianglePlus(const double width, const double length, bool amReversed=false)
draw vehicle as a triangle
static void drawAction_drawVehicleAsPoly(const GUIVisualizationSettings &s, const SUMOVehicleShape shape, const double width, const double length, int carriageIndex=-1, bool isStopped=false, bool amReversed=false)
draw vehicle as a polygon
static void drawAction_drawVehicleAsBoxPlus(const double width, const double length, bool amReversed=false)
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