1
0
Fork 0

David Culp: Here are small changes that allow one to set a life-span for submodels.

This commit is contained in:
ehofman 2004-08-30 09:11:59 +00:00
parent cfc05f5f0d
commit af284e4bb9
10 changed files with 22 additions and 4 deletions

View file

@ -32,6 +32,7 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
_type_str = "ballistic";
_otype = otBallistic;
drag_area = 0.007;
life_timer = 0.0;
}
FGAIBallistic::~FGAIBallistic() {
@ -79,8 +80,15 @@ void FGAIBallistic::setDragArea(double a) {
drag_area = a;
}
void FGAIBallistic::setLife(double seconds) {
life = seconds;
}
void FGAIBallistic::Run(double dt) {
life_timer += dt;
if (life_timer > life) setDie(true);
double speed_north_deg_sec;
double speed_east_deg_sec;

View file

@ -40,6 +40,7 @@ public:
void setElevation( double el );
void setStabilization( bool val );
void setDragArea( double a );
void setLife( double seconds );
private:
@ -48,6 +49,7 @@ private:
double hs; // horizontal speed (fps)
bool aero_stabilized; // if true, object will point where it's going
double drag_area; // equivalent drag area in ft2
double life_timer; // seconds
void Run(double dt);
};

View file

@ -51,6 +51,7 @@ FGAIBase::FGAIBase() {
in_range = false;
invisible = true;
no_roll = true;
life = 900;
model_path = "";
model = 0;
_otype = otNull;

View file

@ -108,6 +108,7 @@ protected:
int id;
bool invisible;
bool no_roll;
double life;
FGAIFlightPlan *fp;
void Transform();

View file

@ -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 speed, double eda, double life ) {
FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
ai_list.push_back(ai_ballistic);
@ -267,6 +267,7 @@ int FGAIManager::createBallistic( string path, double latitude, double longitude
ai_ballistic->setLongitude(longitude);
ai_ballistic->setLatitude(latitude);
ai_ballistic->setDragArea(eda);
ai_ballistic->setLife(life);
ai_ballistic->init();
ai_ballistic->bind();
return ai_ballistic->getID();
@ -384,7 +385,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->eda, en->life );
}
}
}

View file

@ -98,7 +98,8 @@ public:
double azimuth, // in degrees (same as heading)
double elevation, // in degrees (same as pitch)
double speed, // in feet per second
double eda ); // equivalent drag area, ft2
double eda, // equivalent drag area, ft2
double life ); // life span in seconds
int createStorm( string path, // path to exterior model
double latitude, // in degrees -90 to 90

View file

@ -70,6 +70,7 @@ 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);
}
entry_iterator = entries.begin();

View file

@ -49,6 +49,7 @@ public:
double strength; // used by thermal objects
double diameter; // used by thermal objects
double eda; // used by ballistic objects
double life; // life span in seconds
} entry;
FGAIScenario(string filename);

View file

@ -88,7 +88,7 @@ SubmodelSystem::release (submodel* sm, double dt)
//cout << "Creating a submodel." << endl;
int rval = ai->createBallistic( sm->model, IC.lat, IC.lon, IC.alt, IC.azimuth,
IC.elevation, IC.speed, sm->drag_area );
IC.elevation, IC.speed, sm->drag_area, sm->life );
//cout << "Submodel created." << endl;
(sm->count)--;
@ -136,6 +136,7 @@ SubmodelSystem::load ()
sm->yaw_offset = entry_node->getDoubleValue("yaw-offset", 0.0);
sm->pitch_offset = entry_node->getDoubleValue("pitch-offset", 0.0);
sm->drag_area = entry_node->getDoubleValue("eda", 0.007);
sm->life = entry_node->getDoubleValue("life", 900.0);
sm->trigger->setBoolValue(false);
sm->timer = sm->delay;

View file

@ -41,6 +41,7 @@ public:
double yaw_offset;
double pitch_offset;
double drag_area;
double life;
} submodel;
typedef struct {