]> git.mxchange.org Git - flightgear.git/blob - src/AIModel/AIBase.hxx
9221ddb4f24894383064161bd58ae0b6e35d1ac0
[flightgear.git] / src / AIModel / AIBase.hxx
1 // FGAIBase - abstract base class for AI objects
2 // Written by David Culp, started Nov 2003, based on
3 // David Luff's FGAIEntity class.
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., 675 Mass Ave, Cambridge, MA 02139, USA.
19
20 #ifndef _FG_AIBASE_HXX
21 #define _FG_AIBASE_HXX
22
23 #include <simgear/constants.h>
24 #include <simgear/math/point3d.hxx>
25 #include <simgear/scene/model/placement.hxx>
26 #include <string>
27
28 SG_USING_STD(string);
29
30 class FGAIBase {
31
32 public:
33
34     virtual ~FGAIBase();
35     virtual void update(double dt);
36     inline Point3D GetPos() { return(pos); }
37
38     virtual bool init();
39     virtual void bind();
40     virtual void unbind();
41
42     void setPath( const char* model );
43     void setSpeed( double speed_KTAS );
44     void setAltitude( double altitude_ft );
45     void setLongitude( double longitude );
46     void setLatitude( double latitude );
47     void setHeading( double heading );
48
49     void setDie( bool die );
50     bool getDie();
51
52 protected:
53
54     SGPropertyNode *props;
55
56     Point3D pos;        // WGS84 lat & lon in degrees, elev above sea-level in meters
57     double lat, lon;    // As above, this is needed for the property bindings
58     double hdg;         // True heading in degrees
59     double roll;        // degrees, left is negative
60     double pitch;       // degrees, nose-down is negative
61     double speed;       // knots true airspeed
62     double altitude;    // meters above sea level
63     double vs;           // vertical speed, feet per minute   
64
65     double tgt_heading;  // target heading, degrees true
66     double tgt_altitude; // target altitude, *feet* above sea level
67     double tgt_speed;    // target speed, KTAS
68     double tgt_roll;
69     double tgt_pitch;
70     double tgt_yaw;
71     double tgt_vs;
72
73
74     string model_path;     //Path to the 3D model
75     SGModelPlacement aip;
76     bool delete_me;
77
78     void Transform();
79
80 };
81
82
83 inline void FGAIBase::setPath( const char* model ) {
84   model_path.append(model);
85 }
86
87 inline void FGAIBase::setSpeed( double speed_KTAS ) {
88   speed = tgt_speed = speed_KTAS;
89 }
90
91 inline void FGAIBase::setAltitude( double altitude_ft ) {
92   altitude = tgt_altitude = altitude_ft;
93   pos.setelev(altitude * SG_FEET_TO_METER);
94 }
95
96
97 inline void FGAIBase::setLongitude( double longitude ) {
98   lon = longitude;
99   pos.setlon(longitude);
100 }
101
102 inline void FGAIBase::setLatitude( double latitude ) {
103   lat = latitude;
104   pos.setlat(latitude);
105 }
106
107 inline void FGAIBase::setHeading( double heading ) {
108   hdg = tgt_heading = heading;
109 }
110
111 inline void FGAIBase::setDie( bool die ) { delete_me = die; }
112 inline bool FGAIBase::getDie() { return delete_me; }
113
114 #endif  // _FG_AIBASE_HXX
115