1
0
Fork 0

Vivian Meazza:

Attached are the modified files to add buoyancy as a parameter for a
ballistic object. It may be set by adding

<buoyancy>x</buoyancy> 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 <buoyancy>x</buoyancy> is not used, then there is no effect on the
current ballistic model
This commit is contained in:
ehofman 2004-09-01 08:32:54 +00:00
parent d2d27f2d76
commit 1853012d90
6 changed files with 30 additions and 14 deletions

View file

@ -33,7 +33,8 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
_otype = otBallistic; _otype = otBallistic;
drag_area = 0.007; drag_area = 0.007;
life_timer = 0.0; life_timer = 0.0;
} gravity = 32;
}
FGAIBallistic::~FGAIBallistic() { FGAIBallistic::~FGAIBallistic() {
} }
@ -41,7 +42,7 @@ FGAIBallistic::~FGAIBallistic() {
bool FGAIBallistic::init() { bool FGAIBallistic::init() {
FGAIBase::init(); FGAIBase::init();
aero_stabilized = true; aero_stabilized = true;
hdg = azimuth; hdg = azimuth;
pitch = elevation; pitch = elevation;
return true; return true;
@ -86,6 +87,11 @@ void FGAIBallistic::setLife(double seconds) {
life = seconds; life = seconds;
} }
void FGAIBallistic::setBuoyancy(double fpss) {
buoyancy = fpss;
}
void FGAIBallistic::Run(double dt) { void FGAIBallistic::Run(double dt) {
life_timer += dt; life_timer += dt;
@ -110,13 +116,13 @@ void FGAIBallistic::Run(double dt) {
pos.setlat( pos.lat() + speed_north_deg_sec * dt); pos.setlat( pos.lat() + speed_north_deg_sec * dt);
pos.setlon( pos.lon() + speed_east_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) // adjust altitude (feet)
altitude += vs * dt; altitude += vs * dt;
pos.setelev(altitude * SG_FEET_TO_METER); pos.setelev(altitude * SG_FEET_TO_METER);
// adjust vertical speed for acceleration of gravity
vs -= 32.17 * dt;
// recalculate pitch (velocity vector) if aerostabilized // recalculate pitch (velocity vector) if aerostabilized
if (aero_stabilized) pitch = atan2( vs, hs ) * SG_RADIANS_TO_DEGREES; 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); if (altitude < -1000.0) setDie(true);
} }

View file

@ -41,7 +41,8 @@ public:
void setStabilization( bool val ); void setStabilization( bool val );
void setDragArea( double a ); void setDragArea( double a );
void setLife( double seconds ); void setLife( double seconds );
void setBuoyancy( double fps2 );
private: private:
double azimuth; // degrees true double azimuth; // degrees true
@ -50,6 +51,9 @@ private:
bool aero_stabilized; // if true, object will point where it's going bool aero_stabilized; // if true, object will point where it's going
double drag_area; // equivalent drag area in ft2 double drag_area; // equivalent drag area in ft2
double life_timer; // seconds double life_timer; // seconds
double gravity; // fps2
double buoyancy; // fps2
void Run(double dt); void Run(double dt);
}; };

View file

@ -253,7 +253,7 @@ int FGAIManager::createShip( string path, FGAIFlightPlan* flightplan ) {
int FGAIManager::createBallistic( string path, double latitude, double longitude, int FGAIManager::createBallistic( string path, double latitude, double longitude,
double altitude, double azimuth, double elevation, 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); FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
ai_list.push_back(ai_ballistic); 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->setLatitude(latitude);
ai_ballistic->setDragArea(eda); ai_ballistic->setDragArea(eda);
ai_ballistic->setLife(life); ai_ballistic->setLife(life);
ai_ballistic->setBuoyancy(buoyancy);
ai_ballistic->init(); ai_ballistic->init();
ai_ballistic->bind(); ai_ballistic->bind();
return ai_ballistic->getID(); return ai_ballistic->getID();
@ -307,6 +308,7 @@ int FGAIManager::createThermal( double latitude, double longitude,
return ai_thermal->getID(); 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()) {
@ -385,7 +387,7 @@ void FGAIManager::processScenario( string filename ) {
} else if (en->aitype == "ballistic"){ } else if (en->aitype == "ballistic"){
createBallistic( en->model_path, en->latitude, en->longitude, createBallistic( en->model_path, en->latitude, en->longitude,
en->altitude, en->azimuth, en->elevation, en->speed, en->altitude, en->azimuth, en->elevation, en->speed,
en->eda, en->life ); en->eda, en->life, en->buoyancy );
} }
} }
} }

View file

@ -99,8 +99,10 @@ 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
double eda, // equivalent drag area, ft2 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 int createStorm( string path, // path to exterior model
double latitude, // in degrees -90 to 90 double latitude, // in degrees -90 to 90
double longitude, // in degrees -180 to 180 double longitude, // in degrees -180 to 180
@ -112,7 +114,8 @@ public:
double longitude, // in degrees -180 to 180 double longitude, // in degrees -180 to 180
double strength, // in feet per second double strength, // in feet per second
double diameter ); // in feet 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; }

View file

@ -70,7 +70,8 @@ FGAIScenario::FGAIScenario(string filename)
en->strength = entry_node->getDoubleValue("strength-fps", 0.0); en->strength = entry_node->getDoubleValue("strength-fps", 0.0);
en->diameter = entry_node->getDoubleValue("diameter-ft", 0.0); en->diameter = entry_node->getDoubleValue("diameter-ft", 0.0);
en->eda = entry_node->getDoubleValue("eda", 0.007); 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(); entry_iterator = entries.begin();

View file

@ -32,7 +32,7 @@ public:
typedef struct { typedef struct {
string callsign; string callsign;
string aitype; // can be aircraft, ship, storm, thermal string aitype; // can be aircraft, ship, storm, thermal, ballistic, smoke
string aircraft_class; string aircraft_class;
string model_path; string model_path;
string flightplan; string flightplan;
@ -50,6 +50,7 @@ public:
double diameter; // used by thermal objects double diameter; // used by thermal objects
double eda; // used by ballistic objects double eda; // used by ballistic objects
double life; // life span in seconds double life; // life span in seconds
double buoyancy; // acceleration in ft per sec2
} entry; } entry;
FGAIScenario(string filename); FGAIScenario(string filename);