]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Model.hpp
Port over remaining Point3D usage to the more type and unit safe SG* classes.
[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 #include "Rotor.hpp"
10
11 namespace yasim {
12
13 // Declare the types whose pointers get passed around here
14 class Integrator;
15 class Thruster;
16 class Surface;
17 class Rotorpart;
18 class Gear;
19 class Ground;
20 class Hook;
21 class Launchbar;
22 class Hitch;
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 addGear(Gear* gear);
47     void addHook(Hook* hook);
48     void addLaunchbar(Launchbar* launchbar);
49     Surface* getSurface(int handle);
50     Rotorgear* getRotorgear(void);
51     Gear* getGear(int handle);
52     Hook* getHook(void);
53     int addHitch(Hitch* hitch);
54     Launchbar* getLaunchbar(void);
55
56     // Semi-private methods for use by the Airplane solver.
57     int numThrusters();
58     Thruster* getThruster(int handle);
59     void setThruster(int handle, Thruster* t);
60     void initIteration();
61     void getThrust(float* out);
62
63     void setGroundCallback(Ground* ground_cb);
64     Ground* getGroundCallback(void);
65
66     //
67     // Per-iteration settables
68     //
69     void setGroundEffect(float* pos, float span, float mul);
70     void setWind(float* wind);
71     void setAir(float pressure, float temp, float density);
72
73     void updateGround(State* s);
74
75     // BodyEnvironment callbacks
76     virtual void calcForces(State* s);
77     virtual void newState(State* s);
78
79 private:
80     void initRotorIteration();
81     void calcGearForce(Gear* g, float* v, float* rot, float* ground);
82     float gearFriction(float wgt, float v, Gear* g);
83     void localWind(float* pos, State* s, float* out, float alt,
84         bool is_rotor = false);
85
86     Integrator _integrator;
87     RigidBody _body;
88
89     Turbulence* _turb;
90
91     Vector _thrusters;
92     Vector _surfaces;
93     Rotorgear _rotorgear;
94     Vector _gears;
95     Hook* _hook;
96     Launchbar* _launchbar;
97     Vector _hitches;
98
99     float _groundEffectSpan;
100     float _groundEffect;
101     float _wingCenter[3];
102
103     Ground* _ground_cb;
104     double _global_ground[4];
105     float _pressure;
106     float _temp;
107     float _rho;
108     float _wind[3];
109
110     // Accumulators for the total internal gyro and engine torque
111     float _gyro[3];
112     float _torque[3];
113
114     State* _s;
115     bool _crashed;
116     float _agl;
117 };
118
119 }; // namespace yasim
120 #endif // _MODEL_HPP