Flight Model

Eggheads talking about bytes and stuff.
Post Reply
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

I’m having a look at the flight model again, looking at my old IDA database and stuff.

I found that TFXplorer does not properly model the drag increase with extended gear. To enable this, the function computeAerodynamicForceZ_604640() needs a fix in the last condition:

if(isOnGround()) {
if(isGearDown()) {
    xxx += dbl_DA9C31;
}


… where dbl_DA9C31 is obvisously the increase in drag coefficient for extended gear. It defaults to 0.02, which seems a little low. xxx is the accumulated drag coefficient for the entire plane.

More to follow.
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

A few weeks ago, I had the idea that the flight model may not actually be limited to the F-22.

If we look, for example, at the engine descriptions:

    EngineStuffA engines[4]; // left / right / unused / unused

This makes it pretty clear that they planned to use the flight model for other kinds of planes, too – airliners, obviously. But another thing that comes to mind is the Eurofighter Typhoon from EF2000.

I find lots of general settings in the flight model, like e.g. positions of ailerons and rudder. These can easily be changed to match any plane model we like. I’m not far in analyzing the autopilot, but from my impression, it should adjust automatically! See e.g. inAir_updateElevatorAngle_602314().

The one large problem I see is the lookup tables, i.e. aeroLookup9_* in our file. These are hand-suited to the F-22’s drag/lift coefficients, and any other plane should have its own tables. I’ll scrape the EXEs of both TAW and EF2000 for large lists of double-precision floating-point numbers …
mikew
Data Genius
Posts: 242

Post by mikew »

Are the tables commented by IDA to help us guess what each entry does?
I assume these tables are all in the source as we've never found anything flight model related in the extracted files.
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

Right, they are not in the extracted files – they are hard-coded into the EXE. I can only see their addresses and content, but no comments …
mikew
Data Genius
Posts: 242

Post by mikew »

Ah not even text, just a block of binary data put into a specific place by the build system?
I'm sure you can inspect the disassembled code to find out which data is used in a particular calculations, but sounds like a lot of work. :(
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

A typical 2D lookup table may look like this:

Code: Select all

double const aeroLookup6_x[] = { 0.0, 0.2, 0.4, 0.6, 0.8, 0.95 };
double const aeroLookup6_y[] = { 2, 10 };
double const aeroLookup6_s[] = {
	1.0, 1.005, 1.01, 1.02, 1.035, 1.06,
	1.0, 1.015, 1.06, 1.145, 1.325, 1.64
};
Lookup2D const aeroLookup6 = { // @0072F228
	6, 2,
	aeroLookup6_x, aeroLookup6_y,
	aeroLookup6_s
};
The first array defines the samples on the X axis; the other the samples on the Y axis. The third array is the actual 6×2 values at the sample positions.

In this specific example, the X axis may be the Mach Number and Y may be Angle of Attack or something else.

What I’m trying to say: If you look at the values, they are very regular and you’ll find numbers like 0.2, 0.4, … more often than usual. I will just search for the double-precision floating-point values of 0.2, 0.4, 0.5 and if there are more than three hits in a specific place of the executable, I’ll most likely have found the tables.
mikew
Data Genius
Posts: 242

Post by mikew »

Ah, I remember now. It must be over 5 years since we reversed the F22 flight model of TAW and I've just stopped having nightmares about it. Are you suggesting we do the same for EF2000 V2.0, and incorporate it into TFXplorer?
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

mikew wrote: 2022-Feb-13, 20:51Are you suggesting we do the same for EF2000 V2.0, and incorporate it into TFXplorer?
Not decompile it in the same way, ever again! I’d just try to find these data tables and insert them into TAW’s flight model, then change the generic parameters (mass, position of control surfaces, thrust, …) to match EF2000’s and see what happens.

If it works, we get the EF2000 “for free” and should use it. If not, decompiling it can wait another five or ten years 🙂
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

A bug in updateVelocities_6053E0():

VectorXYZ var_28_2 = {
  velocity.x - timeStep * 0.5 * acceleration.x,
  velocity.y - timeStep * 0.5 * acceleration.xy,
  velocity.z - timeStep * 0.5 * acceleration.xz
};


It’s weird that this doesn’t blow up in ADF/TAW’s face. It’s obviously wrong …

I think TFXplorer doesn’t really use this value, though, because velocity is updated in the engine core. But it may corrupt the flight control’s impression of the world.
mikew
Data Genius
Posts: 242

Post by mikew »

There's also the diagnostic system which seems to use its own variables.
...but maybe it works better that way. :)
Scorpion82
Posts: 9

Post by Scorpion82 »

Albeit time constraints held me back, I have been working on a EF2000 Flight Model for Falcon 4.0 for many years. If I get a look at the structure of the FM code you use, I might take a look at it, when time permits. What FMs are used by other planes, all F-22 for the time being?
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

This would be great! You can find the F-22’s flight model here: https://krishty.com/taw/f-22-flight-model.hpp

It basically simulates wings and control surfaces according to some aerodynamic formulas; PID controllers rotate the plane to the required orientation. This is a bit different from the real F-22 (which steers mostly by controlling its center of gravity relative to its center of lift), but it’s good enough for us.

EF2000 (the game) uses a different flight model, and it appears that it has been developed by a completely different person even. Hence our problems reverse engineering it – we basically need to start at zero.
Scorpion82
Posts: 9

Post by Scorpion82 »

Which is not too problematic as the FM in EF2000 isn't too realistic anyway. I wonder whether the FM used for the EF2000 in TAW itself is possibly accessible? Or maybe even that in Eurofighter Typhoon
User avatar
Krishty
Site Admin
Posts: 455

Post by Krishty »

Oh right, I forgot to answer that question.

All non-F-22 planes are simulated with a very coarse system. No individual wings/control surfaces considered etc., just rough aerodynamics like min/max lift coefficient and drag coefficient for the entire plane; turn rate at sea level. Very arcade-ish, but enough for non-player planes.
Scorpion82
Posts: 9

Post by Scorpion82 »

Understood, thank you. So some work on player flyable aircraft is definitely required.
Post Reply