]> git.mxchange.org Git - flightgear.git/blobdiff - src/FDM/Balloon.cxx
I forgot a linker dependency. It really si time to figure out why these are all needed.
[flightgear.git] / src / FDM / Balloon.cxx
index 216a7d42ce395f88df977684faa3bceea4e5827c..9d7f19bad4d59d0664adb832b389187bf5ec2347 100644 (file)
@@ -37,9 +37,13 @@ HISTORY
 /* INCLUDES                                                                */
 /****************************************************************************/
 
+#ifdef HAVE_CONFIG_H
+#  include <config.h>
+#endif
+
 #include <simgear/compiler.h>
 
-#ifdef FG_MATH_EXCEPTION_CLASH
+#ifdef SG_MATH_EXCEPTION_CLASH
 #  include <math.h>
 #endif
 
@@ -48,11 +52,12 @@ HISTORY
 #include <simgear/constants.h>
 #include <simgear/debug/logstream.hxx>
 #include <simgear/math/sg_geodesy.hxx>
-#include <simgear/misc/fgpath.hxx>
+#include <simgear/misc/sg_path.hxx>
 
 #include <Aircraft/aircraft.hxx>
 #include <Controls/controls.hxx>
 #include <Main/globals.hxx>
+#include <Main/fg_props.hxx>
 
 #include "Balloon.h"
 
@@ -61,23 +66,36 @@ HISTORY
 /****************************************************************************/
 
 
+FGBalloonSim::FGBalloonSim( double dt ) {
+    //set the dt of the model
+    current_balloon.set_dt(dt);
+}
+
+
+FGBalloonSim::~FGBalloonSim() {
+}
+
+
 // Initialize the BalloonSim flight model, dt is the time increment for
 // each subsequent iteration through the EOM
-bool FGBalloonSim::init( double dt ) {
-    sgVec3 temp;
+void FGBalloonSim::init() {
+               
+    //do init common to all the FDM's          
+    common_init();
+    
+    //now do init specific to the Balloon
 
-    FG_LOG( FG_FLIGHT, FG_INFO, "Starting initializing BalloonSim" );
+    sgVec3 temp;
 
-    FG_LOG( FG_FLIGHT, FG_INFO, "  created a balloon" );
+    SG_LOG( SG_FLIGHT, SG_INFO, "Starting initializing BalloonSim" );
 
-    //set the dt of the model
-    current_balloon.set_dt(dt);
+    SG_LOG( SG_FLIGHT, SG_INFO, "  created a balloon" );
 
     //set position
     sgSetVec3( temp,
        get_Latitude(), 
        get_Longitude(), 
-       get_Altitude() * FEET_TO_METER);
+       get_Altitude() * SG_FEET_TO_METER);
     current_balloon.setPosition( temp );
 
     //set Euler angles (?)
@@ -89,21 +107,24 @@ bool FGBalloonSim::init( double dt ) {
 
     //set velocities
     sgSetVec3( temp,
-       globals->get_options()->get_uBody(), 
-       globals->get_options()->get_vBody(), 
-       globals->get_options()->get_wBody() );
+              fgGetDouble("/sim/presets/uBody-fps"),
+              fgGetDouble("/sim/presets/vBody-fps"),
+              fgGetDouble("/sim/presets/wBody-fps") );
     current_balloon.setVelocity( temp );
 
-    FG_LOG( FG_FLIGHT, FG_INFO, "Finished initializing BalloonSim" );
-
-    return true;
+    SG_LOG( SG_FLIGHT, SG_INFO, "Finished initializing BalloonSim" );
 }
 
 
 // Run an iteration of the EOM (equations of motion)
-bool FGBalloonSim::update( int multiloop ) {
+void FGBalloonSim::update( double dt ) {
     double save_alt = 0.0;
 
+    if (is_suspended())
+      return;
+
+    int multiloop = _calc_multiloop(dt);
+
     // lets try to avoid really screwing up the BalloonSim model
     if ( get_Altitude() < -9000 ) {
        save_alt = get_Altitude();
@@ -111,11 +132,11 @@ bool FGBalloonSim::update( int multiloop ) {
     }
 
     // set control positions
-    current_balloon.set_burner_strength ( controls.get_throttle(0) );
+    current_balloon.set_burner_strength ( globals->get_controls()->get_throttle(0) );
     //not more implemented yet
 
     // Inform BalloonSim of the local terrain altitude
-    current_balloon.setGroundLevel ( get_Runway_altitude() * FEET_TO_METER);
+    current_balloon.setGroundLevel ( get_Runway_altitude() * SG_FEET_TO_METER);
 
     // old -- FGInterface_2_JSBsim() not needed except for Init()
     // translate FG to JSBsim structure
@@ -140,7 +161,7 @@ bool FGBalloonSim::update( int multiloop ) {
     /*sgVec3 temp, temp2;
     current_balloon.getPosition( temp );
     current_balloon.getVelocity( temp2 );
-    FG_LOG( FG_FLIGHT, FG_INFO, "T: " << current_balloon.getTemperature() <<
+    SG_LOG( SG_FLIGHT, SG_INFO, "T: " << current_balloon.getTemperature() <<
                                " alt: " << temp[2] <<
                                " gr_alt: " << get_Runway_altitude() << 
                                " burner: " << controls.get_elevator() <<
@@ -150,8 +171,6 @@ bool FGBalloonSim::update( int multiloop ) {
     if ( save_alt < -9000.0 ) {
        set_Altitude( save_alt );
     }
-
-    return true;
 }
 
 
@@ -180,7 +199,7 @@ bool FGBalloonSim::copy_from_BalloonSim() {
     //temp[1]: longitude
     //temp[2]: altitude (meters)
 
-    _updatePosition( temp[0], temp[1], temp[2] * METER_TO_FEET  );
+    _updateGeocentricPosition( temp[0], temp[1], temp[2] * SG_METER_TO_FEET );
     
     current_balloon.getHPR( temp );
     set_Euler_Angles( temp[0], temp[1], temp[2] );