]> git.mxchange.org Git - flightgear.git/blob - src/Scenery/scenery.hxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[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 <list>
33
34 #include <plib/sg.h>
35
36 #include <simgear/compiler.h>
37 #include <simgear/structure/subsystem_mgr.hxx>
38 #include <simgear/math/point3d.hxx>
39 #include <simgear/scene/model/placementtrans.hxx>
40 #include <simgear/structure/ssgSharedPtr.hxx>
41
42 SG_USING_STD(list);
43
44 class ssgRoot;
45 class ssgBranch;
46
47
48 // Define a structure containing global scenery parameters
49 class FGScenery : public SGSubsystem {
50     // center of current scenery chunk
51     Point3D center;
52
53     // next center of current scenery chunk
54     Point3D next_center;
55
56     // FIXME this should be a views property
57     // angle of sun relative to current local horizontal
58     double sun_angle;
59
60     // SSG scene graph
61     ssgSharedPtr<ssgRoot> scene_graph;
62     ssgSharedPtr<ssgBranch> terrain_branch;
63     ssgSharedPtr<ssgRoot> gnd_lights_root;
64     ssgSharedPtr<ssgRoot> vasi_lights_root;
65     ssgSharedPtr<ssgRoot> rwy_lights_root;
66     ssgSharedPtr<ssgRoot> taxi_lights_root;
67     ssgSharedPtr<ssgBranch> models_branch;
68     ssgSharedPtr<ssgBranch> aircraft_branch;
69
70     // list of all placement transform, used to move the scenery center on the fly.
71     typedef list<ssgSharedPtr<ssgPlacementTransform> > placement_list_type;
72     placement_list_type _placement_list;
73
74 public:
75
76     FGScenery();
77     ~FGScenery();
78
79     // Implementation of SGSubsystem.
80     void init ();
81     void bind ();
82     void unbind ();
83     void update (double dt);
84
85     /// Compute the elevation of the scenery at geodetic latitude lat,
86     /// geodetic longitude lon and not higher than max_alt.
87     /// If the exact flag is set to true, the scenery center is moved to
88     /// gain a higher accuracy of that query. The center is restored past
89     /// that to the original value.
90     /// The altitude hit is returned in the alt argument.
91     /// The method returns true if the scenery is available for the given
92     /// lat/lon pair. If there is no scenery for that point, the altitude
93     /// value is undefined. 
94     /// All values are meant to be in meters or degrees.
95     bool get_elevation_m(double lat, double lon, double max_alt,
96                          double& alt, bool exact = false);
97
98     /// Compute the elevation of the scenery beow the cartesian point pos.
99     /// you the returned scenery altitude is not higher than the position
100     /// pos plus an ofset given with max_altoff.
101     /// If the exact flag is set to true, the scenery center is moved to
102     /// gain a higher accuracy of that query. The center is restored past
103     /// that to the original value.
104     /// The altitude hit is returned in the alt argument.
105     /// The method returns true if the scenery is available for the given
106     /// lat/lon pair. If there is no scenery for that point, the altitude
107     /// value is undefined.
108     /// All values are meant to be in meters.
109     bool get_cart_elevation_m(const sgdVec3& pos, double max_altoff,
110                               double& radius, bool exact = false);
111
112     /// Compute the nearest intersection point of the line starting from 
113     /// start going in direction dir with the terrain.
114     /// The input and output values should be in cartesian coordinates in the
115     /// usual earth centered wgs84 coordiante system. Units are meters.
116     /// On success, true is returned.
117     bool get_cart_ground_intersection(const sgdVec3& start, const sgdVec3& dir,
118                                       sgdVec3& nearestHit, bool exact = false);
119
120     inline const Point3D& get_center() const { return center; }
121     void set_center( const Point3D& p );
122
123     inline const Point3D& get_next_center() const { return next_center; }
124     inline void set_next_center( const Point3D& p ) { next_center = p; }
125
126     inline ssgRoot *get_scene_graph () const { return scene_graph; }
127     inline void set_scene_graph (ssgRoot * s) { scene_graph = s; }
128
129     inline ssgBranch *get_terrain_branch () const { return terrain_branch; }
130     inline void set_terrain_branch (ssgBranch * t) { terrain_branch = t; }
131
132     inline ssgRoot *get_gnd_lights_root () const {
133         return gnd_lights_root;
134     }
135     inline void set_gnd_lights_root (ssgRoot *r) {
136         gnd_lights_root = r;
137     }
138
139     inline ssgRoot *get_vasi_lights_root () const {
140         return vasi_lights_root;
141     }
142     inline void set_vasi_lights_root (ssgRoot *r) {
143         vasi_lights_root = r;
144     }
145
146     inline ssgRoot *get_rwy_lights_root () const {
147         return rwy_lights_root;
148     }
149     inline void set_rwy_lights_root (ssgRoot *r) {
150         rwy_lights_root = r;
151     }
152
153     inline ssgRoot *get_taxi_lights_root () const {
154         return taxi_lights_root;
155     }
156     inline void set_taxi_lights_root (ssgRoot *r) {
157         taxi_lights_root = r;
158     }
159
160     inline ssgBranch *get_models_branch () const {
161         return models_branch;
162     }
163     inline void set_models_branch (ssgBranch *t) {
164         models_branch = t;
165     }
166
167     inline ssgBranch *get_aircraft_branch () const {
168         return aircraft_branch;
169     }
170     inline void set_aircraft_branch (ssgBranch *t) {
171         aircraft_branch = t;
172     }
173
174     void register_placement_transform(ssgPlacementTransform *trans);
175     void unregister_placement_transform(ssgPlacementTransform *trans);
176 };
177
178
179 #endif // _SCENERY_HXX
180
181