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() {
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() );
+ }
}
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);
#include "AIAircraft.hxx"
#include "AIShip.hxx"
#include "AIBallistic.hxx"
+#include "AIStorm.hxx"
+#include "AIThermal.hxx"
SG_USING_STD(list);
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") );
+
+ }
}
}
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()) {
#include <Main/fg_props.hxx>
#include <list>
#include "AIBase.hxx"
-#include "AIAircraft.hxx"
SG_USING_STD(list);
public:
- enum object_type { otAircraft, otShip, otBallistic, otRocket };
+ enum object_type { otAircraft, otShip, otBallistic, otRocket, otStorm, otThermal };
FGAIManager();
~FGAIManager();
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; }