]> git.mxchange.org Git - flightgear.git/blob - src/Environment/environment_mgr.cxx
Updates to the scenery loading infrastructure to make it more flexible,
[flightgear.git] / src / Environment / environment_mgr.cxx
1 // environment-mgr.cxx -- manager for natural environment information.
2 //
3 // Written by David Megginson, started February 2002.
4 //
5 // Copyright (C) 2002  David Megginson - david@megginson.com
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., 675 Mass Ave, Cambridge, MA 02139, USA.
20 //
21 // $Id$
22
23 #include <simgear/debug/logstream.hxx>
24
25 #include <Main/fg_props.hxx>
26 #include <Aircraft/aircraft.hxx>
27
28 #include "environment_mgr.hxx"
29
30
31 FGEnvironmentMgr::FGEnvironmentMgr ()
32 {
33   _environment = new FGEnvironment();
34 }
35
36 FGEnvironmentMgr::~FGEnvironmentMgr ()
37 {
38   delete _environment;
39 }
40
41 void
42 FGEnvironmentMgr::init ()
43 {
44   SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
45 }
46
47 void
48 FGEnvironmentMgr::bind ()
49 {
50   fgTie("/environment/visibility-m", _environment,
51         &FGEnvironment::get_visibility_m, &FGEnvironment::set_visibility_m);
52   fgSetArchivable("/environment/visibility-m");
53   fgTie("/environment/temperature-sea-level-degc", _environment,
54         &FGEnvironment::get_temperature_sea_level_degc,
55         &FGEnvironment::set_temperature_sea_level_degc);
56   fgSetArchivable("/environment/temperature-sea-level-degc");
57   fgTie("/environment/pressure-sea-level-inhg", _environment,
58         &FGEnvironment::get_pressure_sea_level_inhg,
59         &FGEnvironment::set_pressure_sea_level_inhg);
60   fgSetArchivable("/environment/pressure-sea-level-inhg");
61   fgTie("/environment/wind-from-heading-deg", _environment,
62         &FGEnvironment::get_wind_from_heading_deg,
63         &FGEnvironment::set_wind_from_heading_deg);
64   fgTie("/environment/wind-speed-kt", _environment,
65         &FGEnvironment::get_wind_speed_kt, &FGEnvironment::set_wind_speed_kt);
66   fgTie("/environment/wind-from-north-fps", _environment,
67         &FGEnvironment::get_wind_from_north_fps,
68         &FGEnvironment::set_wind_from_north_fps);
69   fgSetArchivable("/environment/wind-from-north-fps");
70   fgTie("/environment/wind-from-east-fps", _environment,
71         &FGEnvironment::get_wind_from_east_fps,
72         &FGEnvironment::set_wind_from_east_fps);
73   fgSetArchivable("/environment/wind-from-east-fps");
74   fgTie("/environment/wind-from-down-fps", _environment,
75         &FGEnvironment::get_wind_from_down_fps,
76         &FGEnvironment::set_wind_from_down_fps);
77   fgSetArchivable("/environment/wind-from-down-fps");
78 }
79
80 void
81 FGEnvironmentMgr::unbind ()
82 {
83   fgUntie("/environment/visibility-m");
84   fgUntie("/environment/wind-from-heading-deg");
85   fgUntie("/environment/wind-speed-kt");
86   fgUntie("/environment/wind-from-north-fps");
87   fgUntie("/environment/wind-from-east-fps");
88   fgUntie("/environment/wind-from-down-fps");
89 }
90
91 void
92 FGEnvironmentMgr::update (int dt)
93 {
94                                 // FIXME: the FDMs should update themselves
95   current_aircraft.fdm_state
96     ->set_Velocities_Local_Airmass(_environment->get_wind_from_north_fps(),
97                                    _environment->get_wind_from_east_fps(),
98                                    _environment->get_wind_from_down_fps());
99 }
100
101 const FGEnvironment *
102 FGEnvironmentMgr::getEnvironment () const
103 {
104   return _environment;
105 }
106
107 const FGEnvironment *
108 FGEnvironmentMgr::getEnvironment (double lat, double lon, double alt) const
109 {
110                                 // Always returns the same environment
111                                 // for now; we'll make it interesting
112                                 // later.
113   return _environment;
114 }
115
116 // end of environment-mgr.cxx