]> git.mxchange.org Git - flightgear.git/commitdiff
Vivian Meazza:
authorehofman <ehofman>
Wed, 1 Sep 2004 08:32:54 +0000 (08:32 +0000)
committerehofman <ehofman>
Wed, 1 Sep 2004 08:32:54 +0000 (08:32 +0000)
Attached are the modified files to add buoyancy as a parameter for a
ballistic object. It may be set by adding

<buoyancy>x</buoyancy> to the submodel .xml file, where x is the appropriate
value (ft per sec2):

32   neutral buoyancy - contrails
>32  positive buoyancy - exhaust plumes
(0   non-op - default value)

If <buoyancy>x</buoyancy> is not used, then there is no effect on the
current ballistic model

src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/AIScenario.cxx
src/AIModel/AIScenario.hxx

index b6675ff05eb740c5db6c571af00328e36747b13d..76e7a9485c6291ac7c4ca4c20fc2213d2e0c6fab 100644 (file)
@@ -33,7 +33,8 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
     _otype = otBallistic;
     drag_area = 0.007;
     life_timer = 0.0;
-}
+    gravity = 32;
+    }
 
 FGAIBallistic::~FGAIBallistic() {
 }
@@ -41,7 +42,7 @@ FGAIBallistic::~FGAIBallistic() {
 
 bool FGAIBallistic::init() {
    FGAIBase::init();
-   aero_stabilized =  true;
+   aero_stabilized = true;
    hdg = azimuth;
    pitch = elevation;
    return true;
@@ -86,6 +87,11 @@ void FGAIBallistic::setLife(double seconds) {
    life = seconds;
 }
 
+void FGAIBallistic::setBuoyancy(double fpss) {
+   buoyancy = fpss;
+}
+
+
 void FGAIBallistic::Run(double dt) {
 
    life_timer += dt;
@@ -110,13 +116,13 @@ void FGAIBallistic::Run(double dt) {
    pos.setlat( pos.lat() + speed_north_deg_sec * dt);
    pos.setlon( pos.lon() + speed_east_deg_sec * dt); 
 
+   // adjust vertical speed for acceleration of gravity
+   vs -= (gravity - buoyancy) * dt;
+   
    // adjust altitude (feet)
    altitude += vs * dt;
    pos.setelev(altitude * SG_FEET_TO_METER); 
 
-   // adjust vertical speed for acceleration of gravity
-   vs -= 32.17 * dt;
-
    // recalculate pitch (velocity vector) if aerostabilized
    if (aero_stabilized) pitch = atan2( vs, hs ) * SG_RADIANS_TO_DEGREES;
 
@@ -127,4 +133,3 @@ void FGAIBallistic::Run(double dt) {
    if (altitude < -1000.0) setDie(true);
 
 }
-
index 8eb0228180879bf4ab9cea9420d540d020bbc48d..7dca97c7531257bfa58b01e6c42bed825105e76a 100644 (file)
@@ -41,7 +41,8 @@ public:
     void setStabilization( bool val );
     void setDragArea( double a );
     void setLife( double seconds );
-
+    void setBuoyancy( double fps2 );
+       
 private:
 
     double azimuth;         // degrees true
@@ -50,6 +51,9 @@ private:
     bool aero_stabilized;   // if true, object will point where it's going
     double drag_area;       // equivalent drag area in ft2
     double life_timer;      // seconds
+    double gravity;         // fps2
+    double buoyancy;        // fps2
+               
     void Run(double dt);
 };
 
index de5f7de45f25850c805a35eb1f843d07f5991a86..6269e8a268c1f311ec01aa9b6524e2ae2f553d5a 100644 (file)
@@ -253,7 +253,7 @@ int FGAIManager::createShip( string path, FGAIFlightPlan* flightplan ) {
 
 int FGAIManager::createBallistic( string path, double latitude, double longitude,
                                   double altitude, double azimuth, double elevation,
-                                  double speed, double eda, double life ) {
+                                  double speed, double eda, double life, double buoyancy ) {
 
         FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
         ai_list.push_back(ai_ballistic);
@@ -268,6 +268,7 @@ int FGAIManager::createBallistic( string path, double latitude, double longitude
         ai_ballistic->setLatitude(latitude);
         ai_ballistic->setDragArea(eda);
         ai_ballistic->setLife(life);
+        ai_ballistic->setBuoyancy(buoyancy);
         ai_ballistic->init();
         ai_ballistic->bind();
         return ai_ballistic->getID();
@@ -307,6 +308,7 @@ int FGAIManager::createThermal( double latitude, double longitude,
         return ai_thermal->getID();
 }
 
+
 void FGAIManager::destroyObject( int ID ) {
         ai_list_itr = ai_list.begin();
         while(ai_list_itr != ai_list.end()) {
@@ -385,7 +387,7 @@ void FGAIManager::processScenario( string filename ) {
       } else if (en->aitype == "ballistic"){
         createBallistic( en->model_path, en->latitude, en->longitude,
                          en->altitude, en->azimuth, en->elevation, en->speed,
-                         en->eda, en->life );
+                         en->eda, en->life, en->buoyancy );
       }      
     }
   }
index 8db9d6f5f4723df835fbef708013e360b320fe06..afa23eac6da0c91e1961537d359ea5f087331e51 100644 (file)
@@ -99,8 +99,10 @@ public:
                          double elevation,  // in degrees (same as pitch)
                          double speed,      // in feet per second
                          double eda,        // equivalent drag area, ft2
-                         double life );     // life span in seconds
-
+                         double life,       // life span in seconds
+                         double buoyancy    // acceleration in ft per second2
+                         );
+     
     int createStorm( string path,        // path to exterior model
                      double latitude,    // in degrees -90 to 90
                      double longitude,   // in degrees -180 to 180
@@ -112,7 +114,8 @@ public:
                        double longitude,   // in degrees -180 to 180
                        double strength,    // in feet per second
                        double diameter );  // in feet
-                 
+
+        
     void destroyObject( int ID );
 
     inline double get_user_latitude() { return user_latitude; }
index 25b484c77083c2270e59a009c5c058ab7cdab658..a431c2f5afeaf488fbedc75809d4e8d1485ff1e7 100644 (file)
@@ -70,7 +70,8 @@ FGAIScenario::FGAIScenario(string filename)
      en->strength       = entry_node->getDoubleValue("strength-fps", 0.0);
      en->diameter       = entry_node->getDoubleValue("diameter-ft", 0.0);
      en->eda            = entry_node->getDoubleValue("eda", 0.007);
-     en->life           = entry_node->getDoubleValue("life", 900.0); 
+     en->life           = entry_node->getDoubleValue("life", 900.0);
+     en->buoyancy       = entry_node->getDoubleValue("buoyancy", 0); 
    }
 
   entry_iterator = entries.begin();
index 8d1c6b549082d27d0994f152907d7eb56fc83b09..cb798f093b29553541dbda97b1856e4e55ef1323 100644 (file)
@@ -32,7 +32,7 @@ public:
 
   typedef struct {
    string callsign;
-   string aitype;       // can be aircraft, ship, storm, thermal
+   string aitype;       // can be aircraft, ship, storm, thermal, ballistic, smoke
    string aircraft_class;
    string model_path;
    string flightplan;
@@ -50,6 +50,7 @@ public:
    double diameter;     // used by thermal objects
    double eda;          // used by ballistic objects
    double life;         // life span in seconds
+   double buoyancy;     // acceleration in ft per sec2
   } entry;
 
    FGAIScenario(string filename);