]> git.mxchange.org Git - flightgear.git/blob - src/Scenery/scenery.hxx
FGCom[-sa]: add IAX denoiser and auto gain + set silence threshold
[flightgear.git] / src / Scenery / scenery.hxx
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 _SCENERY_HXX
25 #define _SCENERY_HXX
26
27
28 #ifndef __cplusplus                                                          
29 # error This library requires C++
30 #endif                                   
31
32 #include <osg/ref_ptr>
33 #include <osg/Group>
34
35 #include <simgear/compiler.h>
36 #include <simgear/math/SGMath.hxx>
37 #include <simgear/structure/subsystem_mgr.hxx>
38
39 #include "SceneryPager.hxx"
40
41 namespace simgear {
42 class BVHMaterial;
43 }
44
45 // Define a structure containing global scenery parameters
46 class FGScenery : public SGSubsystem {
47
48     // scene graph
49     osg::ref_ptr<osg::Group> scene_graph;
50     osg::ref_ptr<osg::Group> terrain_branch;
51     osg::ref_ptr<osg::Group> models_branch;
52     osg::ref_ptr<osg::Group> aircraft_branch;
53     osg::ref_ptr<osg::Group> interior_branch;
54     
55     osg::ref_ptr<flightgear::SceneryPager> _pager;
56
57 public:
58
59     FGScenery();
60     ~FGScenery();
61
62     // Implementation of SGSubsystem.
63     void init ();
64     void bind ();
65     void unbind ();
66     void update (double dt);
67
68     /// Compute the elevation of the scenery at geodetic latitude lat,
69     /// geodetic longitude lon and not higher than max_alt.
70     /// If the exact flag is set to true, the scenery center is moved to
71     /// gain a higher accuracy of that query. The center is restored past
72     /// that to the original value.
73     /// The altitude hit is returned in the alt argument.
74     /// The method returns true if the scenery is available for the given
75     /// lat/lon pair. If there is no scenery for that point, the altitude
76     /// value is undefined. 
77     /// All values are meant to be in meters or degrees.
78     bool get_elevation_m(const SGGeod& geod, double& alt,
79                          const simgear::BVHMaterial** material,
80                          const osg::Node* butNotFrom = 0);
81
82     /// Compute the elevation of the scenery below the cartesian point pos.
83     /// you the returned scenery altitude is not higher than the position
84     /// pos plus an offset given with max_altoff.
85     /// If the exact flag is set to true, the scenery center is moved to
86     /// gain a higher accuracy of that query. The center is restored past
87     /// that to the original value.
88     /// The altitude hit is returned in the alt argument.
89     /// The method returns true if the scenery is available for the given
90     /// lat/lon pair. If there is no scenery for that point, the altitude
91     /// value is undefined.
92     /// All values are meant to be in meters.
93     bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
94                               double& elevation,
95                               const simgear::BVHMaterial** material,
96                               const osg::Node* butNotFrom = 0);
97
98     /// Compute the nearest intersection point of the line starting from 
99     /// start going in direction dir with the terrain.
100     /// The input and output values should be in cartesian coordinates in the
101     /// usual earth centered wgs84 coordinate system. Units are meters.
102     /// On success, true is returned.
103     bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir,
104                                       SGVec3d& nearestHit,
105                                       const osg::Node* butNotFrom = 0);
106
107     osg::Group *get_scene_graph () const { return scene_graph.get(); }
108     osg::Group *get_terrain_branch () const { return terrain_branch.get(); }
109     osg::Group *get_models_branch () const { return models_branch.get(); }
110     osg::Group *get_aircraft_branch () const { return aircraft_branch.get(); }
111     osg::Group *get_interior_branch () const { return interior_branch.get(); }
112     
113     /// Returns true if scenery is available for the given lat, lon position
114     /// within a range of range_m.
115     /// lat and lon are expected to be in degrees.
116     bool scenery_available(const SGGeod& position, double range_m);
117
118     // Static because access to the pager is needed before the rest of
119     // the scenery is initialized.
120     static flightgear::SceneryPager* getPagerSingleton();
121     flightgear::SceneryPager* getPager() { return _pager.get(); }
122 };
123
124
125 #endif // _SCENERY_HXX
126
127