_otype = otBallistic;
drag_area = 0.007;
life_timer = 0.0;
-}
+ gravity = 32;
+ }
FGAIBallistic::~FGAIBallistic() {
}
bool FGAIBallistic::init() {
FGAIBase::init();
- aero_stabilized = true;
+ aero_stabilized = true;
hdg = azimuth;
pitch = elevation;
return true;
life = seconds;
}
+void FGAIBallistic::setBuoyancy(double fpss) {
+ buoyancy = fpss;
+}
+
+
void FGAIBallistic::Run(double dt) {
life_timer += dt;
pos.setlat( pos.lat() + speed_north_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)
altitude += vs * dt;
pos.setelev(altitude * SG_FEET_TO_METER);
- // adjust vertical speed for acceleration of gravity
- vs -= 32.17 * dt;
-
// recalculate pitch (velocity vector) if aerostabilized
if (aero_stabilized) pitch = atan2( vs, hs ) * SG_RADIANS_TO_DEGREES;
if (altitude < -1000.0) setDie(true);
}
-
void setStabilization( bool val );
void setDragArea( double a );
void setLife( double seconds );
-
+ void setBuoyancy( double fps2 );
+
private:
double azimuth; // degrees true
bool aero_stabilized; // if true, object will point where it's going
double drag_area; // equivalent drag area in ft2
double life_timer; // seconds
+ double gravity; // fps2
+ double buoyancy; // fps2
+
void Run(double dt);
};
int FGAIManager::createBallistic( string path, double latitude, double longitude,
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);
ai_list.push_back(ai_ballistic);
ai_ballistic->setLatitude(latitude);
ai_ballistic->setDragArea(eda);
ai_ballistic->setLife(life);
+ ai_ballistic->setBuoyancy(buoyancy);
ai_ballistic->init();
ai_ballistic->bind();
return ai_ballistic->getID();
return ai_thermal->getID();
}
+
void FGAIManager::destroyObject( int ID ) {
ai_list_itr = ai_list.begin();
while(ai_list_itr != ai_list.end()) {
} else if (en->aitype == "ballistic"){
createBallistic( en->model_path, en->latitude, en->longitude,
en->altitude, en->azimuth, en->elevation, en->speed,
- en->eda, en->life );
+ en->eda, en->life, en->buoyancy );
}
}
}
double elevation, // in degrees (same as pitch)
double speed, // in feet per second
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
double latitude, // in degrees -90 to 90
double longitude, // in degrees -180 to 180
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; }
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);
+ en->life = entry_node->getDoubleValue("life", 900.0);
+ en->buoyancy = entry_node->getDoubleValue("buoyancy", 0);
}
entry_iterator = entries.begin();
typedef struct {
string callsign;
- string aitype; // can be aircraft, ship, storm, thermal
+ string aitype; // can be aircraft, ship, storm, thermal, ballistic, smoke
string aircraft_class;
string model_path;
string flightplan;
double diameter; // used by thermal objects
double eda; // used by ballistic objects
double life; // life span in seconds
+ double buoyancy; // acceleration in ft per sec2
} entry;
FGAIScenario(string filename);