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