]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIBallistic.hxx
Clear chat messages when an aircraft becomes inactive in the property tree.
[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 #include <simgear/scene/material/mat.hxx>
27
28
29 #include "AIManager.hxx"
30 #include "AIBase.hxx"
31
32 SG_USING_STD(vector);
33 SG_USING_STD(list);
34
35 class FGAIBallistic : public FGAIBase {
36
37 public:
38
39     FGAIBallistic();
40     ~FGAIBallistic();
41
42     void readFromScenario(SGPropertyNode* scFileNode);
43
44     bool init(bool search_in_AI_path=false);
45     virtual void bind();
46     virtual void unbind();
47
48     void update(double dt);
49
50     void setAzimuth( double az );
51     void setElevation( double el );
52     void setRoll( double rl );
53     void setStabilisation( bool val );
54     void setDragArea( double a );
55     void setLife( double seconds );
56     void setBuoyancy( double fpss );
57     void setWind_from_east( double fps );
58     void setWind_from_north( double fps );
59     void setWind( bool val );
60     void setCd( double c );
61     void setMass( double m );
62     void setNoRoll( bool nr );
63     void setRandom( bool r );
64     void setName(const string&);
65     void setCollision(bool c);
66     void setImpact(bool i);
67     void setImpactReportNode(const string&);
68     void setFuseRange(double f);
69     void setSMPath(const string&);
70     void setSubID(int i);
71     void setSubmodel(const string&);
72     void setExternalForce( bool f );
73     void setForcePath(const string&);
74     double _getTime() const;
75     bool getHtAGL();
76     void setForceStabilisation( bool val );
77     void setXOffset(double x);
78     void setYOffset(double y);
79     void setZOffset(double z);
80
81
82     virtual const char* getTypeString(void) const { return "ballistic"; }
83     static const double slugs_to_kgs; //conversion factor
84     static const double slugs_to_lbs; //conversion factor
85
86     SGPropertyNode_ptr _force_node;
87     SGPropertyNode_ptr _force_azimuth_node;
88     SGPropertyNode_ptr _force_elevation_node;
89
90 private:
91
92     double _azimuth;         // degrees true
93     double _elevation;       // degrees
94     double _rotation;        // degrees
95     bool   _aero_stabilised; // if true, object will align with trajectory
96     double _drag_area;       // equivalent drag area in ft2
97     double _life_timer;      // seconds
98     double _gravity;         // fps2
99     double _buoyancy;        // fps2
100     double _wind_from_east;  // fps
101     double _wind_from_north; // fps
102     bool   _wind;            // if true, local wind will be applied to object
103     double _Cd;              // drag coefficient
104     double _mass;            // slugs
105     bool   _random;          // modifier for Cd
106     double _ht_agl_ft;       // height above ground level
107     double _load_resistance; // ground load resistanc N/m^2
108     double _frictionFactor;  // dimensionless modifier for Coefficient of Friction
109     bool   _solid;           // if true ground is solid for FDMs
110     double _elevation_m;     // ground elevation in meters
111     bool   _force_stabilised;// if true, object will align to external force
112     double _x_offset;
113     double _y_offset;
114     double _z_offset;
115
116     bool   _report_collision;       // if true a collision point with AI Objects is calculated
117     bool   _report_impact;          // if true an impact point on the terrain is calculated
118     bool   _external_force;         // if true then apply external force
119
120     SGPropertyNode_ptr _impact_report_node;  // report node for impact and collision
121
122     double _fuse_range;
123
124     double _dt_count;
125     double _next_run;
126
127     string _name;
128     string _path;
129     string _submodel;
130     string _force_path;
131
132     const SGMaterial* _material;
133
134     void Run(double dt);
135     void handle_collision();
136     void handle_impact();
137     void setPitch (double e, double dt, double c);
138     void setHdg (double dt, double c);
139     void report_impact(double elevation, const FGAIBase *target = 0);
140
141     double getRecip(double az);
142
143 };
144
145 #endif  // _FG_AIBALLISTIC_HXX