Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
eclipse
GitHub Repository: eclipse/sumo
Path: blob/main/src/osgview/GUIOSGBuilder.h
169665 views
1
/****************************************************************************/
2
// Eclipse SUMO, Simulation of Urban MObility; see https://eclipse.dev/sumo
3
// Copyright (C) 2001-2025 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
/****************************************************************************/
14
/// @file GUIOSGBuilder.h
15
/// @author Daniel Krajzewicz
16
/// @date 19.01.2012
17
///
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
class SUMOPolygon;
48
class PointOfInterest;
49
50
// ===========================================================================
51
// class definitions
52
// ===========================================================================
53
/**
54
* @class GUIOSGBuilder
55
* @brief Builds OSG nodes from microsim objects
56
*/
57
class GUIOSGBuilder {
58
public:
59
static osg::Group* buildOSGScene(osg::Node* const tlg, osg::Node* const tly, osg::Node* const tlr, osg::Node* const tlu, osg::Node* const pole);
60
61
static void buildDecal(const GUISUMOAbstractView::Decal& d, osg::Group& addTo);
62
63
static void buildLight(const GUISUMOAbstractView::Decal& d, osg::Group& addTo);
64
65
/// @brief Build traffic light models with poles and cantilevers automatically
66
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);
67
68
static osg::PositionAttitudeTransform* getTrafficLight(const GUISUMOAbstractView::Decal& d, MSTLLogicControl::TLSLogicVariants& vars, const MSLink* link, osg::Node* const tlg,
69
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);
70
71
static GUIOSGView::OSGMovable buildMovable(const MSVehicleType& type);
72
73
static osg::Node* buildPlane(const float length = 1000.f); // OSG needs float coordinates here
74
75
private:
76
static osg::PositionAttitudeTransform* createTrafficLightState(const GUISUMOAbstractView::Decal& d, osg::Node* tl, const double withPole, const double size, osg::Vec4d color);
77
78
static void buildOSGEdgeGeometry(const MSEdge& edge,
79
osg::Group& addTo, osgUtil::Tessellator& tessellator);
80
81
static void buildOSGJunctionGeometry(GUIJunctionWrapper& junction,
82
osg::Group& addTo, osgUtil::Tessellator& tessellator);
83
84
static void buildPolygonGeometry(const SUMOPolygon& poly, osg::Group& addTo, osgUtil::Tessellator& tessellator);
85
static void buildPoIGeometry(const PointOfInterest& poi, osg::Group& addTo, osgUtil::Tessellator& tessellator);
86
87
static void setShapeState(osg::ref_ptr<osg::ShapeDrawable> shape);
88
89
static std::map<std::string, osg::ref_ptr<osg::Node> > myCars;
90
};
91
92
93
#endif
94
95