]> git.mxchange.org Git - flightgear.git/blob - src/Environment/environment_mgr.cxx
9840d6de25ce066bd52366aebb4f462a4eab2c5b
[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/wind-from-heading-deg", _environment,
54         &FGEnvironment::get_wind_from_heading_deg,
55         &FGEnvironment::set_wind_from_heading_deg);
56   fgTie("/environment/wind-speed-kt", _environment,
57         &FGEnvironment::get_wind_speed_kt, &FGEnvironment::set_wind_speed_kt);
58   fgTie("/environment/wind-from-north-fps", _environment,
59         &FGEnvironment::get_wind_from_north_fps,
60         &FGEnvironment::set_wind_from_north_fps);
61   fgSetArchivable("/environment/wind-from-north-fps");
62   fgTie("/environment/wind-from-east-fps", _environment,
63         &FGEnvironment::get_wind_from_east_fps,
64         &FGEnvironment::set_wind_from_east_fps);
65   fgSetArchivable("/environment/wind-from-east-fps");
66   fgTie("/environment/wind-from-down-fps", _environment,
67         &FGEnvironment::get_wind_from_down_fps,
68         &FGEnvironment::set_wind_from_down_fps);
69   fgSetArchivable("/environment/wind-from-down-fps");
70 }
71
72 void
73 FGEnvironmentMgr::unbind ()
74 {
75   fgUntie("/environment/visibility-m");
76   fgUntie("/environment/wind-from-heading-deg");
77   fgUntie("/environment/wind-speed-kt");
78   fgUntie("/environment/wind-from-north-fps");
79   fgUntie("/environment/wind-from-east-fps");
80   fgUntie("/environment/wind-from-down-fps");
81 }
82
83 void
84 FGEnvironmentMgr::update (int dt)
85 {
86                                 // FIXME: the FDMs should update themselves
87   current_aircraft.fdm_state
88     ->set_Velocities_Local_Airmass(_environment->get_wind_from_north_fps(),
89                                    _environment->get_wind_from_east_fps(),
90                                    _environment->get_wind_from_down_fps());
91 }
92
93 const FGEnvironment *
94 FGEnvironmentMgr::getEnvironment () const
95 {
96   return _environment;
97 }
98
99 const FGEnvironment *
100 FGEnvironmentMgr::getEnvironment (double lat, double lon, double alt) const
101 {
102                                 // Always returns the same environment
103                                 // for now; we'll make it interesting
104                                 // later.
105   return _environment;
106 }
107
108 // end of environment-mgr.cxx