]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Model.hpp
Initial revision of Andy Ross's YASim code. This is (Y)et (A)nother Flight
[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 "util/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     Thruster* getThruster(int handle);
39     void setThruster(int handle, Thruster* t);
40     void initIteration();
41     void getThrust(float* out);
42
43     //
44     // Per-iteration settables
45     //
46     void setGroundPlane(double* planeNormal, double fromOrigin);
47     void setWind(float* wind);
48     void setAirDensity(float rho);
49     void setAir(float pressure, float temp);
50
51     // BodyEnvironment callbacks
52     virtual void calcForces(State* s);
53     virtual void newState(State* s);
54
55 private:
56     void calcGearForce(Gear* g, float* v, float* rot, float* ground);
57     float gearFriction(float wgt, float v, Gear* g);
58     float localGround(State* s, float* out);
59     void localWind(float* pos, State* s, float* out);
60
61     Integrator _integrator;
62     RigidBody _body;
63
64     Vector _thrusters;
65     Vector _surfaces;
66     Vector _gears;
67
68     double _ground[4];
69     float _rho;
70     float _wind[3];
71
72     // Accumulators for the total internal gyro and engine torque
73     float _gyro[3];
74     float _torque[3];
75
76     State* _s;
77 };
78
79 }; // namespace yasim
80 #endif // _MODEL_HPP