]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIBallistic.hxx
abfa68582a206e147ec47df17f79d7754cc91671
[flightgear.git] / src / AIModel / AIBallistic.hxx
1 // FGAIBallistic.hxx - AIBase derived class creates an AI ballistic object
2 //
3 // Written by David Culp, started November 2003.
4 // - davidculp2@comcast.net
5 //
6 // This program is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU General Public License as
8 // published by the Free Software Foundation; either version 2 of the
9 // License, or (at your option) any later version.
10 //
11 // This program is distributed in the hope that it will be useful, but
12 // WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 // General Public License for more details.
15 //
16 // You should have received a copy of the GNU General Public License
17 // along with this program; if not, write to the Free Software
18 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
19
20 #ifndef _FG_AIBALLISTIC_HXX
21 #define _FG_AIBALLISTIC_HXX
22
23 #include <math.h>
24 #include <vector>
25 #include <simgear/structure/SGSharedPtr.hxx>
26
27
28 #include "AIManager.hxx"
29 #include "AIBase.hxx"
30
31 SG_USING_STD(vector);
32 SG_USING_STD(list);
33
34 class FGAIBallistic : public FGAIBase {
35
36 public:
37
38     FGAIBallistic();
39     ~FGAIBallistic();
40
41     void readFromScenario(SGPropertyNode* scFileNode);
42
43     bool init(bool search_in_AI_path=false);
44     virtual void bind();
45     virtual void unbind();
46
47     void update(double dt);
48
49     void setAzimuth( double az );
50     void setElevation( double el );
51     void setRoll( double rl );
52     void setStabilisation( bool val );
53     void setDragArea( double a );
54     void setLife( double seconds );
55     void setBuoyancy( double fpss );
56     void setWind_from_east( double fps );
57     void setWind_from_north( double fps );
58     void setWind( bool val );
59     void setCd( double c );
60     void setMass( double m );
61     void setNoRoll( bool nr );
62     void setRandom( bool r );
63     void setName(const string&);
64     void setCollision(bool c);
65     void setImpact(bool i);
66     void setImpactReportNode(const string&);
67     void setFuseRange(double f);
68     void setSMPath(const string&);
69     void setSubID(int i);
70     void setSubmodel(const string&);
71     void setExternalForce( bool f );
72     void setForcePath(const string&);
73     double _getTime() const;
74
75     virtual const char* getTypeString(void) const { return "ballistic"; }
76     static const double slugs_to_kgs; //conversion factor
77
78     SGPropertyNode_ptr _force_node;
79     SGPropertyNode_ptr _force_azimuth_node;
80     SGPropertyNode_ptr _force_elevation_node;
81
82 private:
83
84     double _azimuth;         // degrees true
85     double _elevation;       // degrees
86     double _rotation;        // degrees
87     bool   _aero_stabilised; // if true, object will align with trajectory
88     double _drag_area;       // equivalent drag area in ft2
89     double _life_timer;      // seconds
90     double _gravity;         // fps2
91     double _buoyancy;        // fps2
92     double _wind_from_east;  // fps
93     double _wind_from_north; // fps
94     bool   _wind;            // if true, local wind will be applied to object
95     double _Cd;              // drag coefficient
96     double _mass;            // slugs
97     bool   _random;          // modifier for Cd
98     double _ht_agl_ft;       // height above ground level
99     double _load_resistance; // ground load resistanc N/m^2
100     bool   _solid;           // if true ground is solid for FDMs
101     //double _hs_force_fps;    // horizontal speed due to external force
102
103     bool   _report_collision;       // if true a collision point with AI Objects is calculated
104     bool   _report_impact;          // if true an impact point on the terrain is calculated
105     bool   _external_force;         // if true then apply external force
106
107     SGPropertyNode_ptr _impact_report_node;  // report node for impact and collision
108
109     double _fuse_range;
110
111     double _dt_count;
112     double _next_run;
113
114     string _name;
115     string _path;
116     string _submodel;
117     string _force_path;
118
119     void Run(double dt);
120     void handle_collision();
121     void handle_impact();
122
123     void report_impact(double elevation, const FGAIBase *target = 0);
124
125 };
126
127 #endif  // _FG_AIBALLISTIC_HXX