1
0
Fork 0

David Culp:

Silly me.  I was starting the timer at zero, so the first tracer didn't fly
until 0.25 seconds after pulling the trigger.  Now the timer starts at the
same value as "delay", so the first round comes out immediately.

Also, I've added an optional configuration attribute that allows you to change
the ballistics of the submodel.  This allows parachutes, or anything else
that has ballistics different from a bullet.  The attribute is called "eda",
which is the equivalent drag area.  Default value is 0.007, which gives the
same ballistics as the current tracers.  Increasing this value gives more
drag.  A value of 2.0 looks good for a parachute.


math stuff
########################################################################
The deceleration of the ballictic object is now given by:

[ (rho) (Cd) ] / [ (1/2) (m) ] * A * (V * V)

where rho is sea-level air density, and Cd and m are fixed, bullet-like
values. So the calculation is:

0.0116918 * A * (V * V)

The value "A" is what I'm calling the "eda" (equivalent drag area).
########################################################################


A parachute model will have to be built so that the parachutist's feet
are in the forward x-direction.
Here is the submodel.xml config I use for "parachutes":

  <submodel>
    <name>flares</name>
    <model>Models/Geometry/flare.ac</model>
    <trigger>systems/submodels/submodel[0]/trigger</trigger>
    <speed>0.0</speed>
    <repeat>true</repeat>
    <delay>0.85</delay>
    <count>4</count>
    <x-offset>0.0</x-offset>
    <y-offset>0.0</y-offset>
    <z-offset>-4.0</z-offset>
    <yaw-offset>0.0</yaw-offset>
    <pitch-offset>0.0</pitch-offset>
    <eda>2.0</eda>
  </submodel>
This commit is contained in:
ehofman 2004-08-26 16:25:54 +00:00
parent 065d4d8da1
commit cfc05f5f0d
8 changed files with 20 additions and 8 deletions

View file

@ -31,6 +31,7 @@ FGAIBallistic::FGAIBallistic(FGAIManager* mgr) {
manager = mgr;
_type_str = "ballistic";
_otype = otBallistic;
drag_area = 0.007;
}
FGAIBallistic::~FGAIBallistic() {
@ -74,6 +75,9 @@ void FGAIBallistic::setStabilization(bool val) {
aero_stabilized = val;
}
void FGAIBallistic::setDragArea(double a) {
drag_area = a;
}
void FGAIBallistic::Run(double dt) {
@ -81,9 +85,9 @@ void FGAIBallistic::Run(double dt) {
double speed_east_deg_sec;
// the two drag calculations below assume sea-level density,
// mass of 0.03 slugs, drag coeff of 0.295, frontal area of 0.007 ft2
// mass of 0.03 slugs, drag coeff of 0.295
// adjust speed due to drag
speed -= 0.000082 * speed * speed * dt;
speed -= 0.0116918 * drag_area * speed * speed * dt;
if ( speed < 0.0 ) speed = 0.0;
vs = sin( pitch * SG_DEGREES_TO_RADIANS ) * speed;
hs = cos( pitch * SG_DEGREES_TO_RADIANS ) * speed;

View file

@ -39,6 +39,7 @@ public:
void setAzimuth( double az );
void setElevation( double el );
void setStabilization( bool val );
void setDragArea( double a );
private:
@ -46,7 +47,7 @@ private:
double elevation; // degrees
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
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,
double altitude, double azimuth, double elevation,
double speed ) {
double speed, double eda ) {
FGAIBallistic* ai_ballistic = new FGAIBallistic(this);
ai_list.push_back(ai_ballistic);
@ -266,6 +266,7 @@ int FGAIManager::createBallistic( string path, double latitude, double longitude
ai_ballistic->setAltitude(altitude);
ai_ballistic->setLongitude(longitude);
ai_ballistic->setLatitude(latitude);
ai_ballistic->setDragArea(eda);
ai_ballistic->init();
ai_ballistic->bind();
return ai_ballistic->getID();
@ -382,7 +383,8 @@ void FGAIManager::processScenario( string filename ) {
en->diameter );
} else if (en->aitype == "ballistic"){
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 );
}
}
}

View file

@ -97,7 +97,8 @@ public:
double altitude, // in feet
double azimuth, // in degrees (same as heading)
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
int createStorm( string path, // path to exterior model
double latitude, // in degrees -90 to 90

View file

@ -69,6 +69,7 @@ FGAIScenario::FGAIScenario(string filename)
en->rudder = entry_node->getDoubleValue("rudder", 0.0);
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);
}
entry_iterator = entries.begin();

View file

@ -48,6 +48,7 @@ public:
double rudder; // used by ship objects
double strength; // used by thermal objects
double diameter; // used by thermal objects
double eda; // used by ballistic objects
} 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 );
IC.elevation, IC.speed, sm->drag_area );
//cout << "Submodel created." << endl;
(sm->count)--;
@ -135,9 +135,10 @@ SubmodelSystem::load ()
sm->z_offset = entry_node->getDoubleValue("z-offset", 0.0);
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->trigger->setBoolValue(false);
sm->timer = 0.0;
sm->timer = sm->delay;
char name[80];
snprintf(name, 80, "/systems/submodels/submodel[%d]/count", i);

View file

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