Put the Thermal and Storm support code back in
This commit is contained in:
parent
ed4509d8b5
commit
250ccf7bff
4 changed files with 85 additions and 11 deletions
|
@ -50,6 +50,8 @@ FGAIBase::FGAIBase() {
|
||||||
tgt_roll = roll = tgt_pitch = tgt_yaw = tgt_vs = vs = pitch = 0.0;
|
tgt_roll = roll = tgt_pitch = tgt_yaw = tgt_vs = vs = pitch = 0.0;
|
||||||
bearing = elevation = range = rdot = 0.0;
|
bearing = elevation = range = rdot = 0.0;
|
||||||
x_shift = y_shift = rotation = 0.0;
|
x_shift = y_shift = rotation = 0.0;
|
||||||
|
invisible = true;
|
||||||
|
model_path = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
FGAIBase::~FGAIBase() {
|
FGAIBase::~FGAIBase() {
|
||||||
|
@ -62,9 +64,11 @@ void FGAIBase::update(double dt) {
|
||||||
|
|
||||||
|
|
||||||
void FGAIBase::Transform() {
|
void FGAIBase::Transform() {
|
||||||
|
if (!invisible) {
|
||||||
aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
|
aip.setPosition(pos.lon(), pos.lat(), pos.elev() * SG_METER_TO_FEET);
|
||||||
aip.setOrientation(roll, pitch, hdg);
|
aip.setOrientation(roll, pitch, hdg);
|
||||||
aip.update( globals->get_scenery()->get_center() );
|
aip.update( globals->get_scenery()->get_center() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -76,16 +80,22 @@ bool FGAIBase::init() {
|
||||||
p_vec.clear();
|
p_vec.clear();
|
||||||
|
|
||||||
props = root->getNode(_type_str, num, true);
|
props = root->getNode(_type_str, num, true);
|
||||||
ssgBranch *model = sgLoad3DModel( globals->get_fg_root(),
|
ssgBranch *model = 0;
|
||||||
|
if (model_path != "") {
|
||||||
|
model = sgLoad3DModel( globals->get_fg_root(),
|
||||||
model_path.c_str(),
|
model_path.c_str(),
|
||||||
props,
|
props,
|
||||||
globals->get_sim_time_sec() );
|
globals->get_sim_time_sec() );
|
||||||
|
}
|
||||||
if (model) {
|
if (model) {
|
||||||
aip.init( model );
|
aip.init( model );
|
||||||
aip.setVisible(true);
|
aip.setVisible(true);
|
||||||
|
invisible = false;
|
||||||
globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph());
|
globals->get_scenery()->get_scene_graph()->addKid(aip.getSceneGraph());
|
||||||
} else {
|
} 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);
|
setDie(false);
|
||||||
|
|
|
@ -97,6 +97,7 @@ protected:
|
||||||
SGModelPlacement aip;
|
SGModelPlacement aip;
|
||||||
bool delete_me;
|
bool delete_me;
|
||||||
int id;
|
int id;
|
||||||
|
bool invisible;
|
||||||
|
|
||||||
void Transform();
|
void Transform();
|
||||||
|
|
||||||
|
|
|
@ -28,6 +28,8 @@
|
||||||
#include "AIAircraft.hxx"
|
#include "AIAircraft.hxx"
|
||||||
#include "AIShip.hxx"
|
#include "AIShip.hxx"
|
||||||
#include "AIBallistic.hxx"
|
#include "AIBallistic.hxx"
|
||||||
|
#include "AIStorm.hxx"
|
||||||
|
#include "AIThermal.hxx"
|
||||||
|
|
||||||
SG_USING_STD(list);
|
SG_USING_STD(list);
|
||||||
|
|
||||||
|
@ -89,6 +91,22 @@ void FGAIManager::init() {
|
||||||
entry->getDoubleValue("elevation"),
|
entry->getDoubleValue("elevation"),
|
||||||
entry->getDoubleValue("speed") );
|
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();
|
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 ) {
|
void FGAIManager::destroyObject( int ID ) {
|
||||||
ai_list_itr = ai_list.begin();
|
ai_list_itr = ai_list.begin();
|
||||||
while(ai_list_itr != ai_list.end()) {
|
while(ai_list_itr != ai_list.end()) {
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include "AIBase.hxx"
|
#include "AIBase.hxx"
|
||||||
#include "AIAircraft.hxx"
|
|
||||||
|
|
||||||
SG_USING_STD(list);
|
SG_USING_STD(list);
|
||||||
|
|
||||||
|
@ -54,7 +53,7 @@ private:
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
enum object_type { otAircraft, otShip, otBallistic, otRocket };
|
enum object_type { otAircraft, otShip, otBallistic, otRocket, otStorm, otThermal };
|
||||||
|
|
||||||
FGAIManager();
|
FGAIManager();
|
||||||
~FGAIManager();
|
~FGAIManager();
|
||||||
|
@ -94,6 +93,18 @@ public:
|
||||||
double elevation, // in degrees (same as pitch)
|
double elevation, // in degrees (same as pitch)
|
||||||
double speed ); // in feet per second
|
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 );
|
void destroyObject( int ID );
|
||||||
|
|
||||||
inline double get_user_latitude() { return user_latitude; }
|
inline double get_user_latitude() { return user_latitude; }
|
||||||
|
|
Loading…
Add table
Reference in a new issue