Eclipse SUMO - Simulation of Urban MObility
GUIOSGBuilder.h
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 /****************************************************************************/
18 // Builds OSG nodes from microsim objects
19 /****************************************************************************/
20 #pragma once
21 #include <config.h>
22 
23 #ifdef HAVE_OSG
24 
25 #include "GUIOSGView.h"
26 
27 #include <map>
28 
29 
30 // ===========================================================================
31 // class declarations
32 // ===========================================================================
33 
34 namespace osg {
35 class Node;
36 class Group;
37 class PositionAttitudeTransform;
38 }
39 
40 namespace osgUtil {
41 class Tessellator;
42 }
43 
44 class MSVehicleType;
45 class MSEdge;
46 class GUIJunctionWrapper;
47 
48 
49 // ===========================================================================
50 // class definitions
51 // ===========================================================================
56 class GUIOSGBuilder {
57 public:
58  static osg::Group* buildOSGScene(osg::Node* const tlg, osg::Node* const tly, osg::Node* const tlr, osg::Node* const tlu, osg::Node* const pole);
59 
60  static void buildDecal(const GUISUMOAbstractView::Decal& d, osg::Group& addTo);
61 
62  static void buildLight(const GUISUMOAbstractView::Decal& d, osg::Group& addTo);
63 
65  static void buildTrafficLightDetails(MSTLLogicControl::TLSLogicVariants& vars, osg::Node* const tlg, osg::Node* const tly, osg::Node* const tlr, osg::Node* const tlu, osg::Node* poleBase, osg::Group& addTo);
66 
67  static osg::PositionAttitudeTransform* getTrafficLight(const GUISUMOAbstractView::Decal& d, MSTLLogicControl::TLSLogicVariants& vars, const MSLink* link, osg::Node* const tlg,
68  osg::Node* const tly, osg::Node* const tlr, osg::Node* const tlu, osg::Node* const pole, const bool withPole = false, const double size = -1, double poleHeight = 1.8, double transparency = .3);
69 
70  static GUIOSGView::OSGMovable buildMovable(const MSVehicleType& type);
71 
72  static osg::Node* buildPlane(const float length = 1000.f); // OSG needs float coordinates here
73 
74 private:
75  static osg::PositionAttitudeTransform* createTrafficLightState(const GUISUMOAbstractView::Decal& d, osg::Node* tl, const double withPole, const double size, osg::Vec4d color);
76 
77  static void buildOSGEdgeGeometry(const MSEdge& edge,
78  osg::Group& addTo, osgUtil::Tessellator& tessellator);
79 
80  static void buildOSGJunctionGeometry(GUIJunctionWrapper& junction,
81  osg::Group& addTo, osgUtil::Tessellator& tessellator);
82 
83  static void setShapeState(osg::ref_ptr<osg::ShapeDrawable> shape);
84 
85  static std::map<std::string, osg::ref_ptr<osg::Node> > myCars;
86 };
87 
88 
89 #endif
A road/street connecting two junctions.
Definition: MSEdge.h:77
Storage for all programs of a single tls.
The car-following model and parameter.
Definition: MSVehicleType.h:63
Definition: Node.h:39
A decal (an image) that can be shown.