| 1 | /* |
| 2 | * SPDX-FileName: AirportBuilder.hxx |
| 3 | * SPDX-FileComment: Builder to create airports based on airport data for rendering in the scenery |
| 4 | * SPDX-FileCopyrightText: Copyright (C) 2020 Stuart Buchanan [email protected] |
| 5 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 6 | */ |
| 7 | |
| 8 | #pragma once |
| 9 | |
| 10 | #include <osgDB/Registry> |
| 11 | #include <simgear/scene/material/Effect.hxx> |
| 12 | #include <simgear/scene/material/EffectGeode.hxx> |
| 13 | |
| 14 | #include "airport.hxx" |
| 15 | |
| 16 | |
| 17 | namespace flightgear { |
| 18 | |
| 19 | static const float RUNWAY_OFFSET = 3.0; |
| 20 | |
| 21 | class AirportBuilder : public osgDB::ReaderWriter |
| 22 | { |
| 23 | public: |
| 24 | // The different layers are offset to avoid z-buffering issues. As they |
| 25 | // are viewed from above only, this doesn't cause any problems visually. |
| 26 | const float MARKING_OFFSET = 2.0; |
| 27 | const float PAVEMENT_OFFSET = 1.0; |
| 28 | const float BOUNDARY_OFFSET = 0.0; |
| 29 | |
| 30 | AirportBuilder(); |
| 31 | virtual ~AirportBuilder(); |
| 32 | |
| 33 | virtual const char* className() const; |
| 34 | |
| 35 | virtual ReadResult readNode(const std::string& fileName, |
| 36 | const osgDB::Options* options) |
| 37 | const; |
| 38 | |
| 39 | private: |
| 40 | osg::Node* createRunway(const osg::Matrixd mat, const SGVec3f center, const FGRunwayRef runway, const osgDB::Options* options) const; |
| 41 | osg::Node* createPavement(const osg::Matrixd mat, const SGVec3f center, const FGPavementRef pavement, const osgDB::Options* options) const; |
| 42 | osg::Node* createBoundary(const osg::Matrixd mat, const SGVec3f center, const FGPavementRef pavement, const osgDB::Options* options) const; |
| 43 | osg::Node* createLine(const osg::Matrixd mat, const SGVec3f center, const FGPavementRef pavement, const osgDB::Options* options) const; |
| 44 | osg::Vec4f getLineColor(const int aPaintCode) const; |
| 45 | osg::ref_ptr<simgear::Effect> getMaterialEffect(std::string material, const osgDB::Options* options) const; |
| 46 | }; |
| 47 | |
| 48 | } // namespace flightgear |