48 float dx = car->_pos_X -
eye[0];
49 float dy = car->_pos_Y -
eye[1];
51 return dx * dx + dy * dy;
56 grMakeLookAtMat4 ( sgMat4 dst,
const sgVec3 eye,
const sgVec3 center,
const sgVec3 up )
68 sgSubVec3 (
y, center, eye ) ;
71 sgCopyVec3 ( z, up ) ;
74 sgVectorProductVec3 ( x,
y, z ) ;
77 sgVectorProductVec3 ( z, x,
y ) ;
80 sgNormaliseVec3 ( x ) ;
81 sgNormaliseVec3 (
y ) ;
82 sgNormaliseVec3 ( z ) ;
85 #define M(row,col) dst[row][col] 86 M(0,0) = x[0];
M(0,1) = x[1];
M(0,2) = x[2];
M(0,3) = 0.0;
87 M(1,0) =
y[0];
M(1,1) =
y[1];
M(1,2) =
y[2];
M(1,3) = 0.0;
88 M(2,0) = z[0];
M(2,1) = z[1];
M(2,2) = z[2];
M(2,3) = 0.0;
89 M(3,0) = eye[0];
M(3,1) = eye[1];
M(3,2) = eye[2];
M(3,3) = 1.0;
95 float myfovy,
float myfovymin,
float myfovymax,
96 float myfnear,
float myffar,
float myfogstart,
float myfogend)
97 :
cGrCamera(myscreen, id, drawCurr, drawDrv, drawBG, mirrorAllowed)
134 const int BUFSIZE=1024;
145 tdble dx, dy, dz, dd;
154 dd = sqrt(dx*dx+dy*dy+dz*dz);
159 res = (float)
scrh / 2.0 / dd / tan(ang);
168 const int BUFSIZE=256;
170 const int PATHSIZE=1024;
216 glMatrixMode(GL_PROJECTION);
223 glMatrixMode(GL_MODELVIEW);
229 static float BACKGROUND_FOVY_CUTOFF = 60.0f;
233 sgSetVec3(
eye, 0, 0, 0);
238 if (
fovy < BACKGROUND_FOVY_CUTOFF) {
239 fovy = BACKGROUND_FOVY_CUTOFF;
250 float myfovy,
float myfovymin,
float myfovymax,
251 float myfnear,
float myffar = 1500.0,
252 float myfogstart = 800.0,
float myfogend = 1500.0)
254 myfovy, myfovymin, myfovymax,
255 myfnear, myffar, myfogstart, myfogend) {
264 p[0] = car->_drvPos_x;
265 p[1] = car->_drvPos_y;
266 p[2] = car->_drvPos_z;
267 sgXformPnt3(
p, car->_posMat);
273 P[0] = car->_drvPos_x + 30.0;
274 P[1] = car->_drvPos_y;
275 P[2] = car->_drvPos_z;
276 sgXformPnt3(P, car->_posMat);
292 glDeleteTextures (1, &
tex);
306 P[0] = car->_bonnetPos_x;
307 P[1] = car->_bonnetPos_y;
308 P[2] = car->_bonnetPos_z;
309 sgXformPnt3(P, car->_posMat);
315 p[0] = car->_bonnetPos_x - 30.0;
316 p[1] = car->_bonnetPos_y;
317 p[2] = car->_bonnetPos_z;
318 sgXformPnt3(
p, car->_posMat);
324 up[0] = car->_posMat[2][0];
325 up[1] = car->_posMat[2][1];
326 up[2] = car->_posMat[2][2];
363 glBindTexture(GL_TEXTURE_2D,
tex);
364 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
365 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
366 glReadBuffer(GL_BACK);
368 glCopyTexImage2D(GL_TEXTURE_2D,
386 glEnable(GL_SCISSOR_TEST);
392 glDisable(GL_SCISSOR_TEST);
394 glBindTexture(GL_TEXTURE_2D,
tex);
395 glReadBuffer(GL_BACK);
398 glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
408 glBindTexture (GL_TEXTURE_2D,
tex);
409 glBegin(GL_TRIANGLE_STRIP);
411 glColor4f(1.0, 1.0, 1.0, 1.0);
427 float myfovy,
float myfovymin,
float myfovymax,
428 float myfnear,
float myffar = 1500.0,
429 float myfogstart = 1400.0,
float myfogend = 1500.0)
431 myfovy, myfovymin, myfovymax,
432 myfnear, myffar, myfogstart, myfogend) {
438 p[0] = car->_bonnetPos_x;
439 p[1] = car->_bonnetPos_y;
440 p[2] = car->_bonnetPos_z;
441 sgXformPnt3(
p, car->_posMat);
447 P[0] = car->_bonnetPos_x + 30.0;
448 P[1] = car->_bonnetPos_y;
449 P[2] = car->_bonnetPos_z;
450 sgXformPnt3(P, car->_posMat);
456 up[0] = car->_posMat[2][0];
457 up[1] = car->_posMat[2][1];
458 up[2] = car->_posMat[2][2];
478 float mydist,
float myHeight,
float fnear,
float ffar = 1500.0,
479 float myfogstart = 1400.0,
float myfogend = 1500.0)
500 }
else if (fabs(
PreA - A) > fabs(
PreA - A - 2*
PI)) {
506 x = car->_pos_X -
dist * CosA;
507 y = car->_pos_Y -
dist * SinA;
534 float mydist,
float fnear,
float ffar = 1500.0,
535 float myfogstart = 1400.0,
float myfogend = 1500.0)
555 }
else if (fabs(
PreA - A) > fabs(
PreA - A - 2*
PI)) {
561 x = car->_pos_X -
dist * CosA;
562 y = car->_pos_Y -
dist * SinA;
588 float mydist,
float fnear,
float ffar = 1500.0,
589 float myfogstart = 1400.0,
float myfogend = 1500.0)
599 tdble CosA = cos(car->_yaw);
600 tdble SinA = sin(car->_yaw);
629 float mydistx,
float mydisty,
float mydistz,
631 float myfogstart = 1400.0,
float myfogend = 1500.0)
670 float mydistz,
int axis,
672 float myfogstart = 1600.0,
float myfogend = 1700.0)
702 tdble x = car->_pos_X;
733 float myfogstart = 1400.0,
float myfogend = 1500.0)
750 const int PATHSIZE=1024;
764 tdble dx, dy, dz, dd;
774 dd = sqrt(dx*dx+dy*dy+dz*dz);
799 float eyex,
float eyey,
float eyez,
800 float centerx,
float centery,
float centerz,
802 float myfogstart = 1600.0,
float myfogend = 1700.0)
866 float myfogstart = 1400.0,
float myfogend = 1500.0)
878 curCam = car->_trkPos.seg->cam;
880 if (curCam == NULL) {
916 float myfogstart = 1400.0,
float myfogend = 1500.0)
948 bool reset_camera =
false;
951 if (fabs(dt) > 1.0f) {
973 timer = 10.0 + (int)(5.0*rand()/(RAND_MAX+1.0));
974 offset[0] = -0.5 + (rand()/(RAND_MAX+1.0));
975 offset[1] = -0.5 + (rand()/(RAND_MAX+1.0));
986 eye[0] = car->_pos_X + 50.0 + (50.0*rand()/(RAND_MAX+1.0));
987 eye[1] = car->_pos_Y + 50.0 + (50.0*rand()/(RAND_MAX+1.0));
988 eye[2] = car->_pos_Z + 50.0 + (50.0*rand()/(RAND_MAX+1.0));
1000 center[0] = (car->_pos_X);
1001 center[1] = (car->_pos_Y);
1002 center[2] = (car->_pos_Z);
1006 if (
eye[2] < height) {
1007 timer = 10.0 + (int)(10.0*rand()/(RAND_MAX+1.0));
1008 offset[2] = height - car->_pos_Z + 1.0;
1034 float myfogstart = 1400.0,
float myfogend = 1500.0)
1047 const int PATHSIZE=1024;
1048 char path[PATHSIZE];
1062 tdble dx, dy, dz, dd;
1065 curCam = car->_trkPos.seg->cam;
1067 if (curCam == NULL) {
1085 dd = sqrt(dx*dx+dy*dy+dz*dz);
1107 seg = car->_trkPos.seg;
1110 switch (seg->
type) {
1112 lg += car->_trkPos.toStart;
1115 lg += car->_trkPos.toStart * seg->
radius;
1142 float myfogstart = 1400.0,
float myfogend = 1500.0)
1175 if (car == s->
cars[i]) {
1215 dist = fabs(car->_trkPos.toMiddle) -
grTrack->
width / 2.0;
1259 curPrio = -1000000.0;
1273 if (last_current !=
current) {
#define RM_CMD_PIT_ASKED
Race command: Pit asked.
void update(tCarElt *car, tSituation *s)
#define DEG2RAD(x)
Degree to radian conversion.
cGrCarCamLookAt(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, int axis, float eyex, float eyey, float eyez, float centerx, float centery, float centerz, float fnear, float ffar=1500.0, float myfogstart=1600.0, float myfogend=1700.0)
float getLODFactor(float x, float y, float z)
cGrCarCamRoadNoZoom(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
double currentTime
current time in sec since the beginning of the simulation
cGrCarCamInsideFixedCar(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float myfovy, float myfovymin, float myfovymax, float myfnear, float myffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
int type
Geometrical type:
int raceCmd
command issued by the driver
void grCamCreateSceneCameraList(class cGrScreen *myscreen, tGrCamHead *cams, tdble fovFactor)
static tdble GetDistToStart(tCarElt *car)
cars situation used to inform the GUI and the drivers
void update(tCarElt *car, tSituation *s)
void loadDefaults(char *attr)
tCarElt ** cars
list of cars
void update(tCarElt *car, tSituation *s)
tdble width
main track width
void update(tCarElt *car, tSituation *s)
void activateViewport(void)
virtual ~cGrCarCamMirror()
void update(tCarElt *car, tSituation *s)
tdble lgfromstart
Length of beginning of segment from starting line.
virtual float getFovY(void)
cGrCarCamBehind2(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float mydist, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
void onSelect(tCarElt *car, tSituation *s)
#define RM_CAR_STATE_NO_SIMU
Do not simulate the car.
#define RAD2DEG(x)
Radian to degree conversion.
void update(tCarElt *car, tSituation *s)
The Gaming Framework API (client part).
void loadDefaults(char *attr)
void update(tCarElt *car, tSituation *s)
void update(tCarElt *car, tSituation *s)
tdble length
main track length
cGrCarCamSide(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float mydistx, float mydisty, float mydistz, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
tCarElt * getCurrentCar(void)
void update(tCarElt *car, tSituation *s)
cGrCarCamRoadFly(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
cGrCarCamUp(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float mydistz, int axis, float fnear, float ffar=1500.0, float myfogstart=1600.0, float myfogend=1700.0)
void update(tCarElt *car, tSituation *s)
void add(tGrCamHead *head)
void update(tCarElt *car, tSituation *s)
cGrCarCamInside(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float myfovy, float myfovymin, float myfovymax, float myfnear, float myffar=1500.0, float myfogstart=800.0, float myfogend=1500.0)
float tdble
Floating point type used in TORCS.
cGrCarCamRoadZoomTVD(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
void update(tCarElt *car, tSituation *s)
cGrCarCamRoadZoom(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
void setViewport(int x, int y, int w, int h)
void setCurrentCar(tCarElt *newCurCar)
#define GF_TAILQ_INIT(head)
Head initialization (Mandatory)
cGrPerspCamera(class cGrScreen *myscreen, int id, int drawCurr, int drawDrv, int drawBG, int mirrorAllowed, float myfovy, float myfovymin, float myfovymax, float myfnear, float myffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
cGrCarCamBehind(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float mydist, float myHeight, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
Graphic Module Interface Definition.
tdble radius
Radius in meters of the middle of the track (>0)
float grGetHOT(float x, float y)
cGrCarCamCenter(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float mydistz, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
void update(tCarElt *car, tSituation *s)
int GfParmSetNum(void *handle, const char *path, const char *key, const char *unit, tdble val)
Set a numerical parameter in the parameter set handle.
void GfScrGetSize(int *scrw, int *scrh, int *vieww, int *viewh)
Get the screen and viewport sizes.
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
void update(tCarElt *car, tSituation *s)
int collision
Collision value for graphics and sound, clearing is managed by consumers.
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
void update(tCarElt *car, tSituation *s)
void setPos(int x, int y, int w, int h)
class cGrScreen * grScreens[GR_NB_MAX_SCREEN]
void loadDefaults(char *attr)
cGrCarCamFront(class cGrScreen *myscreen, int id, int drawCurr, int drawBG, float fovy, float fovymin, float fovymax, float mydist, float fnear, float ffar=1500.0, float myfogstart=1400.0, float myfogend=1500.0)
void GfScrShutdown(void)
Shutdown the screen.
float getDist2(tCarElt *car)
static void grMakeLookAtMat4(sgMat4 dst, const sgVec3 eye, const sgVec3 center, const sgVec3 up)
sgVec3 * getCenterv(void)
tDynPt DynGCg
GC data (world axis)