]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Model.hpp
Updated to YASim-0.1.2
[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
28     void iterate();
29
30     // Externally-managed subcomponents
31     int addThruster(Thruster* t);
32     int addSurface(Surface* surf);
33     int addGear(Gear* gear);
34     Surface* getSurface(int handle);
35     Gear* getGear(int handle);
36
37     // Semi-private methods for use by the Airplane solver.
38     int numThrusters();
39     Thruster* getThruster(int handle);
40     void setThruster(int handle, Thruster* t);
41     void initIteration();
42     void getThrust(float* out);
43
44     //
45     // Per-iteration settables
46     //
47     void setGroundPlane(double* planeNormal, double fromOrigin);
48     void setGroundEffect(float* pos, float span, float mul);
49     void setWind(float* wind);
50     void setAir(float pressure, float temp);
51
52     // BodyEnvironment callbacks
53     virtual void calcForces(State* s);
54     virtual void newState(State* s);
55
56 private:
57     void calcGearForce(Gear* g, float* v, float* rot, float* ground);
58     float gearFriction(float wgt, float v, Gear* g);
59     float localGround(State* s, float* out);
60     void localWind(float* pos, State* s, float* out);
61
62     Integrator _integrator;
63     RigidBody _body;
64
65     Vector _thrusters;
66     Vector _surfaces;
67     Vector _gears;
68
69     float _groundEffectSpan;
70     float _groundEffect;
71     float _wingCenter[3];
72
73     double _ground[4];
74     float _pressure;
75     float _temp;
76     float _rho;
77     float _wind[3];
78
79     // Accumulators for the total internal gyro and engine torque
80     float _gyro[3];
81     float _torque[3];
82
83     State* _s;
84 };
85
86 }; // namespace yasim
87 #endif // _MODEL_HPP