]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIBallistic.hxx
ca92b8b8921b654b769836c7d5b63e0ce2513ad0
[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
72
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 private:
79
80     double _azimuth;         // degrees true
81     double _elevation;       // degrees
82     double _rotation;        // degrees
83     bool   _aero_stabilised; // if true, object will align with trajectory
84     double _drag_area;       // equivalent drag area in ft2
85     double _life_timer;      // seconds
86     double _gravity;         // fps2
87     double _buoyancy;        // fps2
88     double _wind_from_east;  // fps
89     double _wind_from_north; // fps
90     bool   _wind;            // if true, local wind will be applied to object
91     double _Cd;              // drag coefficient
92     double _mass;            // slugs
93     bool   _random;          // modifier for Cd
94     double _ht_agl_ft;       // height above ground level
95     double _load_resistance; // ground load resistanc N/m^2
96     bool   _solid;           // if true ground is solid for FDMs
97
98     bool   _report_collision;       // if true a collision point with AI Objects is calculated
99     bool   _report_impact;          // if true an impact point on the terrain is calculated
100
101     SGPropertyNode_ptr _impact_report_node;  // report node for impact and collision
102
103     double _fuse_range;
104
105     double _dt_count;
106     double _next_run;
107
108     string _name;
109     string _path;
110     string _submodel;
111
112     void Run(double dt);
113     void handle_collision();
114     void handle_impact();
115
116     void report_impact(double elevation, const FGAIBase *target = 0);
117
118 };
119
120 #endif  // _FG_AIBALLISTIC_HXX