]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/UFO.cxx
Don't restore initial screen geometry because there is nothing in fg_os* to resize...
[flightgear.git] / src / FDM / UFO.cxx
index 357c26258d66d08a581ce9935514a7bfd0333c2c..c0f66b20f6a6ed85edf9218a64430a48e6935669 100644 (file)
 //
 // 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.
 //
 
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <simgear/math/sg_geodesy.hxx>
 #include <simgear/math/point3d.hxx>
 #include <simgear/math/polar3d.hxx>
 
-#include <Controls/controls.hxx>
+#include <Aircraft/controls.hxx>
 #include <Main/globals.hxx>
 #include <Main/fg_props.hxx>
 
 const double throttle_damp = 0.2;
 const double aileron_damp = 0.05;
 const double elevator_damp = 0.05;
+const double elevator_trim_damp = 0.05;
 const double rudder_damp = 0.4;
 
 FGUFO::FGUFO( double dt )
   : Throttle(0.0),
     Aileron(0.0),
     Elevator(0.0),
-    Rudder(0.0)
+    Elevator_Trim(0.0),
+    Rudder(0.0),
+    Speed_Max(fgGetNode("/engines/engine/speed-max-mps", true))
 {
 //     set_delta_t( dt );
 }
@@ -54,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);
 }
 
 
@@ -68,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;
     }
@@ -80,15 +89,18 @@ void FGUFO::update( double dt ) {
                + Aileron * (1 - aileron_damp);
     Elevator = globals->get_controls()->get_elevator() * elevator_damp
                + Elevator * (1 - elevator_damp);
+    Elevator_Trim = globals->get_controls()->get_elevator_trim()
+                    * elevator_trim_damp
+                    + Elevator_Trim * (1 - elevator_trim_damp);
     Rudder = globals->get_controls()->get_rudder() * rudder_damp
                + 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
-    double target_pitch = -Elevator * SGD_PI_2;
+    double target_pitch = (-Elevator - Elevator_Trim) * SGD_PI_2;
 
     // if I am pitching down
     if (old_pitch > target_pitch)