This patch only affects aircraft (AI Models) that have no predefined
flightplan. Such aircraft are given some initial conditions that they fly with. They proceed on in "freeflight" mode indefinitely. For example, there is a refueling demo where the tanker starts at 3000', 280 kts, and in a 15 degree bank, and then continues to orbit indefinitely. For these aircraft with no flightplan, I have added several control nodes in controls/flight that allow a script or menu or external application to set heading, altitude, bank angle, and speed. This permits some level of interactive or scripted control over AI aircraft.
This commit is contained in:
parent
c5a7267206
commit
943b7b22a7
2 changed files with 40 additions and 0 deletions
|
@ -184,6 +184,35 @@ void FGAIAircraft::Run(double dt) {
|
|||
}
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
// no flight plan, update target heading, speed, and altitude
|
||||
// from control properties. These default to the initial
|
||||
// settings in the config file, but can be changed "on the
|
||||
// fly".
|
||||
|
||||
string lat_mode = props->getStringValue("controls/flight/lateral-mode");
|
||||
if ( lat_mode == "roll" ) {
|
||||
double angle
|
||||
= props->getDoubleValue("controls/flight/target-roll" );
|
||||
RollTo( angle );
|
||||
} else {
|
||||
double angle
|
||||
= props->getDoubleValue("controls/flight/target-hdg" );
|
||||
TurnTo( angle );
|
||||
}
|
||||
|
||||
string lon_mode
|
||||
= props->getStringValue("controls/flight/longitude-mode");
|
||||
if ( lon_mode == "alt" ) {
|
||||
double alt = props->getDoubleValue("controls/flight/target-alt" );
|
||||
ClimbTo( alt );
|
||||
} else {
|
||||
double angle
|
||||
= props->getDoubleValue("controls/flight/target-pitch" );
|
||||
PitchTo( angle );
|
||||
}
|
||||
|
||||
AccelTo( props->getDoubleValue("controls/flight/target-spd" ) );
|
||||
}
|
||||
|
||||
double turn_radius_ft;
|
||||
|
|
|
@ -223,6 +223,17 @@ void FGAIBase::bind() {
|
|||
props->setBoolValue("controls/lighting/beacon", true);
|
||||
props->setBoolValue("controls/lighting/strobe", true);
|
||||
props->setBoolValue("controls/glide-path", true);
|
||||
|
||||
props->setStringValue("controls/flight/lateral-mode", "roll");
|
||||
props->setDoubleValue("controls/flight/target-hdg", hdg);
|
||||
props->setDoubleValue("controls/flight/target-roll", roll);
|
||||
|
||||
props->setStringValue("controls/flight/longitude-mode", "alt");
|
||||
props->setDoubleValue("controls/flight/target-alt", altitude);
|
||||
props->setDoubleValue("controls/flight/target-pitch", pitch);
|
||||
|
||||
props->setDoubleValue("controls/flight/target-spd", speed);
|
||||
|
||||
}
|
||||
|
||||
void FGAIBase::unbind() {
|
||||
|
|
Loading…
Reference in a new issue