1 // scenery.hxx -- data structures and routines for managing scenery.
3 // Written by Curtis Olson, started May 1997.
5 // Copyright (C) 1997 Curtis L. Olson - http://www.flightgear.org/~curt
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.
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.
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.
29 # error This library requires C++
32 #include <osg/ref_ptr>
35 #include <simgear/compiler.h>
36 #include <simgear/math/SGMath.hxx>
37 #include <simgear/structure/subsystem_mgr.hxx>
41 // Define a structure containing global scenery parameters
42 class FGScenery : public SGSubsystem {
45 osg::ref_ptr<osg::Group> scene_graph;
46 osg::ref_ptr<osg::Group> terrain_branch;
47 osg::ref_ptr<osg::Group> models_branch;
48 osg::ref_ptr<osg::Group> aircraft_branch;
55 // Implementation of SGSubsystem.
59 void update (double dt);
61 /// Compute the elevation of the scenery at geodetic latitude lat,
62 /// geodetic longitude lon and not higher than max_alt.
63 /// If the exact flag is set to true, the scenery center is moved to
64 /// gain a higher accuracy of that query. The center is restored past
65 /// that to the original value.
66 /// The altitude hit is returned in the alt argument.
67 /// The method returns true if the scenery is available for the given
68 /// lat/lon pair. If there is no scenery for that point, the altitude
69 /// value is undefined.
70 /// All values are meant to be in meters or degrees.
71 bool get_elevation_m(double lat, double lon, double max_alt,
72 double& alt, const SGMaterial** material);
74 /// Compute the elevation of the scenery beow the cartesian point pos.
75 /// you the returned scenery altitude is not higher than the position
76 /// pos plus an ofset given with max_altoff.
77 /// If the exact flag is set to true, the scenery center is moved to
78 /// gain a higher accuracy of that query. The center is restored past
79 /// that to the original value.
80 /// The altitude hit is returned in the alt argument.
81 /// The method returns true if the scenery is available for the given
82 /// lat/lon pair. If there is no scenery for that point, the altitude
83 /// value is undefined.
84 /// All values are meant to be in meters.
85 bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
86 double& radius, const SGMaterial** material);
88 /// Compute the nearest intersection point of the line starting from
89 /// start going in direction dir with the terrain.
90 /// The input and output values should be in cartesian coordinates in the
91 /// usual earth centered wgs84 coordiante system. Units are meters.
92 /// On success, true is returned.
93 bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir,
96 osg::Group *get_scene_graph () const { return scene_graph.get(); }
97 osg::Group *get_terrain_branch () const { return terrain_branch.get(); }
98 osg::Group *get_models_branch () const { return models_branch.get(); }
99 osg::Group *get_aircraft_branch () const { return aircraft_branch.get(); }
103 #endif // _SCENERY_HXX