From 250ccf7bff86f4ad1d5fd11b7d919b4fa8b384a0 Mon Sep 17 00:00:00 2001 From: ehofman Date: Wed, 3 Mar 2004 20:33:08 +0000 Subject: [PATCH] Put the Thermal and Storm support code back in --- src/AIModel/AIBase.cxx | 26 +++++++++++++------ src/AIModel/AIBase.hxx | 1 + src/AIModel/AIManager.cxx | 54 ++++++++++++++++++++++++++++++++++++++- src/AIModel/AIManager.hxx | 15 +++++++++-- 4 files changed, 85 insertions(+), 11 deletions(-) diff --git a/src/AIModel/AIBase.cxx b/src/AIModel/AIBase.cxx index baa13f865..123a936e8 100644 --- a/src/AIModel/AIBase.cxx +++ b/src/AIModel/AIBase.cxx @@ -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); diff --git a/src/AIModel/AIBase.hxx b/src/AIModel/AIBase.hxx index 63e0128fe..a9a00408c 100644 --- a/src/AIModel/AIBase.hxx +++ b/src/AIModel/AIBase.hxx @@ -97,6 +97,7 @@ protected: SGModelPlacement aip; bool delete_me; int id; + bool invisible; void Transform(); diff --git a/src/AIModel/AIManager.cxx b/src/AIModel/AIManager.cxx index b3d3060da..394951f09 100644 --- a/src/AIModel/AIManager.cxx +++ b/src/AIModel/AIManager.cxx @@ -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()) { diff --git a/src/AIModel/AIManager.hxx b/src/AIModel/AIManager.hxx index 9b668f4cc..5b0e962b1 100644 --- a/src/AIModel/AIManager.hxx +++ b/src/AIModel/AIManager.hxx @@ -27,7 +27,6 @@ #include
#include #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; }