]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Model.hpp
First cut at a turbulence model for YASim. It's a
[flightgear.git] / src / FDM / YASim / Model.hpp
1 #ifndef _MODEL_HPP
2 #define _MODEL_HPP
3
4 #include "Integrator.hpp"
5 #include "RigidBody.hpp"
6 #include "BodyEnvironment.hpp"
7 #include "Vector.hpp"
8 #include "Turbulence.hpp"
9
10 namespace yasim {
11
12 // Declare the types whose pointers get passed around here
13 class Integrator;
14 class Thruster;
15 class Surface;
16 class Rotorpart;
17 class Rotorblade;
18 class Rotor;
19 class Gear;
20
21 class Model : public BodyEnvironment {
22 public:
23     Model();
24     virtual ~Model();
25
26     RigidBody* getBody();
27     Integrator* getIntegrator();
28
29     void setTurbulence(Turbulence* turb) { _turb = turb; }
30
31     State* getState();
32     void setState(State* s);
33
34     bool isCrashed();
35     void setCrashed(bool crashed);
36     float getAGL();
37
38     void iterate();
39
40     // Externally-managed subcomponents
41     int addThruster(Thruster* t);
42     int addSurface(Surface* surf);
43     int addRotorpart(Rotorpart* rpart);
44     int addRotorblade(Rotorblade* rblade);
45     int addRotor(Rotor* rotor);
46     int addGear(Gear* gear);
47     Surface* getSurface(int handle);
48     Rotorpart* getRotorpart(int handle);
49     Rotorblade* getRotorblade(int handle);
50     Rotor* getRotor(int handle);
51     Gear* getGear(int handle);
52
53     // Semi-private methods for use by the Airplane solver.
54     int numThrusters();
55     Thruster* getThruster(int handle);
56     void setThruster(int handle, Thruster* t);
57     void initIteration();
58     void getThrust(float* out);
59
60     //
61     // Per-iteration settables
62     //
63     void setGroundPlane(double* planeNormal, double fromOrigin);
64     void setGroundEffect(float* pos, float span, float mul);
65     void setWind(float* wind);
66     void setAir(float pressure, float temp, float density);
67
68     // BodyEnvironment callbacks
69     virtual void calcForces(State* s);
70     virtual void newState(State* s);
71
72 private:
73     void initRotorIteration();
74     void calcGearForce(Gear* g, float* v, float* rot, float* ground);
75     float gearFriction(float wgt, float v, Gear* g);
76     float localGround(State* s, float* out);
77     void localWind(float* pos, State* s, float* out);
78
79     Integrator _integrator;
80     RigidBody _body;
81
82     Turbulence* _turb;
83
84     Vector _thrusters;
85     Vector _surfaces;
86     Vector _rotorparts;
87     Vector _rotorblades;
88     Vector _rotors;
89     Vector _gears;
90
91     float _groundEffectSpan;
92     float _groundEffect;
93     float _wingCenter[3];
94
95     double _ground[4];
96     float _pressure;
97     float _temp;
98     float _rho;
99     float _wind[3];
100
101     // Accumulators for the total internal gyro and engine torque
102     float _gyro[3];
103     float _torque[3];
104
105     State* _s;
106     bool _crashed;
107     float _agl;
108 };
109
110 }; // namespace yasim
111 #endif // _MODEL_HPP