Debian Codegraph @

src/Scenery/terrain.hxx

raw symbols SCIP
1 // scenery.hxx -- data structures and routines for managing scenery.
2 //
3 // Written by Curtis Olson, started May 1997.
4 //
5 // Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 //
21 // $Id$
22
23
24 #ifndef _TERRAIN_HXX
25 #define _TERRAIN_HXX
26
27
28 #ifndef __cplusplus
29 # error This library requires C++
30 #endif
31
32 #include <osg/ref_ptr>
33 #include <osg/Switch>
34
35 #include <simgear/compiler.h>
36 #include <simgear/math/SGMath.hxx>
37 #include <simgear/scene/model/particles.hxx>
38 #include <simgear/structure/subsystem_mgr.hxx>
39
40 #include "scenery.hxx"
41 #include "SceneryPager.hxx"
42 #include "tilemgr.hxx"
43
44 namespace simgear {
45 class BVHMaterial;
46 }
47
48 // Define a structure containing global scenery parameters
49 class FGTerrain
50 {
51 public:
52 FGTerrain() = default;
53 virtual ~FGTerrain() = default;
54
55 // Implementation of SGSubsystem. - called from Scenery
56 virtual void init ( osg::Group* terrain ) = 0;
57 virtual void reinit() = 0;
58 virtual void shutdown () = 0;
59 virtual void bind () = 0;
60 virtual void unbind () = 0;
61 virtual void update (double dt) = 0;
62
63 /// Compute the elevation of the scenery at geodetic latitude lat,
64 /// geodetic longitude lon and not higher than max_alt.
65 /// If the exact flag is set to true, the scenery center is moved to
66 /// gain a higher accuracy of that query. The center is restored past
67 /// that to the original value.
68 /// The altitude hit is returned in the alt argument.
69 /// The method returns true if the scenery is available for the given
70 /// lat/lon pair. If there is no scenery for that point, the altitude
71 /// value is undefined.
72 /// All values are meant to be in meters or degrees.
73 virtual bool get_elevation_m(const SGGeod& geod, double& alt,
74 const simgear::BVHMaterial** material,
75 const osg::Node* butNotFrom = 0) = 0;
76
77 /// Compute the elevation of the scenery below the cartesian point pos.
78 /// you the returned scenery altitude is not higher than the position
79 /// pos plus an offset given with max_altoff.
80 /// If the exact flag is set to true, the scenery center is moved to
81 /// gain a higher accuracy of that query. The center is restored past
82 /// that to the original value.
83 /// The altitude hit is returned in the alt argument.
84 /// The method returns true if the scenery is available for the given
85 /// lat/lon pair. If there is no scenery for that point, the altitude
86 /// value is undefined.
87 /// All values are meant to be in meters.
88 virtual bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
89 double& elevation,
90 const simgear::BVHMaterial** material,
91 const osg::Node* butNotFrom = 0) = 0;
92
93 /// Compute the nearest intersection point of the line starting from
94 /// start going in direction dir with the terrain.
95 /// The input and output values should be in cartesian coordinates in the
96 /// usual earth centered wgs84 coordinate system. Units are meters.
97 /// On success, true is returned.
98 virtual bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir,
99 SGVec3d& nearestHit,
100 const osg::Node* butNotFrom = 0) = 0;
101
102 /// Returns true if scenery is available for the given lat, lon position
103 /// within a range of range_m.
104 /// lat and lon are expected to be in degrees.
105 virtual bool scenery_available(const SGGeod& position, double range_m) = 0;
106
107 // tile mgr api
108 virtual bool schedule_scenery(const SGGeod& position, double range_m, double duration=0.0) = 0;
109 virtual void materialLibChanged() = 0;
110 };
111
112 #endif // _TERRAIN_HXX