]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Model.hpp
Updates to the controls properties tree. This is a major update so there may be one...
[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
9 namespace yasim {
10
11 // Declare the types whose pointers get passed around here
12 class Integrator;
13 class Thruster;
14 class Surface;
15 class Gear;
16
17 class Model : public BodyEnvironment {
18 public:
19     Model();
20     virtual ~Model();
21
22     RigidBody* getBody();
23     Integrator* getIntegrator();
24
25     State* getState();
26     void setState(State* s);
27     bool isCrashed();
28     void setCrashed(bool crashed);
29     float getAGL();
30
31     void iterate();
32
33     // Externally-managed subcomponents
34     int addThruster(Thruster* t);
35     int addSurface(Surface* surf);
36     int addGear(Gear* gear);
37     Surface* getSurface(int handle);
38     Gear* getGear(int handle);
39
40     // Semi-private methods for use by the Airplane solver.
41     int numThrusters();
42     Thruster* getThruster(int handle);
43     void setThruster(int handle, Thruster* t);
44     void initIteration();
45     void getThrust(float* out);
46
47     //
48     // Per-iteration settables
49     //
50     void setGroundPlane(double* planeNormal, double fromOrigin);
51     void setGroundEffect(float* pos, float span, float mul);
52     void setWind(float* wind);
53     void setAir(float pressure, float temp, float density);
54
55     // BodyEnvironment callbacks
56     virtual void calcForces(State* s);
57     virtual void newState(State* s);
58
59 private:
60     void calcGearForce(Gear* g, float* v, float* rot, float* ground);
61     float gearFriction(float wgt, float v, Gear* g);
62     float localGround(State* s, float* out);
63     void localWind(float* pos, State* s, float* out);
64
65     Integrator _integrator;
66     RigidBody _body;
67
68     Vector _thrusters;
69     Vector _surfaces;
70     Vector _gears;
71
72     float _groundEffectSpan;
73     float _groundEffect;
74     float _wingCenter[3];
75
76     double _ground[4];
77     float _pressure;
78     float _temp;
79     float _rho;
80     float _wind[3];
81
82     // Accumulators for the total internal gyro and engine torque
83     float _gyro[3];
84     float _torque[3];
85
86     State* _s;
87     bool _crashed;
88     float _agl;
89 };
90
91 }; // namespace yasim
92 #endif // _MODEL_HPP