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++
34 #include <osg/ref_ptr>
37 #include <simgear/compiler.h>
38 #include <simgear/structure/subsystem_mgr.hxx>
39 #include <simgear/math/point3d.hxx>
40 #include <simgear/scene/model/placementtrans.hxx>
41 #include <simgear/scene/util/SGPickCallback.hxx>
48 // Define a structure containing global scenery parameters
49 class FGScenery : public SGSubsystem {
50 // FIXME this should be a views property
51 // angle of sun relative to current local horizontal
55 osg::ref_ptr<osg::Group> scene_graph;
56 osg::ref_ptr<osg::Group> terrain_branch;
57 osg::ref_ptr<osg::Group> gnd_lights_root;
58 osg::ref_ptr<osg::Group> vasi_lights_root;
59 osg::ref_ptr<osg::Group> rwy_lights_root;
60 osg::ref_ptr<osg::Group> taxi_lights_root;
61 osg::ref_ptr<osg::Group> models_branch;
62 osg::ref_ptr<osg::Group> aircraft_branch;
69 // Implementation of SGSubsystem.
73 void update (double dt);
75 /// Compute the elevation of the scenery at geodetic latitude lat,
76 /// geodetic longitude lon and not higher than max_alt.
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 or degrees.
85 bool get_elevation_m(double lat, double lon, double max_alt,
86 double& alt, const SGMaterial** material,
89 /// Compute the elevation of the scenery beow the cartesian point pos.
90 /// you the returned scenery altitude is not higher than the position
91 /// pos plus an ofset given with max_altoff.
92 /// If the exact flag is set to true, the scenery center is moved to
93 /// gain a higher accuracy of that query. The center is restored past
94 /// that to the original value.
95 /// The altitude hit is returned in the alt argument.
96 /// The method returns true if the scenery is available for the given
97 /// lat/lon pair. If there is no scenery for that point, the altitude
98 /// value is undefined.
99 /// All values are meant to be in meters.
100 bool get_cart_elevation_m(const SGVec3d& pos, double max_altoff,
101 double& radius, const SGMaterial** material,
104 /// Compute the nearest intersection point of the line starting from
105 /// start going in direction dir with the terrain.
106 /// The input and output values should be in cartesian coordinates in the
107 /// usual earth centered wgs84 coordiante system. Units are meters.
108 /// On success, true is returned.
109 bool get_cart_ground_intersection(const SGVec3d& start, const SGVec3d& dir,
110 SGVec3d& nearestHit, bool exact = false);
112 osg::Group *get_scene_graph () const { return scene_graph.get(); }
113 inline void set_scene_graph (osg::Group * s) { scene_graph = s; }
115 osg::Group *get_terrain_branch () const { return terrain_branch.get(); }
116 inline void set_terrain_branch (osg::Group * t) { terrain_branch = t; }
118 inline osg::Group *get_gnd_lights_root () const {
119 return gnd_lights_root.get();
121 inline void set_gnd_lights_root (osg::Group *r) {
125 inline osg::Group *get_vasi_lights_root () const {
126 return vasi_lights_root.get();
128 inline void set_vasi_lights_root (osg::Group *r) {
129 vasi_lights_root = r;
132 inline osg::Group *get_rwy_lights_root () const {
133 return rwy_lights_root.get();
135 inline void set_rwy_lights_root (osg::Group *r) {
139 inline osg::Group *get_taxi_lights_root () const {
140 return taxi_lights_root.get();
142 inline void set_taxi_lights_root (osg::Group *r) {
143 taxi_lights_root = r;
146 inline osg::Group *get_models_branch () const {
147 return models_branch.get();
149 inline void set_models_branch (osg::Group *t) {
153 inline osg::Group *get_aircraft_branch () const {
154 return aircraft_branch.get();
156 inline void set_aircraft_branch (osg::Group *t) {
162 #endif // _SCENERY_HXX