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
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.
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.
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.
20 #ifndef _FG_AIBASE_HXX
21 #define _FG_AIBASE_HXX
25 #include <simgear/constants.h>
26 #include <simgear/math/point3d.hxx>
27 #include <simgear/scene/model/placement.hxx>
29 #include <Main/fg_props.hxx>
30 #include "AIFlightPlan.hxx"
42 virtual void update(double dt);
43 inline Point3D GetPos() { return(pos); }
45 enum object_type { otNull, otAircraft, otShip, otBallistic,
46 otRocket, otStorm, otThermal };
50 virtual void unbind();
52 void setPath( const char* model );
53 void setSpeed( double speed_KTAS );
54 void setAltitude( double altitude_ft );
55 void setHeading( double heading );
56 void setLatitude( double latitude );
57 void setLongitude( double longitude );
58 void setBank( double bank );
62 void setDie( bool die );
67 SGPropertyNode *props;
70 // these describe the model's actual state
71 Point3D pos; // WGS84 lat & lon in degrees, elev above sea-level in meters
72 double hdg; // True heading in degrees
73 double roll; // degrees, left is negative
74 double pitch; // degrees, nose-down is negative
75 double speed; // knots true airspeed
76 double altitude; // meters above sea level
77 double vs; // vertical speed, feet per minute
79 // these describe the model's desired state
80 double tgt_heading; // target heading, degrees true
81 double tgt_altitude; // target altitude, *feet* above sea level
82 double tgt_speed; // target speed, KTAS
88 // these describe radar information for the user
89 bool in_range; // true if in range of the radar, otherwise false
90 double bearing; // true bearing from user to this model
91 double elevation; // elevation in degrees from user to this model
92 double range; // range from user to this model, nm
93 double rdot; // range rate, in knots
94 double horiz_offset; // look left/right from user to me, deg
95 double vert_offset; // look up/down from user to me, deg
96 double x_shift; // value used by radar display instrument
97 double y_shift; // value used by radar display instrument
98 double rotation; // value used by radar display instrument
101 string model_path; //Path to the 3D model
102 ssgBranch * model; //The 3D model object
103 SGModelPlacement aip;
118 object_type getType();
119 bool isa( object_type otype );
121 double _getVS_fps() const;
122 void _setVS_fps( double _vs );
124 double _getAltitude() const;
125 void _setAltitude( double _alt );
127 void _setLongitude( double longitude );
128 void _setLatitude ( double latitude );
130 double _getLongitude() const;
131 double _getLatitude () const;
133 double _getBearing() const;
134 double _getElevation() const;
135 double _getRdot() const;
136 double _getH_offset() const;
137 double _getV_offset() const;
138 double _getX_shift() const;
139 double _getY_shift() const;
140 double _getRotation() const;
142 inline double _getRange() { return range; };
144 static bool _isNight();
148 inline void FGAIBase::setPath( const char* model ) {
149 model_path.append(model);
152 inline void FGAIBase::setSpeed( double speed_KTAS ) {
153 speed = tgt_speed = speed_KTAS;
156 inline void FGAIBase::setHeading( double heading ) {
157 hdg = tgt_heading = heading;
160 inline void FGAIBase::setAltitude( double altitude_ft ) {
161 altitude = tgt_altitude = altitude_ft;
162 pos.setelev(altitude * SG_FEET_TO_METER);
165 inline void FGAIBase::setBank( double bank ) {
166 roll = tgt_roll = bank;
170 inline void FGAIBase::setLongitude( double longitude ) {
171 pos.setlon( longitude );
173 inline void FGAIBase::setLatitude ( double latitude ) {
174 pos.setlat( latitude );
177 inline void FGAIBase::setDie( bool die ) { delete_me = die; }
178 inline bool FGAIBase::getDie() { return delete_me; }
180 inline void FGAIBase::setID( int ID ) { id = ID; }
181 inline int FGAIBase::getID() { return id; }
183 inline FGAIBase::object_type FGAIBase::getType() { return _otype; }
185 #endif // _FG_AIBASE_HXX