]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Model.hpp
When we are asked to produce no force on a Surface (e.g. a weight that
[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 class Ground;
21 class Hook;
22 class Launchbar;
23
24 class Model : public BodyEnvironment {
25 public:
26     Model();
27     virtual ~Model();
28
29     RigidBody* getBody();
30     Integrator* getIntegrator();
31
32     void setTurbulence(Turbulence* turb) { _turb = turb; }
33
34     State* getState();
35     void setState(State* s);
36
37     bool isCrashed();
38     void setCrashed(bool crashed);
39     float getAGL();
40
41     void iterate();
42
43     // Externally-managed subcomponents
44     int addThruster(Thruster* t);
45     int addSurface(Surface* surf);
46     int addRotorpart(Rotorpart* rpart);
47     int addRotorblade(Rotorblade* rblade);
48     int addRotor(Rotor* rotor);
49     int addGear(Gear* gear);
50     void addHook(Hook* hook);
51     void addLaunchbar(Launchbar* launchbar);
52     Surface* getSurface(int handle);
53     Rotorpart* getRotorpart(int handle);
54     Rotorblade* getRotorblade(int handle);
55     Rotor* getRotor(int handle);
56     Gear* getGear(int handle);
57     Hook* getHook(void);
58     Launchbar* getLaunchbar(void);
59
60     // Semi-private methods for use by the Airplane solver.
61     int numThrusters();
62     Thruster* getThruster(int handle);
63     void setThruster(int handle, Thruster* t);
64     void initIteration();
65     void getThrust(float* out);
66
67     void setGroundCallback(Ground* ground_cb);
68     Ground* getGroundCallback(void);
69
70     //
71     // Per-iteration settables
72     //
73     void setGroundEffect(float* pos, float span, float mul);
74     void setWind(float* wind);
75     void setAir(float pressure, float temp, float density);
76
77     void updateGround(State* s);
78
79     // BodyEnvironment callbacks
80     virtual void calcForces(State* s);
81     virtual void newState(State* s);
82
83 private:
84     void initRotorIteration();
85     void calcGearForce(Gear* g, float* v, float* rot, float* ground);
86     float gearFriction(float wgt, float v, Gear* g);
87     void localWind(float* pos, State* s, float* out, float alt);
88
89     Integrator _integrator;
90     RigidBody _body;
91
92     Turbulence* _turb;
93
94     Vector _thrusters;
95     Vector _surfaces;
96     Vector _rotorparts;
97     Vector _rotorblades;
98     Vector _rotors;
99     Vector _gears;
100     Hook* _hook;
101     Launchbar* _launchbar;
102
103     float _groundEffectSpan;
104     float _groundEffect;
105     float _wingCenter[3];
106
107     Ground* _ground_cb;
108     double _global_ground[4];
109     float _pressure;
110     float _temp;
111     float _rho;
112     float _wind[3];
113
114     // Accumulators for the total internal gyro and engine torque
115     float _gyro[3];
116     float _torque[3];
117
118     State* _s;
119     bool _crashed;
120     float _agl;
121 };
122
123 }; // namespace yasim
124 #endif // _MODEL_HPP