#ifdef USE_SH_POOLS
public:
// Overload new/delete to
use a SmartHeap fixed size pool
void *operator new(size_t
size) { ShiAssert( size == sizeof(AirframeClass) ); return MemAllocFS(pool);
};
void operator delete(void
*mem) { if (mem) MemFreeFS(mem); };
static void InitializeStorage()
{ pool = MemPoolInitFS( sizeof(AirframeClass), 200, 0 ); };
static void ReleaseStorage()
{ MemPoolFree( pool ); };
static MEM_POOL pool;
#endif
private:
// Airframe/Engine data
AeroData
*aeroData;
EngineData
*engineData;
RollData
*rollCmd;
float
area, fuel, fuelFlow, externalFuel, epuFuel;
float
mass, weight, dragIndex, emptyWeight;
float
gsAvail, maxGs, maxRoll, maxRollDelta, startRoll;
float
minVcas, maxVcas, cornerVcas;
unsigned
int flags;
short
vehicleIndex;
//
A bit of a trick to get ground handling to be smooth at low speed
float
groundAnchorX, groundAnchorY;
float
groundDeltaX, groundDeltaY;
//
Aerodynamics
float
clift0, clalph0;
//float
cdalpha;
float
cnalpha, clalpha;
float
aoabias;
float
cl,cd,cy, clalph;
float
aoamax, aoamin;
float
betmax, betmin;
//
Thrust Dynamics
float
thrtab;
float
thrust;
float
athrev, anozl, ethrst;
//
Autopilot
float
forcedHeading, forcedSpeed;
//
Accelerometers
float
nxcgs, nycgs, nzcgs;
float
nxcgw, nycgw, nzcgw;
//
Filter Arrays
//SAVE_ARRAY
olde1, olde2, olde3, olde4;
//SAVE_ARRAY
oldvt, oldx, oldy, oldz;
SAVE_ARRAY
oldp01, oldp02, oldp03, oldp04, oldp05;
SAVE_ARRAY
oldr01;
//SAVE_ARRAY
oldy02, oldy04;
SAVE_ARRAY
oldy01, oldy03, olda01;
//SAVE_ARRAY
ptrimArray, rtrimArray, ytrimArray;
SAVE_ARRAY
oldRpm;
//
Normalization Params
float
qbar, qsom, qovt;
//
Control Inputs
//float
ptrim, rtrim, ytrim;
float
pshape, rshape, yshape;
float
pstab, rstab;
float
plsdamp, rlsdamp, ylsdamp;
//control
history
//float
rshape1, rshape2;
//float
pshape1, pshape2;
//float
yshape1, yshape2;
float
rshape1;
float
pshape1;
float
yshape1;
float
avgPdelta, avgRdelta , avgYdelta;
//stalls
float
oscillationTimer;
float
oscillationSlope;
float
oldnzcgs;
//
Accelerations
float
xaero, yaero, zaero;
float
xsaero, ysaero, zsaero;
float
xwaero, ywaero, zwaero;
float
xprop, yprop, zprop;
float
xsprop, ysprop, zsprop;
float
xwprop, ywprop, zwprop;
//
Current interpolation breakpoints
int
curMachBreak, curAlphaBreak;
int
curRollAlphaBreak, curRollQbarBreak;
int
curEngMachBreak, curEngAltBreak;
//
Simple flight model
int
simpleMode; // 0 = no
// Functions
int ReadData(int idx);
void SuperSimpleFCS (void);
void SuperSimpleEngine (void);
void Accelerometers (void);
void Aerodynamics (void);
void AeroRead(int);
void Atmosphere(void);
void Axial(float dt);
void EngineRead(int);
void CalcBodyRates(float
dt);
void EquationsOfMotion(float
dt);
void FcsRead(int);
void FlightControlSystem(void);
void Gains(void);
void Initialize (void);
void InitializeEOM (void);
void ReInitialize(void);
void OpenFiles(void);
void Pitch(void);
void ReadData(float *);
void Roll(void);
void Trigenometry(void);
void TrimModel(void);
void Yaw(void);
float CalcMach (float kias,
float pressRatio);
float CalcPressureRatio(float
alt, float* ttheta, float* rsigma);
float Predictor(float x1,
float x2, float y1, float y2);
void SetStallConditions(void);
void ResetIntegrators(void);
float CalculateVt(float
dt);
void SetGroundPosition(float
dt, float netAccel, float gndGmma, float relMu);
void CalculateGroundPlane(float
*gndGmma, float *relMu);
void CalcGroundTurnRate(float
dt);
public:
void EngineModel(float dt);
/*------------------------*/
/* Command mode constants
*/
/*------------------------*/
enum
{
IsDigital = 0x1,
InAir = 0x2,
Trimming = 0x4,
WheelBrakes = 0x8,
Refueling = 0x10,
AOACmdMode = 0x20,
AutoCommand = 0x40,
GCommand = 0x80,
ErrorCommand = 0x100,
GroundCommand = 0x200,
AlphaCommand = 0x400,
GearBroken = 0x800,
Planted = 0x1000,
Simplified = 0x2000,
NoFuelBurn = 0x4000,
EngineOff = 0x8000,
ThrottleCheck = 0x10000,
SuperSimple = 0x20000,
MPOverride = 0x40000,
LowSpdHorn = 0x80000,
HornSilenced = 0x100000,
CATLimiterIII = 0x200000,
NoseSteerOn = 0x400000,
OverRunway = 0x800000,
HasComplexGear= 0x1000000,
GearDamaged = 0x2000000,
OverAirStrip = 0x4000000,
};
enum StallMode
{
None,
Crashing,
Recovering,
EnteringDeepStall,
DeepStall,
Spinning,
FlatSpin
};
// State data
AircraftClass*
platform;
float
e1, e2, e3, e4;
float
x, y, z;
float
vt, vcas, rho;
float
p, q, r;
float
mach, vRot;
float
alpha, beta;
float
theta, phi, psi;
float
gmma, sigma, mu;
float
nxcgb, nycgb, nzcgb;
float
xdot, ydot, zdot, vtDot;
float
rpm;
//float
limiterAssault;
float
stallMagnitude;
float
desiredMagnitude;
float
loadingFraction;
float
assymetry;
float
tefFactor;
float
lefFactor;
float
curMaxGs;
StallMode
stallMode;
GearData
*gear;
int groundType;
float
grndphi, grndthe, groundZ;
float
bumpphi, bumpthe, bumpyaw;
Tpoint
gndNormal;
//
Geometry Stuff
//float
alpdot;
float
betdot;
float
slice;
float
pitch;
//
Initialization Data
float
initialX;
float
initialY;
float
initialZ;
float
initialMach;
float
initialPsi;
float
initialFuel;
//
Flight Control System Gains
float
tp01, tp02, tp03, tp04;
float
zp01, zp02;
float
kp01, kp02, kp03, kp04, kp05, kp06;
float
wp01, wp02;
int
jp01, jp02;
float
tr01;
float
zr01;
float
kr01, kr02, kr03, kr04;
float
wr01;
float
ty01, ty02, ty03;
float
zy01, zy02;
float
ky01, ky02, ky03, ky04, ky05, ky06;
float
wy01, wy02;
int
jy01, jy02;
float
zpdamp;
//
Pilot Commands
float
pstick, rstick, ypedal, throtl, pwrlev;
//float
ptrmcmd, rtrmcmd, ytrmcmd;
float
dbrake, gearPos, gearHandle, speedBrake;
// Functions
AirframeClass (AircraftClass*
self);
~AirframeClass (void);
void Init (int idx);
void Reinit (void);
void Exec(void);
void RemoteUpdate(void);
void ResetOrientation(void);
void CalcBodyOrientation(float
dt);
void YawIt(float betcmd,
float dt);
void PitchIt(float aoacmd,
float dt);
void RollIt(float pscmd,
float dt);
float CheckHeight(void);
void CheckGroundImpact(float
dt);
float GetOptimumCruise(void);
float GetOptimumAltitude(void);
float CalcThrotlPos(float
speed);
float CalcMuFric(int
groundType);
float CalcDesAlpha(float
desGs);
float CalcDesSpeed(float
desAlpha);
void
SetPStick (float newStick) {pstick = newStick;};
void
SetRStick (float newStick) {rstick = newStick;};
void
SetYPedal (float newPedal) {ypedal = newPedal;};
void
SetThrotl (float newThrot) {throtl = newThrot;};
float
PStick (void) {return pstick;};
float
RStick (void) {return rstick;};
float
YPedal (void) {return ypedal;};
float
Throtl (void) {return throtl;};
float
Mass (void)
{return mass;}
float
MaxRoll (void) {return maxRoll * RTD;};
void
SetMaxRoll (float newRoll) {maxRoll = newRoll * DTR;};
void
SetMaxRollDelta (float newRoll) {maxRollDelta = newRoll * DTR; startRoll
= 0.0F;};
void ReSetMaxRoll (void);
float
MaxGs (void) {return maxGs;};
float
MinVcas(void) {return minVcas;}
float
MaxVcas(void) {return maxVcas;}
float CalcTASfromCAS(float
cas);
float
CornerVcas(void) {return cornerVcas;}
float
GsAvail (void) {return gsAvail;};
float SustainedGs (int maxAB);
float PsubS (int maxAB);
float FuelBurn (int maxAB);
float
Fuel (void) {return fuel;};
float
ExternalFuel (void) {return externalFuel;};
void AddExternalFuel (float lbs);
int AddFuel (float
lbs); //this checks whether we're full
float
EPUFuel (void) {return epuFuel;};
float
FuelFlow (void) {return fuelFlow;};
float VtDot(void) {return vtDot;};
float
WingArea (void) {return area;};
int
VehicleIndex(void) {return vehicleIndex;}
void AddWeapon(float weight,float dragIndex, float offset);
void RemoveWeapon(float
Weight, float DragIndex, float offset);
void
SetForcedConditions (float newSpeed, float newHeading) {forcedSpeed = newSpeed;
forcedHeading = newHeading;};
float
Qsom(void) {return qsom;}
float
Cnalpha(void) {return cnalpha;}
int
NumGear(void) {return FloatToInt32(aeroDataset[vehicleIndex].inputData[AeroDataSet::NumGear]);}
float
GetAeroData(int which) {return aeroDataset[vehicleIndex].inputData[which];}
void DragBodypart(void);
void
SetDragIndex(float index) {dragIndex = index;};
float
GetDragIndex(void) {return dragIndex;};
void ResetAlpha(void);
void
SetFlag (int newFlag) {flags |= newFlag;};
void
ClearFlag (int newFlag) {flags &= ~newFlag;};
int
IsSet (int testFlag) {return flags & testFlag ? 1 : 0;};
// KCK added function - this is really only needed temporarily
void SetPosition (float
x, float y, float z);
void ResetFuel (void);
// simple flight mode stuff....
void SimpleModel( void );
void SetSimpleMode( int
);
int
GetSimpleMode(void) {return simpleMode;};
#define SIMPLE_MODE_OFF 0
#define SIMPLE_MODE_AF 1
#define SIMPLE_MODE_HF 2
// easter egg -- helicopter
flight model.....
void RunHeliModel(void);
HeliMMClass *hf;