]> git.mxchange.org Git - flightgear.git/commitdiff
David Culp: Here are small changes that allow one to set a life-span for submodels.
authorehofman <ehofman>
Mon, 30 Aug 2004 09:11:59 +0000 (09:11 +0000)
committerehofman <ehofman>
Mon, 30 Aug 2004 09:11:59 +0000 (09:11 +0000)
src/AIModel/AIBallistic.cxx
src/AIModel/AIBallistic.hxx
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx
src/AIModel/AIScenario.cxx
src/AIModel/AIScenario.hxx
src/Systems/submodel.cxx
src/Systems/submodel.hxx

index ff1264114a45e2d3e54cf6500fe85a048ca15ea3..e06bf9f4b9b858260c0f3368571e279436a98b1a 100644 (file)
@@ -32,6 +32,7 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
     _type_str = "ballistic";
     _otype = otBallistic;
     drag_area = 0.007;
+    life_timer = 0.0;
 }
 
 FGAIBallistic::~FGAIBallistic() {
@@ -79,8 +80,15 @@ void FGAIBallistic::setDragArea(double a) {
    drag_area = a;
 }
 
+void FGAIBallistic::setLife(double seconds) {
+   life = seconds;
+}
+
 void FGAIBallistic::Run(double dt) {
 
+   life_timer += dt;
+   if (life_timer > life) setDie(true); 
+
    double speed_north_deg_sec;
    double speed_east_deg_sec;
 
index b6bf789d843d633f2da440069a9aa39d0e6eb766..8eb0228180879bf4ab9cea9420d540d020bbc48d 100644 (file)
@@ -40,6 +40,7 @@ public:
     void setElevation( double el );
     void setStabilization( bool val );
     void setDragArea( double a );
+    void setLife( double seconds );
 
 private:
 
@@ -48,6 +49,7 @@ private:
     double hs;              // horizontal speed (fps)
     bool aero_stabilized;   // if true, object will point where it's going
     double drag_area;       // equivalent drag area in ft2
+    double life_timer;      // seconds
     void Run(double dt);
 };
 
index dc48ca2b9f8ecabfe6d6051a635e015adccf10fb..a91f8d0a9ade3ffaba4d92eddfca41ee49d44726 100644 (file)
@@ -51,6 +51,7 @@ FGAIBase::FGAIBase() {
     in_range = false;
     invisible = true;
     no_roll = true;
+    life = 900;
     model_path = "";
     model = 0;
     _otype = otNull;
index 9bb85fa24aa2c7bd5646f2875005cdcd0a94e2e1..a46e945265387729dfe95d758b259e169e13cdd3 100644 (file)
@@ -108,6 +108,7 @@ protected:
     int id;
     bool invisible;
     bool no_roll;
+    double life;
     FGAIFlightPlan *fp;
 
     void Transform();
index 951b61d95257667c3f5c131a9e48925c92331f59..de5f7de45f25850c805a35eb1f843d07f5991a86 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 speed, double eda, double life ) {
 
         FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
         ai_list.push_back(ai_ballistic);
@@ -267,6 +267,7 @@ int FGAIManager::createBallistic( string path, double latitude, double longitude
         ai_ballistic->setLongitude(longitude);
         ai_ballistic->setLatitude(latitude);
         ai_ballistic->setDragArea(eda);
+        ai_ballistic->setLife(life);
         ai_ballistic->init();
         ai_ballistic->bind();
         return ai_ballistic->getID();
@@ -384,7 +385,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->eda, en->life );
       }      
     }
   }
index b3b06a4b89e32d020cd45379c1accd2ce7bf9393..8db9d6f5f4723df835fbef708013e360b320fe06 100644 (file)
@@ -98,7 +98,8 @@ public:
                          double azimuth,    // in degrees (same as heading)
                          double elevation,  // in degrees (same as pitch)
                          double speed,      // in feet per second
-                         double eda );      // equivalent drag area, ft2
+                         double eda,        // equivalent drag area, ft2
+                         double life );     // life span in seconds
 
     int createStorm( string path,        // path to exterior model
                      double latitude,    // in degrees -90 to 90
index f16991d81fcc15db0cea5548e2ce0110e48f0124..25b484c77083c2270e59a009c5c058ab7cdab658 100644 (file)
@@ -70,6 +70,7 @@ 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); 
    }
 
   entry_iterator = entries.begin();
index 26ced88cf6c894e1b5c4e782e25452cf72af6634..8d1c6b549082d27d0994f152907d7eb56fc83b09 100644 (file)
@@ -49,6 +49,7 @@ public:
    double strength;     // used by thermal objects
    double diameter;     // used by thermal objects
    double eda;          // used by ballistic objects
+   double life;         // life span in seconds
   } entry;
 
    FGAIScenario(string filename);
index 87f79eaa49dc8a6b34b0d1a3aa8bb47dbd03b926..f22146281cb5846dd5e43f9e337346be6fbd357f 100644 (file)
@@ -88,7 +88,7 @@ SubmodelSystem::release (submodel* sm, double dt)
 
   //cout << "Creating a submodel." << endl; 
   int rval = ai->createBallistic( sm->model, IC.lat, IC.lon, IC.alt, IC.azimuth,
-                                  IC.elevation, IC.speed, sm->drag_area );
+                                  IC.elevation, IC.speed, sm->drag_area, sm->life );
   //cout << "Submodel created." << endl;
   (sm->count)--; 
 
@@ -136,6 +136,7 @@ SubmodelSystem::load ()
      sm->yaw_offset     = entry_node->getDoubleValue("yaw-offset", 0.0); 
      sm->pitch_offset   = entry_node->getDoubleValue("pitch-offset", 0.0);
      sm->drag_area      = entry_node->getDoubleValue("eda", 0.007);
+     sm->life           = entry_node->getDoubleValue("life", 900.0);
 
      sm->trigger->setBoolValue(false);
      sm->timer = sm->delay;
index 93f6ab32ea060ce07b2f507dd8bd45f3d16d6fbf..f088173a0b79816904ee85ecfd32ecd19587c3df 100644 (file)
@@ -41,6 +41,7 @@ public:
   double             yaw_offset;
   double             pitch_offset;
   double             drag_area; 
+  double             life;
  } submodel; 
 
  typedef struct {