From 1853012d90fa2399c387bcdf5aad28e9024ebf9d Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 1 Sep 2004 08:32:54 +0000 Subject: [PATCH] Vivian Meazza: Attached are the modified files to add buoyancy as a parameter for a ballistic object. It may be set by adding x 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 x is not used, then there is no effect on the current ballistic model --- src/AIModel/AIBallistic.cxx | 17 +++++++++++------ src/AIModel/AIBallistic.hxx | 6 +++++- src/AIModel/AIManager.cxx | 6 ++++-- src/AIModel/AIManager.hxx | 9 ++++++--- src/AIModel/AIScenario.cxx | 3 ++- src/AIModel/AIScenario.hxx | 3 ++- 6 files changed, 30 insertions(+), 14 deletions(-) diff --git a/src/AIModel/AIBallistic.cxx b/src/AIModel/AIBallistic.cxx index b6675ff05..76e7a9485 100644 --- a/src/AIModel/AIBallistic.cxx +++ b/src/AIModel/AIBallistic.cxx @@ -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); } - diff --git a/src/AIModel/AIBallistic.hxx b/src/AIModel/AIBallistic.hxx index 8eb022818..7dca97c75 100644 --- a/src/AIModel/AIBallistic.hxx +++ b/src/AIModel/AIBallistic.hxx @@ -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); }; diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index de5f7de45..6269e8a26 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -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 ); } } } diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 8db9d6f5f..afa23eac6 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -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; } diff --git a/src/AIModel/AIScenario.cxx b/src/AIModel/AIScenario.cxx index 25b484c77..a431c2f5a 100644 --- a/src/AIModel/AIScenario.cxx +++ b/src/AIModel/AIScenario.cxx @@ -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(); diff --git a/src/AIModel/AIScenario.hxx b/src/AIModel/AIScenario.hxx index 8d1c6b549..cb798f093 100644 --- a/src/AIModel/AIScenario.hxx +++ b/src/AIModel/AIScenario.hxx @@ -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);