Here’s the issue: Simulating engines is hard. TAW does the bare minimum, and it’s already complex with much room for errors (more on this later). You rather don’t want to re-implement this for every new plane.
So the idea is:
- Let extensions declare engine models, e.g. F199-PW-100 for the F-22. Let them provide properties like maximal thrust, throttle range, etc. Also provide the standard sound effects.
- Extensions, upon spawning a plane, say what engine models the plane uses and where they are located.
- TFXplorer does internally and automatically:
- Thrust computation taking into account altitude and weather.
- Sound effects according to current RPM and afterburner setting.
- Graphics of the exhaust plumes, shock diamonds, etc.
- Computing fuel consumption according to throttle settings.
- Updating the contrails with water vapor from the burnt fuel.
- Providing an IR signature for enemies according to burnt fuel.
- Remove all code doing the above from the F-22 model, and also the KC-135/Aurora models.
- ???
- PROFIT
What could go wrong?
How to compute thrust?
TAW simulates thrust as growing linear with throttle setting, starting with 0 % thrust at 50 % throttle and 100 % thrust at 100 % throttle. This is unrealistic (throst grows exponentially with RPM?), but enough for gameplay.
Altitude is waaaaay more of a problem. TAW uses the following formula to compute thrust with altitude:
Code: Select all
double getSigma(double altitude) {
return eRaisedToPower(altitude * -(altitude * 0.000000001628 + 0.00009503));
}
[…]
auto const n = 0.75;
auto const sigma = getSigma(altitude);
if(altitude < 11'000) {
thrust *= raisedToPower(sigma, n);
} else {
auto const sigma_strat = getSigma(11'000); // at start of stratosphere
thrust *= raisedToPower(sigma_strat, n) * sigma / sigma_strat;
}
I have no sources for that algorithm, and I don’t find the numbers on the internet. I don’t know how realistic it is or how good it will be with other engine models. I only know: If I remove the odd fix for high altitudes, my F-22 can reach Mach 8 at 100.000 ft.
What is RPM, anyway?
The game needs to display turbine RPM on the HUD. So we just take it from the simulation.
Real turbines have two RPMs: N1 is the fan RPM in [0…1] range, and N2 is the RPM of the engine core (also in [0…1] range). Boeing 7x7s display N1, but many jet fighters display N2. Shall we simulate both?
A quick look at ADF/TAW tells us that it simulates neither and just takes an imaginary number to multiply with thrust.
Problem solved, until you reach the next point …
Realistic Sound Needs actual RPM
I’ve heard TAW’s turbine sound for 25 years. I hate it, my wife hates it, my kids hate it.
Nowadays, you don’t take a three-second sound loop and repeat it infinitely with pitch adjusted for throttle. You generate sounds on-the-fly. They never repeat and they can be customized infinitely without having to go out and record anything from a real plane.
For example, Ace Combat uses Turbine:
(More videos here)
If you want to program something like this into the game, you really really want to have correct N1/N2 RPM.
Connecting to FCS
The F-22 needs access to the turbine data for a simple fact: Turbines can never be aligned perfectly with the plane’s center of gravity, and hence their thrust generates torque. The torque must be trimmed out.
So we have to feed the data from the jet engine simulation back into the FCS.
The hardest part is the thrust vectoring control, which uses the nozzle position to estimate the torque that could theoretically be applied.
… and that’s why my weekend project turned out taking two weeks 🙂 I’ll keep doing it, though, because there is another motivation I haven’t mentioned: Rocket engines.
Jet engines need sophisticated code to simulate them, so we should have it in one place and ready to use. Rocket engines don’t need as much sophistication – at least solid-rocket boosters don’t – but they are plentiful. Any missile you want to add to the game? Needs a rocket motor simulation, no matter if guided or unguided. The ejection seat? SAMs? Aren’t flares a kind of rocket motor, too? I don’t want to repeat that code 400 times.
Btw, the sound code has proven to be the most annoying, because it is just stupid boilerplate. Look up RPM, multiply with X, set as pitch for engine sound. Multiply with Y, set as loudness of engine sound. Afterburner on? Set afterburner sound on, else off. Very dull code with lots of repetitions.
Just so you know what I’m up to.