1 // environment-mgr.cxx -- manager for natural environment information.
3 // Written by David Megginson, started February 2002.
5 // Copyright (C) 2002 David Megginson - david@megginson.com
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., 675 Mass Ave, Cambridge, MA 02139, USA.
23 #include <simgear/debug/logstream.hxx>
25 #include <Main/fg_props.hxx>
26 #include <Aircraft/aircraft.hxx>
28 #include "environment_mgr.hxx"
31 FGEnvironmentMgr::FGEnvironmentMgr ()
33 _environment = new FGEnvironment();
36 FGEnvironmentMgr::~FGEnvironmentMgr ()
42 FGEnvironmentMgr::init ()
44 SG_LOG( SG_GENERAL, SG_INFO, "Initializing environment subsystem");
48 FGEnvironmentMgr::bind ()
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");
73 FGEnvironmentMgr::unbind ()
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");
84 FGEnvironmentMgr::update (int dt)
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());
94 FGEnvironmentMgr::getEnvironment () const
100 FGEnvironmentMgr::getEnvironment (double lat, double lon, double alt) const
102 // Always returns the same environment
103 // for now; we'll make it interesting
108 // end of environment-mgr.cxx