24#include <portability.h>
35#include <robottools.h>
40static float grWhite[4] = {1.0, 1.0, 1.0, 1.0};
41static float grRed[4] = {1.0, 0.0, 0.0, 1.0};
42static float grBlue[4] = {0.0, 0.0, 1.0, 1.0};
43static float grGreen[4] = {0.0, 1.0, 0.0, 1.0};
44static float grBlack[4] = {0.0, 0.0, 0.0, 1.0};
71 const int BUFSIZE=1024;
102 const int BUFSIZE=1024;
139 const int BUFSIZE=256;
146 snprintf(buf, BUFSIZE,
"FPS: %.1f", fps);
170 tdble X1, Y1, X2, Y2, xc, yc;
175 yc = (
tdble)(Y1 - 50);
177 X2 = -car->_DynGC.acc.y / 9.81f * 25.0f + X1;
178 Y2 = car->_DynGC.acc.x / 9.81f * 25.0f + Y1;
180 glColor4f(1.0, 1.0, 1.0, 1.0);
181 glVertex2f(X1-50, Y1);
182 glVertex2f(X1+50, Y1);
183 glVertex2f(X1, Y1-50);
184 glVertex2f(X1, Y1+50);
186 glVertex2f(xc, yc+100);
189 const tdble THNSS = 2.0f;
192 glColor4f(0.0, 0.0, 1.0, 1.0);
193 glVertex2f(X1 - THNSS, Y1);
194 glVertex2f(X1 + THNSS, Y1);
195 glVertex2f(X1 + THNSS, Y1 + car->
ctrl.
accelCmd * 50.0f);
196 glVertex2f(X1 - THNSS, Y1 + car->
ctrl.
accelCmd * 50.0f);
198 glVertex2f(X1 - THNSS, Y1);
199 glVertex2f(X1 + THNSS, Y1);
200 glVertex2f(X1 + THNSS, Y1 - car->
ctrl.
brakeCmd * 50.0f);
201 glVertex2f(X1 - THNSS, Y1 - car->
ctrl.
brakeCmd * 50.0f);
203 glVertex2f(X1, Y1 - THNSS);
204 glVertex2f(X1, Y1 + THNSS);
205 glVertex2f(X1 - car->
ctrl.
steer * 50.0f, Y1 + THNSS);
206 glVertex2f(X1 - car->
ctrl.
steer * 50.0f, Y1 - THNSS);
208 glVertex2f(xc - THNSS, yc);
209 glVertex2f(xc + THNSS, yc);
216 glColor4f(1.0, 0.0, 0.0, 1.0);
228 curH =
MIN(val, 1.0);
229 curH =
MAX(curH, 0.0);
242 glVertex2f(X1 -
THNSSFG, Y1 + curH);
243 glVertex2f(X1 +
THNSSFG, Y1 + curH);
244 glVertex2f(X1 +
THNSSFG, Y1 + H);
245 glVertex2f(X1 -
THNSSFG, Y1 + H);
250 glVertex2f(X1 +
THNSSFG, Y1 + curH);
251 glVertex2f(X1 -
THNSSFG, Y1 + curH);
261 if (car->_fuel < 5.0f) {
277 const int BUFSIZE=256;
287 snprintf(buf, BUFSIZE,
"%d/%d - %s", car->_pos, s->_ncars, car->_name);
289 dx =
MAX(dx, (x2-x));
292 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
294 glColor4f(0.1, 0.1, 0.1, 0.8);
295 glVertex2f(x-5,
y + dy);
296 glVertex2f(x+dx+5,
y + dy);
297 glVertex2f(x+dx+5,
y-5 - dy2 * 9 );
298 glVertex2f(x-5,
y-5 - dy2 * 9 );
308 if (car->_fuel < 5.0) {
313 snprintf(buf, BUFSIZE,
"%.1f l", car->_fuel);
324 snprintf(buf, BUFSIZE,
"%d", car->_dammage);
330 snprintf(buf, BUFSIZE,
"%d / %d", car->_laps, s->_totLaps);
339 if (!car->_commitBestLapTime) {
359 snprintf(buf, BUFSIZE,
"%d", (
int)(car->_topSpeed * 3.6));
367 const int BUFSIZE=256;
381 snprintf(buf, BUFSIZE,
"%d/%d - %s", car->_pos, s->_ncars, car->_name);
383 dx =
MAX(dx, (x3-x));
386 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
388 glColor4f(0.1, 0.1, 0.1, 0.8);
389 glVertex2f(x-5,
y + dy);
390 glVertex2f(x+dx+5,
y + dy);
391 int y2 =
y-5 - dy2 * 7;
392 glVertex2f(x+dx+5, y2);
398 glVertex2f(x-5, y2 - 2);
399 glVertex2f(x+dx+5, y2 - 2);
400 y2 = y2 - 2 - dy2 * 6;
401 glVertex2f(x+dx+5, y2);
407 glVertex2f(x-5, y2 - 2);
408 glVertex2f(x+dx+5, y2 - 2);
409 y2 = y2 - 2 - dy2 * 4;
410 glVertex2f(x+dx+5, y2);
421 if (car->_fuel < 5.0) {
426 snprintf(buf, BUFSIZE,
"%.1f l", car->_fuel);
433 snprintf(buf, BUFSIZE,
"%d / %d", car->_laps, s->_totLaps);
443 if (!car->_commitBestLapTime) {
454 if (car->_pos != 1) {
455 snprintf(buf, BUFSIZE,
"<- %s", s->
cars[car->_pos - 2]->_name);
457 if (s->
cars[car->_pos - 2]->_laps == car->_laps) {
468 if (car->_pos != s->_ncars) {
469 snprintf(buf, BUFSIZE,
"-> %s", s->
cars[car->_pos]->_name);
471 if (s->
cars[car->_pos]->_laps == car->_laps) {
483 static const char* wheellabel[4] = {
"FR",
"FL",
"RR",
"RL"};
487 static const int tx0 = 45;
488 static const int tdx = 47;
490 for (i = 0; i < 4; i++) {
499 snprintf(buf, BUFSIZE,
"%5.4f", wheel->
currentWear);
508 for (i = 0; i < 4; i++) {
533#define ALIGN_CENTER 0
542 GLfloat ledcolg[2][3] = {
547 GLfloat ledcolr[2][3] = {
557 int ledRed = (int)((car->_enginerpmRedLine * .9 / car->_enginerpmMax) * (
tdble)ledNb);
558 int ledLit = (int)((car->_enginerpm / car->_enginerpmMax) * (
tdble)ledNb);
562 x =
X - ((ledNb * ledWidth) + (ledNb - 1) * ledSpace) / 2;
568 x =
X - ((ledNb * ledWidth) + (ledNb - 1) * ledSpace);
571 x =
X - ((ledNb * ledWidth) + (ledNb - 1) * ledSpace) / 2;
579 glColor3f(0.1, 0.1, 0.1);
580 glVertex2f(x - ledSpace,
y + ledHeight + ledSpace);
581 glVertex2f(x + ledNb * (ledWidth+ ledSpace),
y + ledHeight + ledSpace);
582 glVertex2f(x + ledNb * (ledWidth+ ledSpace),
Winy);
583 glVertex2f(x - ledSpace,
Winy);
587 glColor3fv(ledcolg[0]);
588 for (i = 0; i < ledRed; i++) {
590 glVertex2f(x + ledWidth,
y);
591 glVertex2f(x + ledWidth,
y + ledHeight);
592 glVertex2f(x,
y + ledHeight);
593 x += ledWidth + ledSpace;
596 glColor3fv(ledcolr[0]);
597 for (i = ledRed; i < ledNb; i++) {
599 glVertex2f(x + ledWidth,
y);
600 glVertex2f(x + ledWidth,
y + ledHeight);
601 glVertex2f(x,
y + ledHeight);
602 x += ledWidth + ledSpace;
606 glColor3fv(ledcolg[1]);
607 for (i = 0; i < ledNb; i++) {
609 glColor3fv(ledcolr[1]);
612 glVertex2f(x +
DD,
y +
DD);
613 glVertex2f(x + ledWidth -
DD,
y +
DD);
614 glVertex2f(x + ledWidth -
DD,
y + ledHeight -
DD);
615 glVertex2f(x +
DD,
y + ledHeight -
DD);
616 x += ledWidth + ledSpace;
628 const int BUFSIZE=256;
635 snprintf(buf, BUFSIZE,
" kph %s",
gearStr[car->_gear+car->_gearOffset]);
639 snprintf(buf, BUFSIZE,
"%3d", abs((
int)(car->_speed_x * 3.6)));
647 const int BUFSIZE=256;
656 for (i = 0; i < s->_ncars; i++) {
657 if (car == s->
cars[i]) {
669 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
671 glColor4f(0.1, 0.1, 0.1, 0.8);
672 glVertex2f(x,
Winy + 5);
674 glVertex2f(
Winx + 180,
y + dy * (maxi + drawLaps));
675 glVertex2f(x,
y + dy * (maxi + drawLaps));
679 if (current + 1 > maxi) {
685 for (j = maxi; j > 0; j--) {
693 if (i == current + 1) {
700 snprintf(buf, BUFSIZE,
"%3d: %s", i, s->
cars[i-1]->_name);
705 }
else if (s->
cars[i-1]->_timeBehindLeader == 0) {
715 if (s->
cars[i-1]->_lapsBehindLeader == 0) {
718 if (s->
cars[i-1]->_lapsBehindLeader > 1) {
719 snprintf(buf, BUFSIZE,
"+%3d Laps", s->
cars[i-1]->_lapsBehindLeader);
721 snprintf(buf, BUFSIZE,
"+%3d Lap", s->
cars[i-1]->_lapsBehindLeader);
732 snprintf(buf, BUFSIZE,
"%d / %d", s->
cars[0]->_laps, s->_totLaps);
744 const int BUFSIZE=32;
748 curInst = &(
grCarInfo[index].instrument[0]);
751 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
752 glEnable(GL_TEXTURE_2D);
753 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
754 glBindTexture(GL_TEXTURE_2D, curInst->
texture->getTextureHandle());
756 glBindTexture(GL_TEXTURE_2D, 0);
761 }
else if (val < 0.0) {
771 glRotatef(val, 0, 0, 1);
779 curInst = &(
grCarInfo[index].instrument[1]);
782 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA) ;
783 glEnable(GL_TEXTURE_2D);
784 glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
785 glBindTexture(GL_TEXTURE_2D, curInst->
texture->getTextureHandle());
787 glBindTexture(GL_TEXTURE_2D, 0);
792 }
else if (val < 0.0) {
801 glRotatef(val, 0, 0, 1);
807 snprintf(buf, BUFSIZE,
"%d", abs((
int)(car->_speed_x * 3.6)));
839 const int BUFSIZE=256;
849 snprintf(buf, BUFSIZE,
"%d/%d", car->_pos, s->_ncars);
855 if (!car->_commitBestLapTime) {
868 snprintf(buf, BUFSIZE,
"Lap: %d/%d", car->_laps, s->_totLaps);
873 snprintf(buf, BUFSIZE,
"%s", car->_name);
877 if (car->_fuel < 5.0) {
888 snprintf(buf, BUFSIZE,
"%3d km/h", abs((
int)(car->_speed_x * 3.6)));
891 snprintf(buf, BUFSIZE,
"%s",
gearStr[car->_gear+car->_gearOffset]);
916 const int BUFSIZE=1024;
924 tdble xSz, ySz, xpos, ypos;
925 tdble needlexSz, needleySz;
927 ssgSetCurrentOptions ( &
options ) ;
931 handle = car->_carHandle;
938 snprintf(buf, BUFSIZE,
"drivers/%s/%d;drivers/%s;cars/%s;data/textures", car->_modName, car->_driverIndex, car->_modName, car->_carName);
964 glBegin(GL_TRIANGLE_STRIP);
966 glColor4f(1.0, 1.0, 1.0, 0.0);
967 glTexCoord2f(0.0, 0.0); glVertex2f(xpos, ypos);
968 glTexCoord2f(0.0, 1.0); glVertex2f(xpos, ypos + ySz);
969 glTexCoord2f(1.0, 0.0); glVertex2f(xpos + xSz, ypos);
970 glTexCoord2f(1.0, 1.0); glVertex2f(xpos + xSz, ypos + ySz);
977 glBegin(GL_TRIANGLE_STRIP);
979 glColor4f(1.0, 0.0, 0.0, 1.0);
980 glVertex2f(0, -needleySz);
981 glVertex2f(0, needleySz);
982 glVertex2f(needlexSz, -needleySz / 2.0);
983 glVertex2f(needlexSz, needleySz / 2.0);
994 snprintf(buf, BUFSIZE,
"drivers/%s/%d;drivers/%s;cars/%s;data/textures", car->_modName, car->_driverIndex, car->_modName, car->_carName);
1023 glBegin(GL_TRIANGLE_STRIP);
1025 glColor4f(1.0, 1.0, 1.0, 0.0);
1026 glTexCoord2f(0.0, 0.0); glVertex2f(xpos, ypos);
1027 glTexCoord2f(0.0, 1.0); glVertex2f(xpos, ypos + ySz);
1028 glTexCoord2f(1.0, 0.0); glVertex2f(xpos + xSz, ypos);
1029 glTexCoord2f(1.0, 1.0); glVertex2f(xpos + xSz, ypos + ySz);
1036 glBegin(GL_TRIANGLE_STRIP);
1038 glColor4f(1.0, 0.0, 0.0, 1.0);
1039 glVertex2f(0, -needleySz);
1040 glVertex2f(0, needleySz);
1041 glVertex2f(needlexSz, -needleySz / 2.0);
1042 glVertex2f(needlexSz, needleySz / 2.0);
1053 ssgDeRefDelete(
grCarInfo[i].instrument[0].texture);
1054 ssgDeRefDelete(
grCarInfo[i].instrument[1].texture);
1055 glDeleteLists(
grCarInfo[i].instrument[0].needleList, 1);
1056 glDeleteLists(
grCarInfo[i].instrument[1].needleList, 1);
1057 glDeleteLists(
grCarInfo[i].instrument[0].CounterList, 1);
1058 glDeleteLists(
grCarInfo[i].instrument[1].CounterList, 1);
#define PRM_TACHO_YDIGITCENTER
#define PRM_SPEEDO_XCENTER
#define PRM_SPEEDO_YDIGITCENTER
#define PRM_TACHO_XDIGITCENTER
#define PRM_SPEEDO_MINANG
#define PRM_SPEEDO_NDLXSZ
#define PRM_SPEEDO_XDIGITCENTER
#define PRM_SPEEDO_NDLYSZ
#define RM_CAR_STATE_DNF
Car did not finish.
struct CarElt tCarElt
Car structure (tCarElt).
#define PRM_SPEEDO_YCENTER
#define RM_CAR_STATE_BROKEN
Engine no more working.
#define PRM_SPEEDO_MAXANG
#define PRM_SPEEDO_DIGITAL
#define PRM_TACHO_XCENTER
#define PRM_TACHO_YCENTER
#define PRM_SPEEDO_MAXVAL
#define PRM_SPEEDO_MINVAL
void refreshBoard(tSituation *s, float Fps, int forceArcade, tCarElt *curr)
void grDispGGraph(tCarElt *car)
void selectBoard(int brd)
void grDispArcade(tCarElt *car, tSituation *s)
void grDispCounterBoard(tCarElt *car)
void grDispDebug(float fps, tCarElt *car)
void grDispCarBoard2(tCarElt *car, tSituation *s)
void grDispMisc(tCarElt *car)
void grDrawGauge(tdble X1, tdble Y1, tdble H, float *clr1, float *clr2, tdble val, const char *title)
void grDispCarBoard1(tCarElt *car, tSituation *s)
void grDispCarBoard(tCarElt *car, tSituation *s)
void loadDefaults(tCarElt *curCar)
void grDispCounterBoard2(tCarElt *car)
void grDispLeaderBoard(tCarElt *car, tSituation *s)
static float grDefaultClr[4]
void grShutdownBoardCar(void)
static const char * gearStr[MAX_GEARS]
void grInitBoardCar(tCarElt *car)
static void grDispEngineLeds(tCarElt *car, int X, int Y, int align, int bg)
float tdble
Floating point type used in TORCS.
int GfuiFontHeight(int font)
Get the height of an initialized GUI font.
int GfuiFontWidth(int font, const char *text)
Measure text using an initialized GUI font.
void GfuiPrintString(const char *text, float *fgColor, int font, int x, int y, int align)
Draw text immediately in the current OpenGL context without creating a widget.
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
int GfParmSetNum(void *handle, const char *path, const char *key, const char *unit, tdble val)
Set a numerical parameter in the parameter set handle.
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
static ssgLoaderOptionsEx options
ssgState * grSsgLoadTexState(const char *img)
void grWriteTime(float *color, int font, int x, int y, tdble sec, int sgn)
struct Situation tSituation
cars situation used to inform the GUI and the drivers
tCarElt ** cars
list of cars
double currentTime
current time in sec since the beginning of the simulation
Parameter header structure, a parameter can either carry a numeric or a string value,...
float msgColor[4]
RGBA of text.
tdble steer
Steer command [-1.0, 1.0].
tdble clutchCmd
Clutch command [0.0, 1.0].
char msg[4][32]
4 lines of 31 characters 0-1 from car 2-3 from race engine
tdble accelCmd
Accelerator command [0.0, 1.0].
tdble brakeCmd
Brake command [0.0, 1.0].
int skillLevel
Driver's skill level (0=rookie -> 3=pro)
Dynamic wheel information.
tgrCarInstrument instrument[2]
#define RPM2RADS(x)
RPM to Radian/s conversion.
#define GFUI_FONT_SMALL_C
#define GFUI_FONT_LARGE_C
#define GFUI_FONT_MEDIUM_C