torcs - 1.2.2

src/modules/graphic/ssggraph.sav/grtrackmap.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     file                 : grtrackmap.h
00004     created              : Fri Aug 29 00:57:00 CEST 2003
00005     copyright            : (C) 2003 by Bernhard Wymann
00006     email                : berniw@bluewin.ch
00007     version              : $Id: grtrackmap.h,v 1.4 2003/11/06 22:12:12 berniw Exp $
00008 
00009  ***************************************************************************/
00010 
00011 /***************************************************************************
00012  *                                                                         *
00013  *   This program is free software; you can redistribute it and/or modify  *
00014  *   it under the terms of the GNU General Public License as published by  *
00015  *   the Free Software Foundation; either version 2 of the License, or     *
00016  *   (at your option) any later version.                                   *
00017  *                                                                         *
00018  ***************************************************************************/
00019 
00020 /*
00021         This class displays an overview map of the track, such that you can see the
00022         upcoming track layout. Your car is displayed as a dot.
00023         To get reasonable efficiency, the track is first rendered into a texture. During the
00024         game just the texture needs to be redrawn.
00025 */
00026 
00027 #ifndef _GRTRACKMAP_H_
00028 #define _GRTRACKMAP_H_
00029 
00030 #include <car.h>
00031 #include <raceman.h>
00032 #include <GL/gl.h>
00033 #include <GL/glut.h>
00034 #include <GL/glu.h>
00035 
00036 #ifndef WIN32
00037 #include <unistd.h>
00038 #include "win32_glext.h"
00039 #endif
00040 #include <math.h>
00041 
00042 #define TRACK_MAP_NONE                                                  (1<<0)
00043 #define TRACK_MAP_NORMAL                                                (1<<1)
00044 #define TRACK_MAP_NORMAL_WITH_OPPONENTS                 (1<<2)
00045 #define TRACK_MAP_PAN                                                   (1<<3)
00046 #define TRACK_MAP_PAN_WITH_OPPONENTS                    (1<<4)
00047 #define TRACK_MAP_PAN_ALIGNED                                   (1<<5)
00048 #define TRACK_MAP_PAN_ALIGNED_WITH_OPPONENTS    (1<<6)
00049 
00050 // Must equal the biggest TRACK_MAP_*
00051 #define TRACK_MAP_MASK (1<<6)
00052 
00053 // Pointer to the track data found in grscene.cpp.
00054 #include <track.h>
00055 extern tTrack *grTrack;
00056 
00057 // Include to access window dimensions.
00058 #include "grmain.h"
00059 
00060 class cGrTrackMap
00061 {
00062         public:
00063                 // The constructor creates a texture of the track data, such that the track
00064                 // layout can be displayed efficiently. Additional data gets initialized.
00065                 cGrTrackMap();
00066 
00067                 // Release the texture and data.
00068                 ~cGrTrackMap();
00069 
00070                 // Walk trough the different available display modes.
00071                 void selectTrackMap();
00072 
00073                 // Draw the track map according to the display mode.
00074                 void display(
00075                         tCarElt *currentCar,
00076                         tSituation *situation,
00077                         int Winx,
00078                         int Winy,
00079                         int Winw,
00080                         int Winh
00081                 );
00082 
00083                 // Set the view mode 
00084                 void setViewMode(int vm);
00085                 
00086                 // Get The view mode
00087                 int getViewMode();
00088 
00089                 // Get the default view mode
00090                 int getDefaultViewMode();
00091 
00092         private:
00093                 // The resolution in [m] to analyse turns.
00094                 static const float RESOLUTION;
00095 
00096                 // Minimum and Maximum line width in pixels to draw the track.
00097                 static const float MINLINEWIDTH;
00098                 static const float MAXLINEWIDTH;
00099 
00100                 // Some data needs just one initalization, after first initialization this is set to true.
00101                 static bool isinitalized;
00102 
00103                 // Texture object
00104                 static GLuint mapTexture;
00105 
00106                 // The car "dot" display list.
00107                 static GLuint cardot;
00108 
00109                 // Track bounding box properties, lower left, upper right corner, width and height.
00110                 static float track_min_x;
00111                 static float track_max_x;
00112                 static float track_min_y;
00113                 static float track_max_y;
00114                 static float track_width;
00115                 static float track_height;
00116 
00117                 // The ratio of width and height to MAX(width, height).
00118                 static float track_x_ratio;
00119                 static float track_y_ratio;
00120 
00121                 // Position and size of the map (relative to top left).
00122                 static int map_x;
00123                 static int map_y;
00124                 static int map_size;
00125 
00126                 // Scaling factor from meters to texels.
00127                 static float ratio;
00128 
00129                 // Color of the cars "dots".
00130                 static GLfloat currentCarColor[4];
00131                 static GLfloat aheadCarColor[4];
00132                 static GLfloat behindCarColor[4];
00133 
00134                 // Holds the current view (look at TRACK_MAP_*).
00135                 int viewmode;
00136 
00137                 // Draw the track full visible and static.
00138                 void drawTrackNormal(int x, int y);
00139 
00140                 // Draw the track in the panning mode.
00141                 void drawTrackPanning(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *situation);
00142 
00143                 // Draw the track in the panning aligned mode.
00144                 void drawTrackPanningAligned(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *s);
00145 
00146                 // Draw the dot of the car.
00147                 void drawCar(tCarElt *currentCar, GLfloat* color, int x, int y);
00148 
00149                 // Draw all opponents of the current car.
00150                 void drawCars(tCarElt *currentCar, tSituation *s, int x, int y);
00151 
00152                 // Setus up colors.
00153                 void initColors();
00154 
00155                 void checkAndSetMinimum(float &currentmin, float &value);
00156                 void checkAndSetMaximum(float &currentmax, float &value);
00157 };
00158 
00159 #endif // _GRTRACKMAP_H_
00160 

Generated at Thu Feb 26 21:52:29 2004 for torcs by doxygen 1.3.3 written by Dimitri van Heesch, © 1997-1999
TORCS © Eric Espié 1999, 2002.