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