]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/UFO.cxx
- Added ultra-light traffic is now a separate traffic class that can have its
[flightgear.git] / src / FDM / UFO.cxx
index ede9452d156d1f2bdbb78a7a27920d156f3d2f55..c741505de07102851d4d4ef73279fddb0ca89bd5 100644 (file)
@@ -17,7 +17,7 @@
 //
 // You should have received a copy of the GNU General Public License
 // along with this program; if not, write to the Free Software
-// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 //
 
 
@@ -46,7 +46,8 @@ FGUFO::FGUFO( double dt )
     Aileron(0.0),
     Elevator(0.0),
     Elevator_Trim(0.0),
-    Rudder(0.0)
+    Rudder(0.0),
+    Speed_Max(fgGetNode("/engines/engine/speed-max-mps", true))
 {
 //     set_delta_t( dt );
 }
@@ -60,6 +61,8 @@ FGUFO::~FGUFO() {
 // for each subsequent iteration through the EOM
 void FGUFO::init() {
     common_init();
+    if (Speed_Max->getDoubleValue() < 0.01)
+        Speed_Max->setDoubleValue(2000.0);
 }
 
 
@@ -74,8 +77,8 @@ void FGUFO::update( double dt ) {
 
     // read the throttle
     double th = globals->get_controls()->get_throttle( 0 );
-    if ( globals->get_controls()->get_brake_left() > 0.
-         || globals->get_controls()->get_brake_right() > 0.0 )
+    if ( globals->get_controls()->get_brake_left() > 0.5
+         || globals->get_controls()->get_brake_right() > 0.5 )
     {
         th = -th;
     }
@@ -93,7 +96,7 @@ void FGUFO::update( double dt ) {
                + Rudder * (1 - rudder_damp);
 
     // the velocity of the aircraft
-    double velocity = Throttle * 2000; // meters/sec
+    double velocity = Throttle * Speed_Max->getDoubleValue(); // meters/sec
 
     double old_pitch = get_Theta();
     double pitch_rate = SGD_PI_4; // assume I will be pitching up
@@ -192,8 +195,8 @@ void FGUFO::update( double dt ) {
     sgGeodToGeoc( get_Latitude(), get_Altitude(), &sl_radius, &lat_geoc );
 
     // update euler angles
-    _set_Euler_Angles( roll, pitch,
-                       fmod(get_Psi() + turn + yaw, SGD_2PI) );
+    double heading = fmod(get_Psi() + turn + yaw, SGD_2PI);
+    _set_Euler_Angles(roll, pitch, heading);
     _set_Euler_Rates(0,0,0);
 
     _set_Geocentric_Position( lat_geoc, get_Longitude(), 
@@ -203,4 +206,9 @@ void FGUFO::update( double dt ) {
     _update_ground_elev_at_pos();
     _set_Sea_level_radius( sl_radius * SG_METER_TO_FEET);
     _set_Altitude( get_Altitude() + climb );
+    _set_Altitude_AGL( get_Altitude() - get_Runway_altitude() );
+
+    set_V_north(cos(heading) * velocity * SG_METER_TO_FEET);
+    set_V_east(sin(heading) * velocity * SG_METER_TO_FEET);
+    set_V_down(-real_climb_rate);
 }