]> git.mxchange.org Git - flightgear.git/blob - src/ATC/AIPlane.hxx
Moved some of the low level scene graph construction code over to simgear.
[flightgear.git] / src / ATC / AIPlane.hxx
1 // FGAIPlane - abstract base class for an AI plane
2 //
3 // Written by David Luff, started 2002.
4 //
5 // Copyright (C) 2002  David C. Luff - david.luff@nottingham.ac.uk
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License as
9 // published by the Free Software Foundation; either version 2 of the
10 // License, or (at your option) any later version.
11 //
12 // This program is distributed in the hope that it will be useful, but
13 // WITHOUT ANY WARRANTY; without even the implied warranty of
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 // General Public License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program; if not, write to the Free Software
19 // Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20
21 #ifndef _FG_AI_PLANE_HXX
22 #define _FG_AI_PLANE_HXX
23
24 #include <plib/sg.h>
25 #include <plib/ssg.h>
26 #include <simgear/math/point3d.hxx>
27 #include <simgear/scene/model/model.hxx>
28
29 #include "AIEntity.hxx"
30 #include "ATC.hxx"
31
32 enum PatternLeg {
33         TAKEOFF_ROLL,
34         CLIMBOUT,
35         TURN1,
36         CROSSWIND,
37         TURN2,
38         DOWNWIND,
39         TURN3,
40         BASE,
41         TURN4,
42         FINAL,
43         LANDING_ROLL,
44         LEG_UNKNOWN
45 };
46
47 /*****************************************************************
48 *
49 *  FGAIPlane - this class is derived from FGAIEntity and adds the 
50 *  practical requirement for an AI plane - the ability to send radio
51 *  communication, and simple performance details for the actual AI
52 *  implementation to use.  The AI implementation is expected to be
53 *  in derived classes - this class does nothing useful on its own.
54 *
55 ******************************************************************/
56 class FGAIPlane : public FGAIEntity {
57
58 public:
59
60         FGAIPlane();
61     virtual ~FGAIPlane();
62
63     // Run the internal calculations
64     virtual void Update(double dt);
65         
66         // Send a transmission *TO* the AIPlane.
67         // FIXME int code is a hack - eventually this will receive Alexander's coded messages.
68         virtual void RegisterTransmission(int code);
69         
70         // Return the current pattern leg the plane is flying.
71         inline PatternLeg GetLeg() {return leg;}
72
73 protected:
74         PlaneRec plane;
75
76     double mag_hdg;     // degrees - the heading that the physical aircraft is *pointing*
77     double track;       // track that the physical aircraft is *following* - degrees relative to *true* north
78     double crab;        // Difference between heading and track due to wind.
79     double mag_var;     // degrees
80     double IAS;         // Indicated airspeed in knots
81     double vel;         // velocity along track in knots
82     double vel_si;      // velocity along track in m/s
83     double slope;       // Actual slope that the plane is flying (degrees) - +ve is uphill
84     double AoA;         // degrees - difference between slope and pitch
85     // We'll assume that the plane doesn't yaw or slip - the track/heading difference is to allow for wind
86
87     double freq;        // The comm frequency that we're operating on
88
89     // We need some way for this class to display its radio transmissions if on the 
90     // same frequency and in the vicinity of the user's aircraft
91     // This may need to be done independently of ATC eg CTAF
92     // Make radio transmission - this simply sends the transmission for physical rendering if the users
93     // aircraft is on the same frequency and in range.  It is up to the derived classes to let ATC know
94     // what is going on.
95     void Transmit(string msg);
96
97     void Bank(double angle);
98     void LevelWings(void);
99         
100         PatternLeg leg;
101 };
102
103 #endif  // _FG_AI_PLANE_HXX
104