]> git.mxchange.org Git - flightgear.git/commitdiff
Put the Thermal and Storm support code back in
authorehofman <ehofman>
Wed, 3 Mar 2004 20:33:08 +0000 (20:33 +0000)
committerehofman <ehofman>
Wed, 3 Mar 2004 20:33:08 +0000 (20:33 +0000)
src/AIModel/AIBase.cxx
src/AIModel/AIBase.hxx
src/AIModel/AIManager.cxx
src/AIModel/AIManager.hxx

index baa13f8655f669d15a7b094bb30f821124e009db..123a936e8bb16621ebd1e340ac89f2d34d4a0cc9 100644 (file)
@@ -50,6 +50,8 @@ FGAIBase::FGAIBase() {
     tgt_roll = roll = tgt_pitch = tgt_yaw = tgt_vs = vs = pitch = 0.0;
     bearing = elevation = range = rdot = 0.0;
     x_shift = y_shift = rotation = 0.0;
+    invisible = true;
+    model_path = "";
 }
 
 FGAIBase::~FGAIBase() {
@@ -62,9 +64,11 @@ void FGAIBase::update(double dt) {
 
 
 void FGAIBase::Transform() {
-    aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
-    aip.setOrientation(roll, pitch, hdg);
-    aip.update( globals->get_scenery()->get_center() );    
+    if (!invisible) {
+      aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
+      aip.setOrientation(roll, pitch, hdg);
+      aip.update( globals->get_scenery()->get_center() );    
+    }
 }
 
 
@@ -76,16 +80,22 @@ bool FGAIBase::init() {
    p_vec.clear();
 
    props = root->getNode(_type_str, num, true);
-   ssgBranch *model = sgLoad3DModel( globals->get_fg_root(),
-                                    model_path.c_str(),
-                                     props,
-                                    globals->get_sim_time_sec() );
+   ssgBranch *model = 0;
+   if (model_path != "") {
+      model = sgLoad3DModel( globals->get_fg_root(),
+                            model_path.c_str(),
+                             props,
+                            globals->get_sim_time_sec() );
+   }
    if (model) {
      aip.init( model );
      aip.setVisible(true);
+     invisible = false;
      globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph());
    } else {
-     SG_LOG(SG_INPUT, SG_WARN, "AIBase: Could not load aircraft model.");
+     if (model_path != "") { 
+       SG_LOG(SG_INPUT, SG_WARN, "AIBase: Could not load model.");
+     }
    } 
 
    setDie(false);
index 63e0128fe0c8801fa6deed41b4382384dc71973c..a9a00408cbd85aab1e229d86c0d1b324850357df 100644 (file)
@@ -97,6 +97,7 @@ protected:
     SGModelPlacement aip;
     bool delete_me;
     int id;
+    bool invisible;
 
     void Transform();
 
index b3d3060da74ce6772e3d96dc4ec53fbc8c656ea3..394951f09b4405526dbc4054930fd8723e0a17f4 100644 (file)
@@ -28,6 +28,8 @@
 #include "AIAircraft.hxx"
 #include "AIShip.hxx"
 #include "AIBallistic.hxx"
+#include "AIStorm.hxx"
+#include "AIThermal.hxx"
 
 SG_USING_STD(list);
 
@@ -89,7 +91,23 @@ void FGAIManager::init() {
                                 entry->getDoubleValue("elevation"),
                                 entry->getDoubleValue("speed") );
 
-      } 
+      } else if (!strcmp(entry->getStringValue("type", ""), "storm")) {
+
+        rval = createStorm( entry->getStringValue("path"),
+                            entry->getDoubleValue("latitude"),
+                            entry->getDoubleValue("longitude"),
+                            entry->getDoubleValue("altitude-ft"),
+                            entry->getDoubleValue("heading"),
+                            entry->getDoubleValue("speed-KTAS") );
+
+      } else if (!strcmp(entry->getStringValue("type", ""), "thermal")) {
+
+        rval = createThermal( entry->getDoubleValue("latitude"),
+                              entry->getDoubleValue("longitude"),
+                              entry->getDoubleValue("strength-fps"),
+                              entry->getDoubleValue("diameter-ft") );
+
+      }       
     }
   }
 
@@ -232,6 +250,40 @@ int FGAIManager::createBallistic( string path, double latitude, double longitude
         return ai_ballistic->getID();
 }
 
+int FGAIManager::createStorm( string path, double latitude, double longitude,
+                             double altitude, double heading, double speed ) {
+
+        FGAIStorm* ai_storm = new FGAIStorm(this);
+        ai_list.push_back(ai_storm);
+        ai_storm->setID( assignID() );
+        ++numObjects;
+        ai_storm->setHeading(heading);
+        ai_storm->setSpeed(speed);
+        ai_storm->setPath(path.c_str());
+        ai_storm->setAltitude(altitude);
+        ai_storm->setLongitude(longitude);
+        ai_storm->setLatitude(latitude);
+        ai_storm->init();
+        ai_storm->bind();
+        return ai_storm->getID();
+}
+
+int FGAIManager::createThermal( double latitude, double longitude,
+                                double strength, double diameter ) {
+
+        FGAIThermal* ai_thermal = new FGAIThermal(this);
+        ai_list.push_back(ai_thermal);
+        ai_thermal->setID( assignID() );
+        ++numObjects;
+        ai_thermal->setLongitude(longitude);
+        ai_thermal->setLatitude(latitude);
+        ai_thermal->setStrength(strength);
+        ai_thermal->setDiameter(diameter / 6076.11549);
+        ai_thermal->init();
+        ai_thermal->bind();
+        return ai_thermal->getID();
+}
+
 void FGAIManager::destroyObject( int ID ) {
         ai_list_itr = ai_list.begin();
         while(ai_list_itr != ai_list.end()) {
index 9b668f4ccbfb70a69685733e1d171fd3cbff9f37..5b0e962b17de668352aa5a6c89fc8da586c9bcda 100644 (file)
@@ -27,7 +27,6 @@
 #include <Main/fg_props.hxx>
 #include <list>
 #include "AIBase.hxx"
-#include "AIAircraft.hxx"
 
 SG_USING_STD(list);
 
@@ -54,7 +53,7 @@ private:
 
 public:
 
-    enum object_type { otAircraft, otShip, otBallistic, otRocket };
+    enum object_type { otAircraft, otShip, otBallistic, otRocket, otStorm, otThermal };
 
     FGAIManager();
     ~FGAIManager();
@@ -94,6 +93,18 @@ public:
                          double elevation,  // in degrees (same as pitch)
                          double speed );    // in feet per second
 
+    int createStorm( string path,        // path to exterior model
+                     double latitude,    // in degrees -90 to 90
+                     double longitude,   // in degrees -180 to 180
+                     double altitude,    // in feet
+                     double heading,     // true heading in degrees
+                     double speed );     // in knots true airspeed (KTAS)    
+
+    int createThermal( double latitude,    // in degrees -90 to 90
+                       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; }