]> git.mxchange.org Git - flightgear.git/blob - src/FDM/YASim/Hitch.hpp
FGPUIDialog: fix reading from already free'd memory.
[flightgear.git] / src / FDM / YASim / Hitch.hpp
1 #ifndef _HITCH_HPP
2 #define _HITCH_HPP
3
4 #include <string>
5
6 #include <Main/fg_props.hxx>
7 #include <simgear/props/tiedpropertylist.hxx>
8
9 namespace yasim {
10
11 class Ground;
12 class RigidBody;
13 struct State;
14
15 class Hitch {
16 public:
17     Hitch(const char *name);
18     ~Hitch();
19
20     // Externally set values
21     void setPosition(float* position);
22     void setOpen(bool isOpen);
23     //void setName(const char *text);
24
25     void setTowLength(float length);
26     void setTowElasticConstant(float sc);
27     void setTowBreakForce(float bf);
28     void setTowWeightPerM(float rw);
29     void setWinchMaxSpeed(float mws);
30     void setWinchRelSpeed(float rws);
31     void setWinchPosition(double *winchPosition); //in global coordinates!
32     void setWinchPositionAuto(bool doit);
33     void findBestAIObject(bool doit,bool running_as_autoconnect=false);
34     void setWinchInitialTowLength(float length);
35     void setWinchPower(float power);
36     void setWinchMaxForce(float force);
37     void setWinchMaxTowLength(float length);
38     void setWinchMinTowLength(float length);
39     void setMpAutoConnectPeriod(float dt);
40     void setForceIsCalculatedByOther(bool b);
41     
42     void setGlobalGround(double *global_ground, float *global_vel);
43
44     void getPosition(float* out);
45     float getTowLength(void);
46
47     void calcForce(Ground *g_cb, RigidBody* body, State* s);
48
49     // Computed values: total force
50     void getForce(float* force, float* off);
51
52     void integrate (float dt);
53
54     std::string getConnectedPropertyNode() const;
55     void setConnectedPropertyNode(const char *nodename);
56
57 private:
58     float _pos[3];
59     bool _open;
60     bool _oldOpen;
61     float _towLength;
62     float _towElasticConstant;
63     float _towBrakeForce;
64     float _towWeightPerM;
65     float _winchMaxSpeed;
66     float _winchRelSpeed;
67     float _winchInitialTowLength;
68     float _winchMaxTowLength;
69     float _winchMinTowLength;
70     float _winchPower;
71     float _winchMaxForce;
72     float _winchActualForce;
73     double _winchPos[3];
74     float _force[3];
75     float _towEndForce[3];
76     float _reportTowEndForce[3];
77     float _forceMagnitude;
78     double _global_ground[4];
79     float _global_vel[3];
80     //char _name[256];
81     State* _state;
82     float _dist;
83     float _timeLagCorrectedDist;
84     SGPropertyNode_ptr _towEndNode;
85     //const char *_towEndPropertyName;
86     bool _towEndIsConnectedToProperty;
87     bool _nodeIsMultiplayer;
88     bool _nodeIsAiAircraft;
89     bool _forceIsCalculatedByMaster;
90     int _nodeID;
91     //const char *_ai_MP_callsign;
92     bool _isSlave;
93     float _mpAutoConnectPeriod;
94     float _timeToNextAutoConnectTry;
95     float _timeToNextReConnectTry;
96     float _height_above_ground;
97     float _winch_height_above_ground;
98     float _loPosFrac;
99     float _lowest_tow_height;
100     float _speed_in_tow_direction;
101     float _mp_time_lag;
102     float _mp_last_reported_dist;
103     float _mp_last_reported_v;
104     float _mp_v;
105     float _mp_dist;
106     float _mp_lpos[3];
107     float _mp_force[3];
108     bool _mp_is_slave;
109     bool _mp_open_last_state;
110
111     bool _displayed_len_lower_dist_message;
112     bool _last_wish;
113
114     SGPropertyNode_ptr _node;
115     simgear::TiedPropertyList _tiedProperties;
116 };
117
118 }; // namespace yasim
119 #endif // _HITCH_HPP