TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
grtrackmap.h
Go to the documentation of this file.
1/***************************************************************************
2
3 file : grtrackmap.h
4 created : Fri Aug 29 00:57:00 CEST 2003
5 copyright : (C) 2003 by Bernhard Wymann
6 email : berniw@bluewin.ch
7 version : $Id$
8
9 ***************************************************************************/
10
11/***************************************************************************
12 * *
13 * This program is free software; you can redistribute it and/or modify *
14 * it under the terms of the GNU General Public License as published by *
15 * the Free Software Foundation; either version 2 of the License, or *
16 * (at your option) any later version. *
17 * *
18 ***************************************************************************/
19
20/*
21 This class displays an overview map of the track, such that you can see the
22 upcoming track layout. Your car is displayed as a dot.
23 To get reasonable efficiency, the track is first rendered into a texture. During the
24 game just the texture needs to be redrawn.
25*/
26
27#ifndef _GRTRACKMAP_H_
28#define _GRTRACKMAP_H_
29
30#include <car.h>
31#include <raceman.h>
32#include <GL/gl.h>
33#include <GL/glut.h>
34#include <GL/glu.h>
35
36#ifndef WIN32
37#include <unistd.h>
38#endif
39#include <math.h>
40#include <glfeatures.h>
41
42#define TRACK_MAP_NONE (1<<0)
43#define TRACK_MAP_NORMAL (1<<1)
44#define TRACK_MAP_NORMAL_WITH_OPPONENTS (1<<2)
45#define TRACK_MAP_PAN (1<<3)
46#define TRACK_MAP_PAN_WITH_OPPONENTS (1<<4)
47#define TRACK_MAP_PAN_ALIGNED (1<<5)
48#define TRACK_MAP_PAN_ALIGNED_WITH_OPPONENTS (1<<6)
49
50// Must equal the biggest TRACK_MAP_*
51#define TRACK_MAP_MASK (1<<6)
52
53// Pointer to the track data found in grscene.cpp.
54#include <track.h>
55extern tTrack *grTrack;
56
57// Include to access window dimensions.
58#include "grmain.h"
59
61{
62 public:
63 // The constructor creates a texture of the track data, such that the track
64 // layout can be displayed efficiently. Additional data gets initialized.
66
67 // Release the texture and data.
69
70 // Walk trough the different available display modes.
71 void selectTrackMap();
72
73 // Draw the track map according to the display mode.
74 void display(
75 tCarElt *currentCar,
76 tSituation *situation,
77 int Winx,
78 int Winy,
79 int Winw,
80 int Winh
81 );
82
83 // Set the view mode
84 void setViewMode(int vm);
85
86 // Get The view mode
87 int getViewMode();
88
89 // Get the default view mode
91
92 private:
93 // The resolution in [m] to analyse turns.
94 static const float RESOLUTION;
95
96 // Minimum and Maximum line width in pixels to draw the track.
97 static const float MINLINEWIDTH;
98 static const float MAXLINEWIDTH;
99
100 // Some data needs just one initalization, after first initialization this is set to true.
101 static bool isinitalized;
102
103 // Texture object
104 static GLuint mapTexture;
105
106 // The car "dot" display list.
107 static GLuint cardot;
108
109 // Track bounding box properties, lower left, upper right corner, width and height.
110 static float track_min_x;
111 static float track_max_x;
112 static float track_min_y;
113 static float track_max_y;
114 static float track_width;
115 static float track_height;
116
117 // The ratio of width and height to MAX(width, height).
118 static float track_x_ratio;
119 static float track_y_ratio;
120
121 // Position and size of the map (relative to top left).
122 static int map_x;
123 static int map_y;
124 static int map_size;
125
126 // Scaling factor from meters to texels.
127 static float ratio;
128
129 // Color of the cars "dots".
130 static GLfloat currentCarColor[4];
131 static GLfloat aheadCarColor[4];
132 static GLfloat behindCarColor[4];
133
134 // Holds the current view (look at TRACK_MAP_*).
136
137 // Draw the track full visible and static.
138 void drawTrackNormal(int x, int y);
139
140 // Draw the track in the panning mode.
141 void drawTrackPanning(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *situation);
142
143 // Draw the track in the panning aligned mode.
144 void drawTrackPanningAligned(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *s);
145
146 // Draw the dot of the car.
147 void drawCar(tCarElt *currentCar, GLfloat* color, int x, int y);
148
149 // Draw all opponents of the current car.
150 void drawCars(tCarElt *currentCar, tSituation *s, int x, int y);
151
152 // Setus up colors.
153 void initColors();
154
155 void checkAndSetMinimum(float &currentmin, float &value);
156 void checkAndSetMaximum(float &currentmax, float &value);
157};
158
159#endif // _GRTRACKMAP_H_
160
static Vector y[4]
Definition Convex.cpp:56
struct CarElt tCarElt
Car structure (tCarElt).
void initColors()
static float track_y_ratio
Definition grtrackmap.h:119
static int map_size
Definition grtrackmap.h:124
static GLuint mapTexture
Definition grtrackmap.h:104
void selectTrackMap()
static GLfloat behindCarColor[4]
Definition grtrackmap.h:132
static int map_x
Definition grtrackmap.h:122
static const float MAXLINEWIDTH
Definition grtrackmap.h:98
void drawTrackPanning(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *situation)
static float track_width
Definition grtrackmap.h:114
static float track_max_y
Definition grtrackmap.h:113
static float track_min_x
Definition grtrackmap.h:110
void checkAndSetMaximum(float &currentmax, float &value)
static GLfloat currentCarColor[4]
Definition grtrackmap.h:130
void display(tCarElt *currentCar, tSituation *situation, int Winx, int Winy, int Winw, int Winh)
static const float RESOLUTION
Definition grtrackmap.h:94
void setViewMode(int vm)
void drawTrackNormal(int x, int y)
void drawCars(tCarElt *currentCar, tSituation *s, int x, int y)
static const float MINLINEWIDTH
Definition grtrackmap.h:97
static GLfloat aheadCarColor[4]
Definition grtrackmap.h:131
void drawCar(tCarElt *currentCar, GLfloat *color, int x, int y)
static float track_min_y
Definition grtrackmap.h:112
void checkAndSetMinimum(float &currentmin, float &value)
static float track_max_x
Definition grtrackmap.h:111
static GLuint cardot
Definition grtrackmap.h:107
static float ratio
Definition grtrackmap.h:127
int getDefaultViewMode()
static float track_x_ratio
Definition grtrackmap.h:118
void drawTrackPanningAligned(int Winx, int Winy, int Winw, int Winh, tCarElt *currentCar, tSituation *s)
static int map_y
Definition grtrackmap.h:123
static bool isinitalized
Definition grtrackmap.h:101
int getViewMode()
static float track_height
Definition grtrackmap.h:115
static int Winw
Definition grboard.cpp:52
static int Winx
Definition grboard.cpp:51
static int Winh
Definition grboard.cpp:54
static int Winy
Definition grboard.cpp:53
tTrack * grTrack
Definition grscene.cpp:58
struct Situation tSituation
cars situation used to inform the GUI and the drivers
Track structure.
Definition track.h:533