Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

airport.h

Go to the documentation of this file.
00001 #ifndef _AIRPORT_H
00002 #define _AIRPORT_H
00003 
00004 #ifdef __GNUG__
00005 #include <vector>
00006 #include <vector.h>
00007 #include <map.h>
00008 using namespace std;
00009 #else
00010 #include <vector>
00011 #include <map>
00012 #endif
00013 
00014 #include <ctype.h>
00015 #include <string>
00016 #include <list>
00017 #include <algorithm>
00018 #include <fstream.h>
00019 #include <stdlib.h>
00020 #include <math.h>
00021 
00022 #ifdef HPUX
00023 #define atan2 atan2f
00024 #endif
00025 
00026 #include "OBJlib.h"
00027 #include "waterGL.h"
00028 
00029 //#include "grass.h"
00030 //#include "runway.h"
00031 // #############################################################################
00032 // ## Defines ##################################################################
00033 // #############################################################################
00034 #define PI                              3.1415926535897932
00035 
00036 #define YES             0
00037 #define NO              1
00038 #define QUEUED  2
00039 
00040 #define ONE_WAY 0
00041 #define TWO_WAY 1
00042 
00043 #define LIGHT_INTERVAL  15
00044 
00045 // #############################################################################
00046 // ## Classes and Structs ######################################################
00047 // #############################################################################
00048 // ********** Coastline ********************************************************
00050 struct Coastline
00051 {
00052         vector<float> coords;
00053 };
00054 
00056 // ********** RunwayPiece ******************************************************
00057 struct RunwayPiece
00058 {
00059         string handle;
00060         unsigned long thresholdWeight;
00061         float startX, endX, startY, endY, anchorX, anchorY, radius;
00062         int direction;
00063         int maxPlanesQueued;
00064         list<string> planesQueued;
00065 };
00066 
00067 // ********** TerminalPiece ****************************************************
00068 struct TerminalPiece
00069 {
00070         int x;
00071         int y;
00072         int xRadius;
00073         int yRadius;
00074         int height;
00075         int theta;
00076 };
00077 
00078 // ********** TowerPiece ******************************************************
00079 struct TowerPiece
00080 {
00081         int x;
00082         int y;
00083         int xRadius;
00084         int yRadius;
00085         int height;
00086 };
00087 
00091 // ********** RunwayResponse ***************************************************
00092 struct RunwayResponse
00093 {
00094         int response;
00095         int queuePosition;
00096         int delayTimeGuess;
00097 };
00098 
00103 // ********** Airport **********************************************************
00104 class Airport
00105 {
00106 public:
00109         Airport();
00110 
00112         ~Airport();
00113 
00115         void Animate();
00116 
00119         void Center( double & x, double & y, double & z );
00120 
00123         void GetNearestPoint( float planeX, float planeY, float & coordX, float & coordY, float & runwayDirX, float & runwayDirY, string runwayHandle );
00124         void GetNearestPoint( float planeX, float planeY, float & coordX, float & coordY, float & runwayDirX, float & runwayDirY );
00125 
00128         string GetNearestRunway( float xPos, float yPos );
00129 
00131         const int GetNumRunways();
00132 
00134         const int GetNumPlanesQueued( string runwayHandle );
00135 
00137         bool IsPlaneQueued( string planeHandle, string runwayHandle );
00138 
00141         bool LoadAirport( char * name );
00142 
00144         bool Render();
00145 
00147         RunwayResponse ReserveRunway( string planeHandle, string runwayHandle );
00148         RunwayResponse ReserveRunway( string planeHandle, float xPos, float yPos );
00149 
00151         void SetScale( double newScale );
00152 
00156         void SetWaterSpeed( float xSpeed, float ySpeed );
00157         
00159         void UnreserveRunway( string planeHandle, string runwayHandle );
00160         void UnreserveRunway( string planeHandle );
00161 private:
00162         // Finds the slope and y intercept of a line given two points
00163         void FindLine( float startX, float startY, float endX, float endY, float & m, float & B );
00164 
00165         // Checks if a point is on a runway
00166         bool InsideRunway( float x, float y, int & numInside );
00167 
00168         // Checks for an intersection between two lines
00169         bool Intersection( float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4, float & x, float & y);
00170 
00171         // LoadCoasts gets the coastline placement information
00172         bool LoadCoast( ifstream & airportInfo, char * buffer );
00173 
00174         // LoadDisplayLists sets up the airport display list
00175         bool LoadDisplayLists();
00176 
00177         // LoadExtents loads the boundaries of the airport
00178         bool LoadExtents( ifstream & airportInfo, char * buffer );
00179 
00180         // These functions load the appropriate placement of all airport pieces.
00181         bool LoadTowers( ifstream & airportInfo, char * buffer );
00182         bool LoadTerminals( ifstream & airportInfo, char * buffer );
00183         bool LoadRunways( ifstream & airportInfo, char * buffer );
00184 
00185         // LoadModels loads the Alias/Wavefront control tower and terminal models.
00186         bool LoadModels();
00187 
00188         // LoadTextures sets up all texturing information
00189         bool LoadTextures();
00190 
00191         // Renders the lights part of the display list
00192         void RenderLights();
00193 
00194         // Parts of the airport display list called by Render()
00195         void RenderRunways();
00196         void RenderTerminal( int centerX, int centerY, int radiusX, int radiusY, int height, int theta );
00197         void RenderTower( int centerX, int centerY, int radiusX, int radiusY, int height );
00198         void RenderWater();
00199 
00200         // SetupRunwayEdges is used to create the vector RunwayEdges, which is used
00201         // for the lights along each runway, as well as the paint
00202         void SetupRunwayEdges();
00203 
00204         // SetupWater creates the closed polylines needed to define an area of
00205         // water. It sets up the water vector for rendering.
00206         void SetupWater();
00207 
00208         // SkipComments is used to skip the comments in a file when reading the
00209         // airport placement information.
00210         bool SkipComments( ifstream & file, char * buffer );
00211 
00212         // SkipSpaces tries to send a digit to buffer. However, if it encounters
00213         // something that isn't digits or spaces, it returns false.
00214         bool SkipSpaces( ifstream & file, char * buffer );
00215 
00216 
00217 
00218         // These variables store all information needed to place their
00219         // respective pieces.
00220         TowerPiece              tower;                  // The tower
00221         vector<RunwayPiece>     runways;                // The runways
00222         vector<TerminalPiece>   terminals;              // The terminals
00223 
00224         // coast stores a vector of Coastlines, thus any number of polylines,
00225         // defining the coast surrounding the airport, if there is any.
00226         vector<Coastline> coast;                        // The coast polylines
00227 
00228         // water stores the patches of water in the terrain and the
00229         // information on how to render them.
00230         vector<WaterGL> water;
00231 
00232         // Maps the handles of each runway to an index
00233         map<string, int> runwayHandleMap;
00234 
00235         // The edges of the runways, used for the paint outline and lights on
00236         // the outside of each runway
00237         vector<float> runwayEdges;
00238 
00239         // These variables store all model, texturing, and material information
00240         // relevant to the control tower and terminals. The GLMmodel pointer is
00241         // used to load an Alias/Wavefront .obj file.
00242         GLMmodel * towerModel;
00243         GLMmodel * terminalModel;
00244 
00245         // Display lists
00246         GLuint  airportDisplayList;
00247 
00248         int extentX1, extentY1, extentX2, extentY2;     // Airport extents
00249 
00250         int centerX, centerY;                           // What is the center of the airport?
00251         
00252         double scale;   // The default units for the airport class are such that                        // one OpenGL unit = 1 meter. The scale variable can
00253                         // be used to increase or decrease scale. Thus, a scale 
00254                         // of .5 will make everything drawn to 50% scale. Thus, 
00255                         // the user has to know what sort of unit conversion he 
00256                         // wants to do.
00257 
00258 };
00259 
00260 #endif

Generated on Sun Jun 16 17:36:41 2002 for Anirudh's Vortex-Wake Simulation Code by doxygen1.2.13.1 written by Dimitri van Heesch, © 1997-2001