TORCS  1.3.9
The Open Racing Car Simulator
grcam.cpp
Go to the documentation of this file.
1 /***************************************************************************
2 
3  file : grcam.cpp
4  created : Mon Aug 21 20:55:32 CEST 2000
5  copyright : (C) 2000 by Eric Espie
6  email : torcs@free.fr
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 #include <stdio.h>
21 #include <stdlib.h>
22 #include <math.h>
23 #include <memory.h>
24 #ifdef WIN32
25 #include <windows.h>
26 #endif
27 #include <GL/gl.h>
28 #include <GL/glu.h>
29 #include <plib/ssg.h>
30 
31 #include <robottools.h>
32 #include <portability.h>
33 #include <graphic.h>
34 #include "grcam.h"
35 #include "grscreen.h"
36 #include "grscene.h"
37 #include "grshadow.h"
38 #include "grskidmarks.h"
39 #include "grsmoke.h"
40 #include "grcar.h"
41 #include "grmain.h"
42 #include "grutil.h"
43 #include <tgfclient.h>
44 
45 float
47 {
48  float dx = car->_pos_X - eye[0];
49  float dy = car->_pos_Y - eye[1];
50 
51  return dx * dx + dy * dy;
52 }
53 
54 
55 static void
56 grMakeLookAtMat4 ( sgMat4 dst, const sgVec3 eye, const sgVec3 center, const sgVec3 up )
57 {
58  // Caveats:
59  // 1) In order to compute the line of sight, the eye point must not be equal
60  // to the center point.
61  // 2) The up vector must not be parallel to the line of sight from the eye
62  // to the center point.
63 
64  /* Compute the direction vectors */
65  sgVec3 x,y,z;
66 
67  /* Y vector = center - eye */
68  sgSubVec3 ( y, center, eye ) ;
69 
70  /* Z vector = up */
71  sgCopyVec3 ( z, up ) ;
72 
73  /* X vector = Y cross Z */
74  sgVectorProductVec3 ( x, y, z ) ;
75 
76  /* Recompute Z = X cross Y */
77  sgVectorProductVec3 ( z, x, y ) ;
78 
79  /* Normalize everything */
80  sgNormaliseVec3 ( x ) ;
81  sgNormaliseVec3 ( y ) ;
82  sgNormaliseVec3 ( z ) ;
83 
84  /* Build the matrix */
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;
90 #undef M
91 }
92 
93 
94 cGrPerspCamera::cGrPerspCamera(class cGrScreen *myscreen, int id, int drawCurr, int drawDrv, int drawBG, int mirrorAllowed,
95  float myfovy, float myfovymin, float myfovymax,
96  float myfnear, float myffar, float myfogstart, float myfogend)
97  : cGrCamera(myscreen, id, drawCurr, drawDrv, drawBG, mirrorAllowed)
98 {
99  fovy = myfovy;
100  fovymin = myfovymin;
101  fovymax = myfovymax;
102  fnear = myfnear;
103  ffar = myffar;
104  fovydflt = myfovy;
105  fogstart = myfogstart;
106  fogend = myfogend;
107 
108 }
109 
111 {
112  // PLib takes the field of view as angles in degrees. However, the
113  // aspect ratio really aplies to lengths in the projection
114  // plane. So we have to transform the fovy angle to a length in
115  // the projection plane, apply the aspect ratio and transform the
116  // result back to an angle. Care needs to be taken to because the
117  // tan and atan functions operate on angles in radians. Also,
118  // we're only interested in half the viewing angle.
119  float fovx = atan(screen->getViewRatio() * tan(fovy * M_PI / 360.0)) * 360.0 / M_PI;
120  grContext.setFOV(fovx, fovy);
121  grContext.setNearFar(fnear, ffar);
122 }
123 
125 {
126  sgMat4 mat;
127  grMakeLookAtMat4(mat, eye, center, up);
128 
129  grContext.setCamera(mat);
130 }
131 
133 {
134  const int BUFSIZE=1024;
135  char path[BUFSIZE];
136 
137  snprintf(path, BUFSIZE, "%s/%d", GR_SCT_DISPMODE, screen->getId());
138  fovy = (float)GfParmGetNum(grHandle, path, attr, (char*)NULL, fovydflt);
139  limitFov();
140 }
141 
142 
143 /* Give the height in pixels of 1 m high object on the screen at this point */
144 float cGrPerspCamera::getLODFactor(float x, float y, float z) {
145  tdble dx, dy, dz, dd;
146  float ang;
147  int scrh, dummy;
148  float res;
149 
150  dx = x - eye[0];
151  dy = y - eye[1];
152  dz = z - eye[2];
153 
154  dd = sqrt(dx*dx+dy*dy+dz*dz);
155 
156  ang = DEG2RAD(fovy / 2.0);
157  GfScrGetSize(&dummy, &scrh, &dummy, &dummy);
158 
159  res = (float)scrh / 2.0 / dd / tan(ang);
160  if (res < 0) {
161  res = 0;
162  }
163  return res;
164 }
165 
167 {
168  const int BUFSIZE=256;
169  char buf[BUFSIZE];
170  const int PATHSIZE=1024;
171  char path[PATHSIZE];
172 
173 
174  switch(cmd) {
175  case GR_ZOOM_IN:
176  if (fovy > 2) {
177  fovy--;
178  } else {
179  fovy /= 2.0;
180  }
181  if (fovy < fovymin) {
182  fovy = fovymin;
183  }
184  break;
185 
186  case GR_ZOOM_OUT:
187  fovy++;
188  if (fovy > fovymax) {
189  fovy = fovymax;
190  }
191  break;
192 
193  case GR_ZOOM_MAX:
194  fovy = fovymax;
195  break;
196 
197  case GR_ZOOM_MIN:
198  fovy = fovymin;
199  break;
200 
201  case GR_ZOOM_DFLT:
202  fovy = fovydflt;
203  break;
204  }
205 
206  limitFov();
207 
208  snprintf(buf, BUFSIZE, "%s-%d-%d", GR_ATT_FOVY, screen->getCurCamHead(), getId());
209  snprintf(path, PATHSIZE, "%s/%d", GR_SCT_DISPMODE, screen->getId());
210  GfParmSetNum(grHandle, path, buf, (char*)NULL, (tdble)fovy);
211  GfParmWriteFile(NULL, grHandle, "Graph");
212 }
213 
215 {
216  glMatrixMode(GL_PROJECTION);
217  glLoadIdentity();
218  gluOrtho2D(left, right, bottom, top);
219 }
220 
222 {
223  glMatrixMode(GL_MODELVIEW);
224  glLoadIdentity();
225 }
226 
228 {
229  static float BACKGROUND_FOVY_CUTOFF = 60.0f;
230  memcpy(&eye, curCam->getPosv(), sizeof(eye));
231  memcpy(&center, curCam->getCenterv(), sizeof(center));
232  sgSubVec3(center, center, eye);
233  sgSetVec3(eye, 0, 0, 0);
234  speed[0]=0.0;
235  speed[1]=0.0;
236  speed[2]=0.0;
237  fovy = curCam->getFovY();
238  if (fovy < BACKGROUND_FOVY_CUTOFF) {
239  fovy = BACKGROUND_FOVY_CUTOFF;
240  }
241  memcpy(&up, curCam->getUpv(), sizeof(up));
242 }
243 
244 
245 
247 {
248  public:
249  cGrCarCamInside(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
250  float myfovy, float myfovymin, float myfovymax,
251  float myfnear, float myffar = 1500.0,
252  float myfogstart = 800.0, float myfogend = 1500.0)
253  : cGrPerspCamera(myscreen, id, drawCurr, 0, drawBG, 1,
254  myfovy, myfovymin, myfovymax,
255  myfnear, myffar, myfogstart, myfogend) {
256  up[0] = 0;
257  up[1] = 0;
258  up[2] = 1;
259  }
260 
261  void update(tCarElt *car, tSituation *s) {
262  sgVec3 P, p;
263 
264  p[0] = car->_drvPos_x;
265  p[1] = car->_drvPos_y;
266  p[2] = car->_drvPos_z;
267  sgXformPnt3(p, car->_posMat);
268 
269  eye[0] = p[0];
270  eye[1] = p[1];
271  eye[2] = p[2];
272 
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);
277 
278  center[0] = P[0];
279  center[1] = P[1];
280  center[2] = P[2];
281 
282  speed[0] =car->pub.DynGCg.vel.x;
283  speed[1] =car->pub.DynGCg.vel.y;
284  speed[2] =car->pub.DynGCg.vel.z;
285  }
286 };
287 
288 
289 /* MIRROR */
291 {
292  glDeleteTextures (1, &tex);
293  delete viewCam;
294 }
295 
296 
298  fovy = 90.0 / screen->getViewRatio();
299 }
300 
301 
303 {
304  sgVec3 P, p;
305 
306  P[0] = car->_bonnetPos_x;
307  P[1] = car->_bonnetPos_y;
308  P[2] = car->_bonnetPos_z;
309  sgXformPnt3(P, car->_posMat);
310 
311  eye[0] = P[0];
312  eye[1] = P[1];
313  eye[2] = P[2];
314 
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);
319 
320  center[0] = p[0];
321  center[1] = p[1];
322  center[2] = p[2];
323 
324  up[0] = car->_posMat[2][0];
325  up[1] = car->_posMat[2][1];
326  up[2] = car->_posMat[2][2];
327 }
328 
329 
330 void cGrCarCamMirror::setViewport(int x, int y, int w, int h)
331 {
332  vpx = x;
333  vpy = y;
334  vpw = w;
335  vph = h;
336 
337  if (viewCam) {
338  delete viewCam;
339  }
340  viewCam = new cGrOrthoCamera(screen, x, x + w, y, y + h);
341  limitFov();
342 }
343 
344 
345 void cGrCarCamMirror::setPos (int x, int y, int w, int h)
346 {
347  mx = x;
348  my = y;
349  mw = w;
350  mh = h;
351 
352  // round up texture size to next power of two
353  tw = GfNearestPow2(w);
354  th = GfNearestPow2(h);
355  if (tw < w) {
356  tw *= 2;
357  }
358  if (th < h) {
359  th *= 2;
360  }
361 
362  // Create texture object.
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);
367 
368  glCopyTexImage2D(GL_TEXTURE_2D,
369  0, // map level,
370  GL_RGB, // internal format,
371  0, 0, tw, th,
372  0 ); // border
373 
374  tsu = (float) mw / tw;
375  teu = 0.0;
376  tsv = 0.0;
377  tev = (float) mh / th;
378 }
379 
380 
382 {
383  glViewport(vpx, vpy, vpw, vph);
384 
385  // Enable scissor test to conserve graphics memory bandwidth.
386  glEnable(GL_SCISSOR_TEST);
387  glScissor(vpx + (vpw - mw)/2, vpy + (vph - mh)/2, mw, mh);
388 }
389 
391 {
392  glDisable(GL_SCISSOR_TEST);
393 
394  glBindTexture(GL_TEXTURE_2D, tex);
395  glReadBuffer(GL_BACK);
396 
397  // NVidia recommends to NOT use glCopyTexImage2D for performance reasons.
398  glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
399  vpx + (vpw - mw)/2,
400  vpy + (vph - mh)/2, mw, mh);
401 }
402 
403 
405 {
406  viewCam->action ();
407 
408  glBindTexture (GL_TEXTURE_2D, tex);
409  glBegin(GL_TRIANGLE_STRIP);
410  {
411  glColor4f(1.0, 1.0, 1.0, 1.0);
412  glTexCoord2f(tsu, tsv); glVertex2f(mx, my);
413  glTexCoord2f(tsu, tev); glVertex2f(mx, my + mh);
414  glTexCoord2f(teu, tsv); glVertex2f(mx + mw, my);
415  glTexCoord2f(teu, tev); glVertex2f(mx + mw, my + mh);
416  }
417  glEnd();
418 }
419 
420 
421 
422 
424 {
425  public:
426  cGrCarCamInsideFixedCar(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
427  float myfovy, float myfovymin, float myfovymax,
428  float myfnear, float myffar = 1500.0,
429  float myfogstart = 1400.0, float myfogend = 1500.0)
430  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 1,
431  myfovy, myfovymin, myfovymax,
432  myfnear, myffar, myfogstart, myfogend) {
433  }
434 
435  void update(tCarElt *car, tSituation *s) {
436  sgVec3 P, p;
437 
438  p[0] = car->_bonnetPos_x;
439  p[1] = car->_bonnetPos_y;
440  p[2] = car->_bonnetPos_z;
441  sgXformPnt3(p, car->_posMat);
442 
443  eye[0] = p[0];
444  eye[1] = p[1];
445  eye[2] = p[2];
446 
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);
451 
452  center[0] = P[0];
453  center[1] = P[1];
454  center[2] = P[2];
455 
456  up[0] = car->_posMat[2][0];
457  up[1] = car->_posMat[2][1];
458  up[2] = car->_posMat[2][2];
459 
460  speed[0] =car->pub.DynGCg.vel.x;
461  speed[1] =car->pub.DynGCg.vel.y;
462  speed[2] =car->pub.DynGCg.vel.z;
463  }
464 };
465 
466 
468 {
470 
471  protected:
472  float dist;
473  float height;
474 
475  public:
476  cGrCarCamBehind(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
477  float fovy, float fovymin, float fovymax,
478  float mydist, float myHeight, float fnear, float ffar = 1500.0,
479  float myfogstart = 1400.0, float myfogend = 1500.0)
480  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
481  fovymax, fnear, ffar, myfogstart, myfogend) {
482  dist = mydist;
483  height = myHeight;
484  PreA = 0.0;
485  up[0] = 0;
486  up[1] = 0;
487  up[2] = 1;
488  }
489 
490  void update(tCarElt *car, tSituation *s) {
491  tdble A;
492  tdble CosA;
493  tdble SinA;
494  tdble x;
495  tdble y;
496 
497  A = car->_yaw;
498  if (fabs(PreA - A) > fabs(PreA - A + 2*PI)) {
499  PreA += 2*PI;
500  } else if (fabs(PreA - A) > fabs(PreA - A - 2*PI)) {
501  PreA -= 2*PI;
502  }
503  RELAXATION(A, PreA, 10.0);
504  CosA = cos(A);
505  SinA = sin(A);
506  x = car->_pos_X - dist * CosA;
507  y = car->_pos_Y - dist * SinA;
508 
509  eye[0] = x;
510  eye[1] = y;
511  eye[2] = RtTrackHeightG(car->_trkPos.seg, x, y) + height;
512  center[0] = car->_pos_X + (10 - dist) * CosA;
513  center[1] = car->_pos_Y + (10 - dist) * SinA;
514  center[2] = car->_pos_Z;
515 
516  speed[0] = car->pub.DynGCg.vel.x;
517  speed[1] = car->pub.DynGCg.vel.y;
518  speed[2] = car->pub.DynGCg.vel.z;
519 
520  }
521 };
522 
523 
525 {
527 
528  protected:
529  float dist;
530 
531  public:
532  cGrCarCamBehind2(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
533  float fovy, float fovymin, float fovymax,
534  float mydist, float fnear, float ffar = 1500.0,
535  float myfogstart = 1400.0, float myfogend = 1500.0)
536  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
537  fovymax, fnear, ffar, myfogstart, myfogend) {
538  dist = mydist;
539  PreA = 0.0;
540  up[0] = 0;
541  up[1] = 0;
542  up[2] = 1;
543  }
544 
545  void update(tCarElt *car, tSituation *s) {
546  tdble A;
547  tdble CosA;
548  tdble SinA;
549  tdble x;
550  tdble y;
551 
552  A = RtTrackSideTgAngleL(&(car->_trkPos));
553  if (fabs(PreA - A) > fabs(PreA - A + 2*PI)) {
554  PreA += 2*PI;
555  } else if (fabs(PreA - A) > fabs(PreA - A - 2*PI)) {
556  PreA -= 2*PI;
557  }
558  RELAXATION(A, PreA, 5.0);
559  CosA = cos(A);
560  SinA = sin(A);
561  x = car->_pos_X - dist * CosA;
562  y = car->_pos_Y - dist * SinA;
563 
564  eye[0] = x;
565  eye[1] = y;
566  eye[2] = RtTrackHeightG(car->_trkPos.seg, x, y) + 5.0;
567  center[0] = car->_pos_X;
568  center[1] = car->_pos_Y;
569  center[2] = car->_pos_Z;
570 
571 
572  speed[0] = car->pub.DynGCg.vel.x;
573  speed[1] = car->pub.DynGCg.vel.y;
574  speed[2] = car->pub.DynGCg.vel.z;
575 
576  }
577 };
578 
579 
581 {
582  protected:
583  float dist;
584 
585  public:
586  cGrCarCamFront(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
587  float fovy, float fovymin, float fovymax,
588  float mydist, float fnear, float ffar = 1500.0,
589  float myfogstart = 1400.0, float myfogend = 1500.0)
590  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
591  fovymax, fnear, ffar, myfogstart, myfogend) {
592  dist = mydist;
593  up[0] = 0;
594  up[1] = 0;
595  up[2] = 1;
596  }
597 
598  void update(tCarElt *car, tSituation *s) {
599  tdble CosA = cos(car->_yaw);
600  tdble SinA = sin(car->_yaw);
601  tdble x = car->_pos_X + dist * CosA;
602  tdble y = car->_pos_Y + dist * SinA;
603 
604  eye[0] = x;
605  eye[1] = y;
606  eye[2] = RtTrackHeightG(car->_trkPos.seg, x, y) + 0.5;
607  center[0] = car->_pos_X;
608  center[1] = car->_pos_Y;
609  center[2] = car->_pos_Z;
610 
611  speed[0] = car->pub.DynGCg.vel.x;
612  speed[1] = car->pub.DynGCg.vel.y;
613  speed[2] = car->pub.DynGCg.vel.z;
614 
615  }
616 };
617 
618 
620 {
621 protected:
622  float distx;
623  float disty;
624  float distz;
625 
626  public:
627  cGrCarCamSide(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
628  float fovy, float fovymin, float fovymax,
629  float mydistx, float mydisty, float mydistz,
630  float fnear, float ffar = 1500.0,
631  float myfogstart = 1400.0, float myfogend = 1500.0)
632  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
633  fovymax, fnear, ffar, myfogstart, myfogend) {
634  distx = mydistx;
635  disty = mydisty;
636  distz = mydistz;
637 
638  up[0] = 0;
639  up[1] = 0;
640  up[2] = 1;
641  }
642 
643  void update(tCarElt *car, tSituation *s) {
644  tdble x = car->_pos_X + distx;
645  tdble y = car->_pos_Y + disty;
646  tdble z = car->_pos_Z + distz;
647 
648  eye[0] = x;
649  eye[1] = y;
650  eye[2] = z;
651  center[0] = car->_pos_X;
652  center[1] = car->_pos_Y;
653  center[2] = car->_pos_Z;
654 
655  speed[0] = car->pub.DynGCg.vel.x;
656  speed[1] = car->pub.DynGCg.vel.y;
657  speed[2] = car->pub.DynGCg.vel.z;
658 
659  }
660 };
661 
663 {
664  protected:
665  float distz;
666 
667  public:
668  cGrCarCamUp(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
669  float fovy, float fovymin, float fovymax,
670  float mydistz, int axis,
671  float fnear, float ffar = 1500.0,
672  float myfogstart = 1600.0, float myfogend = 1700.0)
673  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
674  fovymax, fnear, ffar, myfogstart, myfogend) {
675  distz = mydistz;
676  up[2] = 0;
677  switch (axis) {
678  case 0:
679  up[0] = 0;
680  up[1] = 1;
681  break;
682  case 1:
683  up[0] = 0;
684  up[1] = -1;
685  break;
686  case 2:
687  up[0] = 1;
688  up[1] = 0;
689  break;
690  case 3:
691  up[0] = -1;
692  up[1] = 0;
693  break;
694  default:
695  up[0] = 0;
696  up[1] = 1;
697  break;
698  }
699  }
700 
701  void update(tCarElt *car, tSituation *s) {
702  tdble x = car->_pos_X;
703  tdble y = car->_pos_Y;
704  tdble z = car->_pos_Z + distz;
705 
706  eye[0] = x;
707  eye[1] = y;
708  eye[2] = z;
709  center[0] = x;
710  center[1] = y;
711  center[2] = car->_pos_Z;
712 
713 
714  speed[0] = car->pub.DynGCg.vel.x;
715  speed[1] = car->pub.DynGCg.vel.y;
716  speed[2] = car->pub.DynGCg.vel.z;
717 
718  }
719 };
720 
722 {
723  protected:
724  float distz;
725  float locfar;
726  float locfovy;
727 
728  public:
729  cGrCarCamCenter(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
730  float fovy, float fovymin, float fovymax,
731  float mydistz,
732  float fnear, float ffar = 1500.0,
733  float myfogstart = 1400.0, float myfogend = 1500.0)
734  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
735  fovymax, fnear, ffar, myfogstart, myfogend) {
736  distz = mydistz;
737  locfar = ffar;
738  locfovy = fovy;
739 
740  eye[0] = grWrldX * 0.5;
741  eye[1] = grWrldY * 0.6;
742  eye[2] = distz;
743 
744  up[0] = 0;
745  up[1] = 0;
746  up[2] = 1;
747  }
748 
749  void loadDefaults(char *attr) {
750  const int PATHSIZE=1024;
751  char path[PATHSIZE];
752 
753  snprintf(path, PATHSIZE, "%s/%d", GR_SCT_DISPMODE, screen->getId());
754  locfovy = (float)GfParmGetNum(grHandle, path, attr, (char*)NULL, fovydflt);
755  }
756 
757  void setZoom(int cmd) {
758  fovy = locfovy;
760  locfovy = fovy;
761  }
762 
763  void update(tCarElt *car, tSituation *s) {
764  tdble dx, dy, dz, dd;
765 
766  center[0] = car->_pos_X;
767  center[1] = car->_pos_Y;
768  center[2] = car->_pos_Z;
769 
770  dx = center[0] - eye[0];
771  dy = center[1] - eye[1];
772  dz = center[2] - eye[2];
773 
774  dd = sqrt(dx*dx+dy*dy+dz*dz);
775 
776  fnear = dz - 5;
777  if (fnear < 1) {
778  fnear = 1;
779  }
780  ffar = dd + locfar;
781 
782  fovy = RAD2DEG(atan2(locfovy, dd));
783 
784  speed[0] = 0;
785  speed[1] = 0;
786  speed[2] = 0;
787 
788  }
789 };
790 
792 {
793  protected:
794 
795  public:
796  cGrCarCamLookAt(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
797  float fovy, float fovymin, float fovymax,
798  int axis,
799  float eyex, float eyey, float eyez,
800  float centerx, float centery, float centerz,
801  float fnear, float ffar = 1500.0,
802  float myfogstart = 1600.0, float myfogend = 1700.0)
803  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
804  fovymax, fnear, ffar, myfogstart, myfogend) {
805 
806  eye[0] = eyex;
807  eye[1] = eyey;
808  eye[2] = eyez;
809 
810  center[0] = centerx;
811  center[1] = centery;
812  center[2] = centerz;
813 
814  switch (axis) {
815  case 0:
816  up[0] = 0;
817  up[1] = 1;
818  up[2] = 0;
819  break;
820  case 1:
821  up[0] = 0;
822  up[1] = -1;
823  up[2] = 0;
824  break;
825  case 2:
826  up[0] = 1;
827  up[1] = 0;
828  up[2] = 0;
829  break;
830  case 3:
831  up[0] = -1;
832  up[1] = 0;
833  up[2] = 0;
834  break;
835  case 4:
836  up[0] = 0;
837  up[1] = 0;
838  up[2] = 1;
839  break;
840  case 5:
841  up[0] = 0;
842  up[1] = 0;
843  up[2] = -1;
844  break;
845  default:
846  up[0] = 0;
847  up[1] = 0;
848  up[2] = 1;
849  break;
850  }
851  }
852 
853  void update(tCarElt *car, tSituation *s) {
854  }
855 };
856 
857 
859 {
860  protected:
861 
862  public:
863  cGrCarCamRoadNoZoom(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
864  float fovy, float fovymin, float fovymax,
865  float fnear, float ffar = 1500.0,
866  float myfogstart = 1400.0, float myfogend = 1500.0)
867  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
868  fovymax, fnear, ffar, myfogstart, myfogend) {
869  up[0] = 0;
870  up[1] = 0;
871  up[2] = 1;
872  }
873 
874  void update(tCarElt *car, tSituation *s) {
875  tRoadCam *curCam;
876 
877 
878  curCam = car->_trkPos.seg->cam;
879 
880  if (curCam == NULL) {
881  eye[0] = grWrldX * 0.5;
882  eye[1] = grWrldY * 0.6;
883  eye[2] = 120;
884  center[2] = car->_pos_Z;
885  } else {
886  eye[0] = curCam->pos.x;
887  eye[1] = curCam->pos.y;
888  eye[2] = curCam->pos.z;
889  center[2] = curCam->pos.z;
890  }
891 
892  center[0] = car->_pos_X;
893  center[1] = car->_pos_Y;
894  /* center[2] = car->_pos_Z; */
895 
896  speed[0] = 0.0;
897  speed[1] = 0.0;
898  speed[2] = 0.0;
899  }
900 };
901 
903 {
904  protected:
905  int current;
906  float timer;
907  float zOffset;
908  float gain;
909  float damp;
910  float offset[3];
911  double currenttime;
912  public:
913  cGrCarCamRoadFly(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
914  float fovy, float fovymin, float fovymax,
915  float fnear, float ffar = 1500.0,
916  float myfogstart = 1400.0, float myfogend = 1500.0)
917  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
918  fovymax, fnear, ffar, myfogstart, myfogend) {
919  up[0] = 0;
920  up[1] = 0;
921  up[2] = 1;
922  timer = 0.0;
923  offset[0]=0.0;
924  offset[1]=0.0;
925  offset[2]=60.0;
926  current = -1;
927  currenttime = 0.0;
928  speed[0] = 0.0;
929  speed[1] = 0.0;
930  speed[2] = 0.0;
931  }
932 
933  void update(tCarElt *car, tSituation *s) {
934  //tRoadCam *curCam;
935  float height;
936  float dt;
937 
938  //curCam = car->_trkPos.seg->cam;
939 
940  if (currenttime == 0.0) {
942  }
943 
944  if (currenttime == s->currentTime) {
945  return;
946  }
947 
948  bool reset_camera = false;
949  dt = s->currentTime - currenttime;
951  if (fabs(dt) > 1.0f) {
952  dt = 0.1f; // avoid overflow
953  reset_camera = true;
954  }
955 
956  //timer--;
957  if (timer<0.0) {
958  reset_camera = true;
959  } else {
960  timer -= dt;
961  }
962 
963  if (current != car->index) {
964  /* the target car changed */
965  zOffset = 50.0;
966  current = car->index;
967  reset_camera = true;
968  } else {
969  zOffset = 0.0;
970  }
971 
972  if ((timer <= 0.0) || (zOffset > 0.0)) {
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));
976  offset[2] = 10.0f + (50.0*rand()/(RAND_MAX+1.0)) + zOffset;
977  offset[0] = offset[0]*(offset[2]+1.0);
978  offset[1] = offset[1]*(offset[2]+1.0);
979  // follow the car more closely when low
980  gain = 200.0/(10.0f+offset[2]);
981  damp = 5.0f;
982  }
983 
984 
985  if (reset_camera) {
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));
989  speed[0] = speed[1] = speed[2] = 0.0f;
990  }
991 
992  speed[0] += (gain*(offset[0]+car->_pos_X - eye[0]) - speed[0]*damp)*dt;
993  speed[1] += (gain*(offset[1]+car->_pos_Y - eye[1]) - speed[1]*damp)*dt;
994  speed[2] += (gain*(offset[2]+car->_pos_Z - eye[2]) - speed[2]*damp)*dt;
995 
996  eye[0] = eye[0] + speed[0]*dt;
997  eye[1] = eye[1] + speed[1]*dt;
998  eye[2] = eye[2] + speed[2]*dt;
999 
1000  center[0] = (car->_pos_X);
1001  center[1] = (car->_pos_Y);
1002  center[2] = (car->_pos_Z);
1003 
1004  // avoid going under the scene
1005  height = grGetHOT(eye[0], eye[1]) + 1.0;
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;
1009  eye[2] = height;
1010  }
1011 
1012  }
1013 
1014 
1015 
1016  void onSelect(tCarElt *car, tSituation *s)
1017  {
1018  timer = 0;
1019  current = -1;
1020  }
1021 
1022 };
1023 
1025 {
1026  protected:
1027  float locfar;
1028  float locfovy;
1029 
1030  public:
1031  cGrCarCamRoadZoom(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
1032  float fovy, float fovymin, float fovymax,
1033  float fnear, float ffar = 1500.0,
1034  float myfogstart = 1400.0, float myfogend = 1500.0)
1035  : cGrPerspCamera(myscreen, id, drawCurr, 1, drawBG, 0, fovy, fovymin,
1036  fovymax, fnear, ffar, myfogstart, myfogend) {
1037  locfar = ffar;
1038  locfovy = fovy;
1039 
1040  up[0] = 0;
1041  up[1] = 0;
1042  up[2] = 1;
1043  }
1044 
1045  void loadDefaults(char *attr) {
1046 
1047  const int PATHSIZE=1024;
1048  char path[PATHSIZE];
1049 
1050  snprintf(path, PATHSIZE, "%s/%d", GR_SCT_DISPMODE, screen->getId());
1051  locfovy = (float)GfParmGetNum(grHandle, path,
1052  attr, (char*)NULL, fovydflt);
1053  }
1054 
1055  void setZoom(int cmd) {
1056  fovy = locfovy;
1058  locfovy = fovy;
1059  }
1060 
1061  void update(tCarElt *car, tSituation *s) {
1062  tdble dx, dy, dz, dd;
1063  tRoadCam *curCam;
1064 
1065  curCam = car->_trkPos.seg->cam;
1066 
1067  if (curCam == NULL) {
1068  eye[0] = grWrldX * 0.5;
1069  eye[1] = grWrldY * 0.6;
1070  eye[2] = 120;
1071  } else {
1072  eye[0] = curCam->pos.x;
1073  eye[1] = curCam->pos.y;
1074  eye[2] = curCam->pos.z;
1075  }
1076 
1077  center[0] = car->_pos_X;
1078  center[1] = car->_pos_Y;
1079  center[2] = car->_pos_Z;
1080 
1081  dx = center[0] - eye[0];
1082  dy = center[1] - eye[1];
1083  dz = center[2] - eye[2];
1084 
1085  dd = sqrt(dx*dx+dy*dy+dz*dz);
1086 
1087  fnear = dz - 5;
1088  if (fnear < 1) {
1089  fnear = 1;
1090  }
1091  ffar = dd + locfar;
1092  fovy = RAD2DEG(atan2(locfovy, dd));
1093  limitFov();
1094 
1095  speed[0] = 0.0;
1096  speed[1] = 0.0;
1097  speed[2] = 0.0;
1098  }
1099 };
1100 
1101 static tdble
1103 {
1104  tTrackSeg *seg;
1105  tdble lg;
1106 
1107  seg = car->_trkPos.seg;
1108  lg = seg->lgfromstart;
1109 
1110  switch (seg->type) {
1111  case TR_STR:
1112  lg += car->_trkPos.toStart;
1113  break;
1114  default:
1115  lg += car->_trkPos.toStart * seg->radius;
1116  break;
1117  }
1118  return lg;
1119 }
1120 
1121 typedef struct
1122 {
1123  double prio;
1125  int event;
1126 } tSchedView;
1127 
1129 {
1136  int current;
1137 
1138  public:
1139  cGrCarCamRoadZoomTVD(class cGrScreen *myscreen, int id, int drawCurr, int drawBG,
1140  float fovy, float fovymin, float fovymax,
1141  float fnear, float ffar = 1500.0,
1142  float myfogstart = 1400.0, float myfogend = 1500.0)
1143  : cGrCarCamRoadZoom(myscreen, id, drawCurr, drawBG, fovy, fovymin,
1144  fovymax, fnear, ffar, myfogstart, myfogend) {
1145  schedView = (tSchedView *)calloc(grNbCars, sizeof(tSchedView));
1146  if (!schedView) {
1147  GfTrace("malloc error");
1148  GfScrShutdown();
1149  exit (1);
1150  }
1151 
1152  lastEventTime = 0;
1153  lastViewTime = 0;
1154 
1155  current = -1;
1156 
1160  }
1161 
1163 
1164  void update(tCarElt *car, tSituation *s) {
1165  int i, j;
1166  int curCar;
1167  double curPrio;
1168  double deltaEventTime = s->currentTime - lastEventTime;
1169  double deltaViewTime = s->currentTime - lastViewTime;
1170  int event = 0;
1171 
1172  if (current == -1) {
1173  current = 0;
1174  for (i = 0; i < grNbCars; i++) {
1175  if (car == s->cars[i]) {
1176  current = i;
1177  break;
1178  }
1179  }
1180  }
1181 
1182 
1183  /* Track events */
1184  if (deltaEventTime > camEventInterval) {
1185 
1186  memset(schedView, 0, grNbCars * sizeof(tSchedView));
1187  for (i = 0; i < grNbCars; i++) {
1188  schedView[i].viewable = 1;
1189  }
1190 
1191  for (i = 0; i < GR_NB_MAX_SCREEN; i++) {
1192  if ((screen != grScreens[i]) && grScreens[i]->isActive()) {
1193  car = grScreens[i]->getCurrentCar();
1194  schedView[car->index].viewable = 0;
1195  schedView[car->index].prio -= 10000;
1196  }
1197  }
1198 
1199  for (i = 0; i < grNbCars; i++) {
1200  tdble dist, fs;
1201 
1202  car = s->cars[i];
1203  schedView[car->index].prio += grNbCars - i;
1204  fs = GetDistToStart(car);
1205  if ((car->_state & RM_CAR_STATE_NO_SIMU) != 0) {
1206  schedView[car->index].viewable = 0;
1207  } else {
1208  if ((fs > (grTrack->length - 200.0)) && (car->_remainingLaps == 0)) {
1209  schedView[car->index].prio += 5 * grNbCars;
1210  event = 1;
1211  }
1212  }
1213 
1214  if ((car->_state & RM_CAR_STATE_NO_SIMU) == 0) {
1215  dist = fabs(car->_trkPos.toMiddle) - grTrack->width / 2.0;
1216  /* out of track */
1217  if (dist > 0) {
1218  schedView[car->index].prio += grNbCars;
1219  if (car->ctrl.raceCmd & RM_CMD_PIT_ASKED) {
1220  schedView[car->index].prio += grNbCars;
1221  event = 1;
1222  }
1223  }
1224 
1225  for (j = i+1; j < grNbCars; j++) {
1226  tCarElt *car2 = s->cars[j];
1227  tdble fs2 = GetDistToStart(car2);
1228  tdble d = fabs(fs2 - fs);
1229 
1230  if ((car2->_state & RM_CAR_STATE_NO_SIMU) == 0) {
1231  if (d < proximityThld) {
1232  d = proximityThld - d;
1233  schedView[car->index].prio += d * grNbCars / proximityThld;
1234  schedView[car2->index].prio += d * (grNbCars - 1) / proximityThld;
1235  if (i == 0) {
1236  event = 1;
1237  }
1238  }
1239  }
1240  }
1241 
1242  if (car->priv.collision) {
1243  schedView[car->index].prio += grNbCars;
1244  event = 1;
1245  }
1246  } else {
1247  if (i == current) {
1248  event = 1; /* update view */
1249  }
1250  }
1251  }
1252 
1253 
1254  /* change current car */
1255  if ((event && (deltaEventTime > camEventInterval)) || (deltaViewTime > camChangeInterval)) {
1256  int last_current = current;
1257 
1258  curCar = 0;
1259  curPrio = -1000000.0;
1260  for (i = 0; i < grNbCars; i++) {
1261 
1262  if ((schedView[i].prio > curPrio) && (schedView[i].viewable)) {
1263  curPrio = schedView[i].prio;
1264  curCar = i;
1265  }
1266  }
1267  for (i = 0; i < grNbCars; i++) {
1268  if (s->cars[i]->index == curCar) {
1269  current = i;
1270  break;
1271  }
1272  }
1273  if (last_current != current) {
1276 
1277  for (i = 0; i < grNbCars; i++) {
1278  s->cars[i]->priv.collision = 0;
1279  }
1280  }
1281  }
1282  }
1283 
1285 
1287  }
1288 };
1289 
1290 
1291 void
1292 grCamCreateSceneCameraList(class cGrScreen *myscreen, tGrCamHead *cams, tdble fovFactor)
1293 {
1294  int id;
1295  int c;
1296  class cGrCamera *cam;
1297 
1298  /* Scene Cameras */
1299  c = 0;
1300 
1301  /* F2 */
1302  GF_TAILQ_INIT(&cams[c]);
1303  id = 0;
1304 
1305  /* cam F2 = behind very near */
1306  cam = new cGrCarCamBehind(myscreen,
1307  id,
1308  1, /* drawCurr */
1309  1, /* drawBG */
1310  40.0, /* fovy */
1311  5.0, /* fovymin */
1312  95.0, /* fovymax */
1313  6.0, /* dist */
1314  2.0, /* height */
1315  1.0, /* near */
1316  600.0 * fovFactor, /* far */
1317  300.0 * fovFactor, /* fog */
1318  600.0 * fovFactor /* fog */
1319  );
1320  cam->add(&cams[c]);
1321  id++;
1322 
1323  /* cam F2 = behind near */
1324  cam = new cGrCarCamBehind(myscreen,
1325  id,
1326  1, /* drawCurr */
1327  1, /* drawBG */
1328  40.0, /* fovy */
1329  5.0, /* fovymin */
1330  95.0, /* fovymax */
1331  10.0, /* dist */
1332  2.0, /* height */
1333  1.0, /* near */
1334  600.0 * fovFactor, /* far */
1335  300.0 * fovFactor, /* fog */
1336  600.0 * fovFactor /* fog */
1337  );
1338  cam->add(&cams[c]);
1339  id++;
1340 
1341  /* cam F2 = car inside with car (bonnet view) fixed to the car */
1342  cam = new cGrCarCamInsideFixedCar(myscreen,
1343  id,
1344  1, /* drawCurr */
1345  1, /* drawBG */
1346  67.5, /* fovy */
1347  50.0, /* fovymin */
1348  95.0, /* fovymax */
1349  0.3, /* near */
1350  600.0 * fovFactor, /* far */
1351  300.0 * fovFactor, /* fog */
1352  600.0 * fovFactor /* fog */
1353  );
1354  cam->add(&cams[c]);
1355  id++;
1356 
1357  /* cam F2 = car inside with car (bonnet view) */
1358  cam = new cGrCarCamInside(myscreen,
1359  id,
1360  1, /* drawCurr */
1361  1, /* drawBG */
1362  67.5, /* fovy */
1363  50.0, /* fovymin */
1364  95.0, /* fovymax */
1365  0.1, /* near */
1366  600.0 * fovFactor, /* far */
1367  300.0 * fovFactor, /* fog */
1368  600.0 * fovFactor /* fog */
1369  );
1370  cam->add(&cams[c]);
1371  id++;
1372 
1373  /* cam F2 = car inside car (no car - road view) */
1374  cam = new cGrCarCamInsideFixedCar(myscreen,
1375  id,
1376  0, /* drawCurr */
1377  1, /* drawBG */
1378  67.5, /* fovy */
1379  50.0, /* fovymin */
1380  95.0, /* fovymax */
1381  0.3, /* near */
1382  600.0 * fovFactor, /* far */
1383  300.0 * fovFactor, /* fog */
1384  600.0 * fovFactor /* fog */
1385  );
1386  cam->add(&cams[c]);
1387 
1388  /* F3 */
1389  c++;
1390  GF_TAILQ_INIT(&cams[c]);
1391  id = 0;
1392 
1393  /* cam F3 = behind far */
1394  cam = new cGrCarCamBehind(myscreen,
1395  id,
1396  1, /* drawCurr */
1397  1, /* drawBG */
1398  40.0, /* fovy */
1399  5.0, /* fovymin */
1400  95.0, /* fovymax */
1401  20.0, /* dist */
1402  2.0, /* height */
1403  1.0, /* near */
1404  600.0 * fovFactor, /* far */
1405  300.0 * fovFactor, /* fog */
1406  600.0 * fovFactor /* fog */
1407  );
1408  cam->add(&cams[c]);
1409  id++;
1410 
1411  /* cam F3 = car behind*/
1412  cam = new cGrCarCamBehind2(myscreen,
1413  id,
1414  1, /* drawCurr */
1415  1, /* drawBG */
1416  40.0, /* fovy */
1417  5.0, /* fovymin */
1418  95.0, /* fovymax */
1419  30.0, /* dist */
1420  1.0, /* near */
1421  1000.0 * fovFactor, /* far */
1422  500.0 * fovFactor, /* fog */
1423  1000.0 * fovFactor /* fog */
1424  );
1425  cam->add(&cams[c]);
1426  id++;
1427 
1428  /* cam F3 = car behind*/
1429  cam = new cGrCarCamBehind(myscreen,
1430  id,
1431  1, /* drawCurr */
1432  1, /* drawBG */
1433  40.0, /* fovy */
1434  5.0, /* fovymin */
1435  95.0, /* fovymax */
1436  8.0, /* dist */
1437  .50, /* height */
1438  .50, /* near */
1439  600.0 * fovFactor, /* far */
1440  300.0 * fovFactor, /* fog */
1441  600.0 * fovFactor /* fog */
1442  );
1443  cam->add(&cams[c]);
1444  id++;
1445 
1446  /* cam F3 = car reverse*/
1447  cam = new cGrCarCamFront(myscreen,
1448  id,
1449  1, /* drawCurr */
1450  1, /* drawBG */
1451  40.0, /* fovy */
1452  5.0, /* fovymin */
1453  95.0, /* fovymax */
1454  8.0, /* dist */
1455  0.5, /* near */
1456  1000.0 * fovFactor, /* far */
1457  500.0 * fovFactor, /* fog */
1458  1000.0 * fovFactor /* fog */
1459  );
1460  cam->add(&cams[c]);
1461 
1462  /* F4 */
1463  c++;
1464  GF_TAILQ_INIT(&cams[c]);
1465  id = 0;
1466 
1467  /* cam F4 = car side 1*/
1468  cam = new cGrCarCamSide(myscreen,
1469  id,
1470  1, /* drawCurr */
1471  1, /* drawBG */
1472  30.0, /* fovy */
1473  5.0, /* fovymin */
1474  60.0, /* fovymax */
1475  0.0, /* distx */
1476  -20.0, /* disty */
1477  3.0, /* distz */
1478  1.0, /* near */
1479  1000.0 * fovFactor, /* far */
1480  500.0 * fovFactor, /* fog */
1481  1000.0 * fovFactor /* fog */
1482  );
1483  cam->add(&cams[c]);
1484  id++;
1485 
1486  /* cam F4 = car side 2*/
1487  cam = new cGrCarCamSide(myscreen,
1488  id,
1489  1, /* drawCurr */
1490  1, /* drawBG */
1491  30.0, /* fovy */
1492  5.0, /* fovymin */
1493  60.0, /* fovymax */
1494  0.0, /* distx */
1495  20.0, /* disty */
1496  3.0, /* distz */
1497  1.0, /* near */
1498  1000.0 * fovFactor, /* far */
1499  500.0 * fovFactor, /* fog */
1500  1000.0 * fovFactor /* fog */
1501  );
1502  cam->add(&cams[c]);
1503  id++;
1504 
1505  /* cam F4 = car side 3*/
1506  cam = new cGrCarCamSide(myscreen,
1507  id,
1508  1, /* drawCurr */
1509  1, /* drawBG */
1510  30.0, /* fovy */
1511  5.0, /* fovymin */
1512  60.0, /* fovymax */
1513  -20.0, /* distx */
1514  0.0, /* disty */
1515  3.0, /* distz */
1516  1.0, /* near */
1517  1000.0 * fovFactor, /* far */
1518  500.0 * fovFactor, /* fog */
1519  1000.0 * fovFactor /* fog */
1520  );
1521  cam->add(&cams[c]);
1522  id++;
1523 
1524  /* cam F4 = car side 4*/
1525  cam = new cGrCarCamSide(myscreen,
1526  id,
1527  1, /* drawCurr */
1528  1, /* drawBG */
1529  30.0, /* fovy */
1530  5.0, /* fovymin */
1531  60.0, /* fovymax */
1532  20.0, /* distx */
1533  0.0, /* disty */
1534  3.0, /* distz */
1535  1.0, /* near */
1536  1000.0 * fovFactor, /* far */
1537  500.0 * fovFactor, /* fog */
1538  1000.0 * fovFactor /* fog */
1539  );
1540  cam->add(&cams[c]);
1541  id++;
1542 
1543  /* cam F4 = car side 5*/
1544  cam = new cGrCarCamSide(myscreen,
1545  id,
1546  1, /* drawCurr */
1547  1, /* drawBG */
1548  30.0, /* fovy */
1549  5.0, /* fovymin */
1550  60.0, /* fovymax */
1551  0.0, /* distx */
1552  -40.0, /* disty */
1553  6.0, /* distz */
1554  1.0, /* near */
1555  1000.0 * fovFactor, /* far */
1556  500.0 * fovFactor, /* fog */
1557  1000.0 * fovFactor /* fog */
1558  );
1559  cam->add(&cams[c]);
1560  id++;
1561 
1562  /* cam F4 = car side 6*/
1563  cam = new cGrCarCamSide(myscreen,
1564  id,
1565  1, /* drawCurr */
1566  1, /* drawBG */
1567  30.0, /* fovy */
1568  5.0, /* fovymin */
1569  60.0, /* fovymax */
1570  0.0, /* distx */
1571  40.0, /* disty */
1572  6.0, /* distz */
1573  1.0, /* near */
1574  1000.0 * fovFactor, /* far */
1575  500.0 * fovFactor, /* fog */
1576  1000.0 * fovFactor /* fog */
1577  );
1578  cam->add(&cams[c]);
1579  id++;
1580 
1581  /* cam F4 = car side 7*/
1582  cam = new cGrCarCamSide(myscreen,
1583  id,
1584  1, /* drawCurr */
1585  1, /* drawBG */
1586  30.0, /* fovy */
1587  5.0, /* fovymin */
1588  60.0, /* fovymax */
1589  -40.0, /* distx */
1590  0.0, /* disty */
1591  6.0, /* distz */
1592  1.0, /* near */
1593  1000.0 * fovFactor, /* far */
1594  500.0 * fovFactor, /* fog */
1595  1000.0 * fovFactor /* fog */
1596  );
1597  cam->add(&cams[c]);
1598  id++;
1599 
1600  /* cam F4 = car side 8*/
1601  cam = new cGrCarCamSide(myscreen,
1602  id,
1603  1, /* drawCurr */
1604  1, /* drawBG */
1605  30.0, /* fovy */
1606  5.0, /* fovymin */
1607  60.0, /* fovymax */
1608  40.0, /* distx */
1609  0.0, /* disty */
1610  6.0, /* distz */
1611  1.0, /* near */
1612  1000.0 * fovFactor, /* far */
1613  500.0 * fovFactor, /* fog */
1614  1000.0 * fovFactor /* fog */
1615  );
1616  cam->add(&cams[c]);
1617 
1618  /* F5 */
1619  c++;
1620  GF_TAILQ_INIT(&cams[c]);
1621  id = 0;
1622 
1623  /* cam F5 = car up 1*/
1624  cam = new cGrCarCamUp(myscreen,
1625  id,
1626  1, /* drawCurr */
1627  1, /* drawBG */
1628  //12.0, /* fovy */
1629  67.5, /* fovy */
1630  1.0, /* fovymin */
1631  90.0, /* fovymax */
1632  //300.0, /* distz */
1633  200.0, /* distz */
1634  0, /* axis */
1635  //200.0, /* near */
1636  100.0, /* near */
1637  1000.0 * fovFactor,/* far */
1638  500.0 * fovFactor, /* fog */
1639  1000.0 * fovFactor /* fog */
1640  );
1641  cam->add(&cams[c]);
1642  id++;
1643 
1644  /* cam F5 = car up 2*/
1645  cam = new cGrCarCamUp(myscreen,
1646  id,
1647  1, /* drawCurr */
1648  1, /* drawBG */
1649  //12.0, /* fovy */
1650  67.5, /* fovy */
1651  1.0, /* fovymin */
1652  90.0, /* fovymax */
1653  //300.0, /* distz */
1654  250.0, /* distz */
1655  1, /* axis */
1656  200.0, /* near */
1657  1000.0 * fovFactor,/* far */
1658  500.0 * fovFactor, /* fog */
1659  1000.0 * fovFactor /* fog */
1660  );
1661  cam->add(&cams[c]);
1662  id++;
1663 
1664  /* cam F5 = car up 3*/
1665  cam = new cGrCarCamUp(myscreen,
1666  id,
1667  1, /* drawCurr */
1668  1, /* drawBG */
1669  //12.0, /* fovy */
1670  67.5, /* fovy */
1671  1.0, /* fovymin */
1672  90.0, /* fovymax */
1673  //300.0, /* distz */
1674  350.0, /* distz */
1675  2, /* axis */
1676  200.0, /* near */
1677  1000.0 * fovFactor,/* far */
1678  500.0 * fovFactor, /* fog */
1679  1000.0 * fovFactor /* fog */
1680  );
1681  cam->add(&cams[c]);
1682  id++;
1683 
1684  /* cam F5 = car up 4*/
1685  cam = new cGrCarCamUp(myscreen,
1686  id,
1687  1, /* drawCurr */
1688  1, /* drawBG */
1689  //12.0, /* fovy */
1690  67.5, /* fovy */
1691  1.0, /* fovymin */
1692  90.0, /* fovymax */
1693  //300.0, /* distz */
1694  400.0, /* distz */
1695  3, /* axis */
1696  200.0, /* near */
1697  1000.0 * fovFactor,/* far */
1698  500.0 * fovFactor, /* fog */
1699  1000.0 * fovFactor /* fog */
1700  );
1701  cam->add(&cams[c]);
1702 
1703  /* F6 */
1704  c++;
1705  GF_TAILQ_INIT(&cams[c]);
1706  id = 0;
1707 
1708  /* cam F6 = car from circuit centre */
1709  cam = new cGrCarCamCenter(myscreen,
1710  id,
1711  1, /* drawCurr */
1712  1, /* drawBG */
1713  21.0, /* fovy */
1714  2.0, /* fovymin */
1715  60.0, /* fovymax */
1716  120.0, /* distz */
1717  100.0, /* near */
1718  1500.0,/* far */
1719  10500.0,/* fog */
1720  20500.0 /* fog */
1721  );
1722  cam->add(&cams[c]);
1723 
1724  /* F7 */
1725  c++;
1726  GF_TAILQ_INIT(&cams[c]);
1727  id = 0;
1728 
1729  /* cam F7 = panoramic */
1730  cam = new cGrCarCamLookAt(myscreen,
1731  id,
1732  1, /* drawCurr */
1733  0, /* drawBG */
1734  74.0, /* fovy */
1735  1.0, /* fovymin */
1736  110.0, /* fovymax */
1737  0, /* up axis */
1738  grWrldX/2, /* eyex */
1739  grWrldY/2, /* eyey */
1740  MAX(grWrldX/2, grWrldY*4/3/2) + grWrldZ, /* eyez */
1741  grWrldX/2, /* centerx */
1742  grWrldY/2, /* centery */
1743  0, /* centerz */
1744  10.0, /* near */
1745  grWrldMaxSize * 2.0, /* far */
1746  grWrldMaxSize * 10.0, /* fog */
1747  grWrldMaxSize * 20.0 /* fog */
1748  );
1749  cam->add(&cams[c]);
1750  id++;
1751 
1752  /* cam F7 = panoramic */
1753  cam = new cGrCarCamLookAt(myscreen,
1754  id,
1755  1, /* drawCurr */
1756  0, /* drawBG */
1757  74.0f, /* fovy */
1758  1.0f, /* fovymin */
1759  110.0f, /* fovymax */
1760  4, /* up axis */
1761  -grWrldX/2.0f, /* eyex */
1762  -grWrldY/2.0f, /* eyey */
1763  0.25f * sqrt((double)(grWrldX*grWrldX+grWrldY*grWrldY)), /* eyez */
1764  grWrldX/2.0f, /* centerx */
1765  grWrldY/2.0f, /* centery */
1766  0.0f, /* centerz */
1767  10.0f, /* near */
1768  2.0f * grWrldMaxSize, /* far */
1769  10.0f * grWrldMaxSize, /* fog */
1770  20.0f * grWrldMaxSize /* fog */
1771  );
1772  cam->add(&cams[c]);
1773  id++;
1774 
1775  /* cam F7 = panoramic */
1776  cam = new cGrCarCamLookAt(myscreen,
1777  id,
1778  1, /* drawCurr */
1779  0, /* drawBG */
1780  74.0f, /* fovy */
1781  1.0f, /* fovymin */
1782  110.0f, /* fovymax */
1783  4, /* up axis */
1784  -grWrldX/2.0f, /* eyex */
1785  grWrldY * 3.0f/2.0f, /* eyey */
1786  0.25f * sqrt((double)(grWrldX*grWrldX+grWrldY*grWrldY)), /* eyez */
1787  grWrldX/2.0f, /* centerx */
1788  grWrldY/2.0f, /* centery */
1789  0.0f, /* centerz */
1790  10.0f, /* near */
1791  2.0f * grWrldMaxSize, /* far */
1792  10.0f * grWrldMaxSize, /* fog */
1793  20.0f * grWrldMaxSize /* fog */
1794  );
1795  cam->add(&cams[c]);
1796  id++;
1797 
1798  /* cam F7 = panoramic */
1799  cam = new cGrCarCamLookAt(myscreen,
1800  id,
1801  1, /* drawCurr */
1802  0, /* drawBG */
1803  74.0f, /* fovy */
1804  1.0f, /* fovymin */
1805  110.0f, /* fovymax */
1806  4, /* up axis */
1807  grWrldX * 3.0f/2.0f, /* eyex */
1808  grWrldY * 3.0f/2.0f, /* eyey */
1809  0.25f * sqrt((double)(grWrldX*grWrldX+grWrldY*grWrldY)), /* eyez */
1810  grWrldX/2.0f, /* centerx */
1811  grWrldY/2.0f, /* centery */
1812  0.0f, /* centerz */
1813  10.0f, /* near */
1814  2.0f * grWrldMaxSize, /* far */
1815  10.0f * grWrldMaxSize, /* fog */
1816  20.0f * grWrldMaxSize /* fog */
1817  );
1818  cam->add(&cams[c]);
1819  id++;
1820 
1821  /* cam F7 = panoramic */
1822  cam = new cGrCarCamLookAt(myscreen,
1823  id,
1824  1, /* drawCurr */
1825  0, /* drawBG */
1826  74.0f, /* fovy */
1827  1.0f, /* fovymin */
1828  110.0f, /* fovymax */
1829  4, /* up axis */
1830  grWrldX * 3.0f/2.0f, /* eyex */
1831  -grWrldY/2.0f, /* eyey */
1832  0.25f * sqrt((double)(grWrldX*grWrldX+grWrldY*grWrldY)), /* eyez */
1833  grWrldX/2.0f, /* centerx */
1834  grWrldY/2.0f, /* centery */
1835  0.0f, /* centerz */
1836  10.0f, /* near */
1837  2.0f * grWrldMaxSize, /* far */
1838  10.0f * grWrldMaxSize, /* fog */
1839  20.0f * grWrldMaxSize /* fog */
1840  );
1841  cam->add(&cams[c]);
1842  id++;
1843 
1844  /* F8 */
1845  c++;
1846  GF_TAILQ_INIT(&cams[c]);
1847  id = 0;
1848 
1849  /* cam F8 = road cam fixed fov */
1850 
1851  cam = new cGrCarCamRoadNoZoom(myscreen,
1852  id,
1853  1, /* drawCurr */
1854  1, /* drawBG */
1855  30.0, /* fovy */
1856  5.0, /* fovymin */
1857  60.0, /* fovymax */
1858  1.0, /* near */
1859  1000.0 * fovFactor,/* far */
1860  500.0 * fovFactor, /* fog */
1861  1000.0 * fovFactor /* fog */
1862  );
1863  cam->add(&cams[c]);
1864 
1865  /* F9 */
1866  c++;
1867  GF_TAILQ_INIT(&cams[c]);
1868  id = 0;
1869 
1870  /* cam F9 = road cam zoomed */
1871  cam = new cGrCarCamRoadZoom(myscreen,
1872  id,
1873  1, /* drawCurr */
1874  1, /* drawBG */
1875  9.0, /* fovy */
1876  1.0, /* fovymin */
1877  90.0, /* fovymax */
1878  1.0, /* near */
1879  1000.0 * fovFactor, /* far */
1880  500.0 * fovFactor, /* fog */
1881  1000.0 * fovFactor /* fog */
1882  );
1883  cam->add(&cams[c]);
1884 
1885  /* F10 */
1886  c++;
1887  GF_TAILQ_INIT(&cams[c]);
1888  id = 0;
1889 
1890  cam = new cGrCarCamRoadFly(myscreen,
1891  id,
1892  1, /* drawCurr */
1893  1, /* drawBG */
1894  //17.0, /* fovy */
1895  67.5, /* fovy */
1896  1.0, /* fovymin */
1897  90.0, /* fovymax */
1898  1.0, /* near */
1899  1000.0 * fovFactor, /* far */
1900  500.0 * fovFactor, /* fog */
1901  1000.0 * fovFactor /* fog */
1902  );
1903  cam->add(&cams[c]);
1904 
1905  /* F11 */
1906  c++;
1907  GF_TAILQ_INIT(&cams[c]);
1908  id = 0;
1909  cam = new cGrCarCamRoadZoomTVD(myscreen,
1910  id,
1911  1, /* drawCurr */
1912  1, /* drawBG */
1913  9.0, /* fovy */
1914  1.0, /* fovymin */
1915  90.0, /* fovymax */
1916  1.0, /* near */
1917  1000.0 * fovFactor, /* far */
1918  500.0 * fovFactor, /* fog */
1919  1000.0 * fovFactor /* fog */
1920  );
1921  cam->add(&cams[c]);
1922 
1923 }
#define RM_CMD_PIT_ASKED
Race command: Pit asked.
Definition: car.h:352
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:1061
#define DEG2RAD(x)
Degree to radian conversion.
Definition: tgf.h:76
tTrack * grTrack
Definition: grscene.cpp:57
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)
Definition: grcam.cpp:796
float tsu
Definition: grcam.h:238
float right
Definition: grcam.h:194
float getLODFactor(float x, float y, float z)
Definition: grcam.cpp:144
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)
Definition: grcam.cpp:863
int getId(void)
Definition: grcam.h:85
double currentTime
current time in sec since the beginning of the simulation
Definition: raceman.h:88
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)
Definition: grcam.cpp:426
float locfar
Definition: grcam.cpp:725
int type
Geometrical type:
Definition: track.h:280
void setProjection(void)
Definition: grcam.cpp:110
int raceCmd
command issued by the driver
Definition: car.h:350
void grCamCreateSceneCameraList(class cGrScreen *myscreen, tGrCamHead *cams, tdble fovFactor)
Definition: grcam.cpp:1292
float fovy
Definition: grcam.h:152
static tdble GetDistToStart(tCarElt *car)
Definition: grcam.cpp:1102
static int scrh
Definition: mouseconfig.cpp:50
cars situation used to inform the GUI and the drivers
Definition: raceman.h:85
static tRmFileSelect fs
Definition: racemanmenu.cpp:48
#define GR_ZOOM_MAX
Definition: grcam.h:269
float fogstart
Definition: grcam.h:158
tdble y
y coordinate
Definition: tgf.h:132
int grNbCars
Definition: grmain.cpp:57
#define GR_SCT_TVDIR
Definition: graphic.h:77
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:545
double camEventInterval
Definition: grcam.cpp:1132
void loadDefaults(char *attr)
Definition: grcam.cpp:749
void setModelView(void)
Definition: grcam.cpp:221
class cGrScreen * screen
Definition: grcam.h:51
tdble RtTrackHeightG(tTrackSeg *seg, tdble X, tdble Y)
Returns the absolute height in meters of the road at the Global position (segment, X, Y)
Definition: rttrack.cpp:443
#define TR_STR
Straight.
Definition: track.h:287
tCarElt ** cars
list of cars
Definition: raceman.h:90
tCarCtrl ctrl
private
Definition: car.h:462
float bottom
Definition: grcam.h:195
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:490
int GfNearestPow2(int x)
Definition: tgf.cpp:285
Car structure (tCarElt).
Definition: car.h:455
float tev
Definition: grcam.h:238
Robots Tools.
tdble width
main track width
Definition: track.h:513
int viewable
Definition: grcam.cpp:1124
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:261
void activateViewport(void)
Definition: grcam.cpp:381
sgVec3 eye
Definition: grcam.h:48
virtual ~cGrCarCamMirror()
Definition: grcam.cpp:290
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:1164
tdble lgfromstart
Length of beginning of segment from starting line.
Definition: track.h:319
sgVec3 speed
Definition: grcam.h:47
const double PI
PI.
Definition: tgf.h:69
float tsv
Definition: grcam.h:238
virtual float getFovY(void)
Definition: grcam.h:126
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)
Definition: grcam.cpp:532
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
Definition: params.cpp:1610
void setProjection(void)
Definition: grcam.cpp:214
float fovymin
Definition: grcam.h:153
void setZoom(int cmd)
Definition: grcam.cpp:757
void onSelect(tCarElt *car, tSituation *s)
Definition: grcam.cpp:1016
#define RM_CAR_STATE_NO_SIMU
Do not simulate the car.
Definition: car.h:217
#define RAD2DEG(x)
Radian to degree conversion.
Definition: tgf.h:75
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:933
void setZoom(int cmd)
Definition: grcam.cpp:1055
The Gaming Framework API (client part).
ssgContext grContext
Definition: grmain.cpp:67
void loadDefaults(char *attr)
Definition: grcam.cpp:1045
#define M(row, col)
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:874
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:435
tdble length
main track length
Definition: track.h:512
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)
Definition: grcam.cpp:627
float height
Definition: grcam.cpp:473
tCarElt * getCurrentCar(void)
Definition: grscreen.h:82
float fovydflt
Definition: grcam.h:155
float ffar
Definition: grcam.h:157
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:598
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)
Definition: grcam.cpp:913
road camera
Definition: track.h:226
GLuint tex
Definition: grcam.h:239
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)
Definition: grcam.cpp:668
#define GR_ATT_CHGCAMINT
Definition: graphic.h:78
void update(tCarElt *car, tSituation *s)
Definition: grcam.h:226
void add(tGrCamHead *head)
Definition: grcam.h:131
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:853
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)
Definition: grcam.cpp:249
float tdble
Floating point type used in TORCS.
Definition: tgf.h:48
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)
Definition: grcam.cpp:1139
float getViewRatio(void)
Definition: grscreen.h:84
#define GR_ZOOM_DFLT
Definition: grcam.h:271
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:302
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)
Definition: grcam.cpp:1031
void setViewport(int x, int y, int w, int h)
Definition: grcam.cpp:330
float disty
Definition: grcam.cpp:623
Definition: Endpoint.h:36
void setCurrentCar(tCarElt *newCurCar)
Definition: grscreen.cpp:107
int grWrldY
Definition: grscene.cpp:54
tdble x
x coordinate
Definition: tgf.h:131
#define GR_ZOOM_MIN
Definition: grcam.h:270
void store(void)
Definition: grcam.cpp:390
static Point p[4]
Definition: Convex.cpp:54
#define GF_TAILQ_INIT(head)
Head initialization (Mandatory)
Definition: tgf.h:485
int grWrldX
Definition: grscene.cpp:53
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)
Definition: grcam.cpp:94
tPublicCar pub
public
Definition: car.h:459
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)
Definition: grcam.cpp:476
double currenttime
Definition: grcam.cpp:911
void setZoom(int cmd)
Definition: grcam.cpp:166
Graphic Module Interface Definition.
tdble radius
Radius in meters of the middle of the track (>0)
Definition: track.h:320
tdble y
y coordinate
Definition: tgf.h:117
tSchedView * schedView
Definition: grcam.cpp:1130
float grGetHOT(float x, float y)
Definition: grutil.cpp:354
cGrOrthoCamera * viewCam
Definition: grcam.h:240
tPrivCar priv
private
Definition: car.h:461
float left
Definition: grcam.h:193
tdble z
z coordinate
Definition: tgf.h:118
int grWrldMaxSize
Definition: grscene.cpp:56
int id
Definition: grcam.h:40
int index
car index
Definition: car.h:457
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)
Definition: grcam.cpp:729
void limitFov(void)
Definition: grcam.cpp:297
#define GR_SCT_DISPMODE
Definition: graphic.h:63
int getCurCamHead(void)
Definition: grscreen.h:85
sgVec3 center
Definition: grcam.h:49
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:763
#define GR_ATT_EVTINT
Definition: graphic.h:79
int GfParmSetNum(void *handle, const char *path, const char *key, const char *unit, tdble val)
Set a numerical parameter in the parameter set handle.
Definition: params.cpp:2586
sgVec3 * getPosv(void)
Definition: grcam.h:98
#define GR_NB_MAX_SCREEN
Definition: grmain.h:72
void GfScrGetSize(int *scrw, int *scrh, int *vieww, int *viewh)
Get the screen and viewport sizes.
Definition: screen.cpp:471
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Definition: params.cpp:2392
void action(void)
Definition: grcam.h:79
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:701
int collision
Collision value for graphics and sound, clearing is managed by consumers.
Definition: car.h:306
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
Definition: track.h:276
int getId(void)
Definition: grscreen.h:87
static Vector y[4]
Definition: Convex.cpp:56
void limitFov(void)
Definition: grcam.h:179
float fnear
Definition: grcam.h:156
float offset[3]
Definition: grcam.cpp:910
float distz
Definition: grcam.cpp:665
void update(tCarElt *car, tSituation *s)
Definition: grcam.cpp:643
float top
Definition: grcam.h:196
void setPos(int x, int y, int w, int h)
Definition: grcam.cpp:345
tPosd vel
velocity
Definition: tgf.h:145
float distx
Definition: grcam.cpp:622
#define GR_ZOOM_OUT
Definition: grcam.h:268
float fovymax
Definition: grcam.h:154
class cGrScreen * grScreens[GR_NB_MAX_SCREEN]
Definition: grmain.cpp:68
double camChangeInterval
Definition: grcam.cpp:1131
void * grHandle
Definition: grmain.cpp:59
float teu
Definition: grcam.h:238
sgVec3 up
Definition: grcam.h:50
float dist
Definition: grcam.cpp:583
#define GfTrace
Definition: tgf.h:336
void display(void)
Definition: grcam.cpp:404
#define GR_ATT_PROXTHLD
Definition: graphic.h:80
void loadDefaults(char *attr)
Definition: grcam.cpp:132
t3Dd pos
Definition: track.h:229
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)
Definition: grcam.cpp:586
sgVec3 * getUpv(void)
Definition: grcam.h:122
double prio
Definition: grcam.cpp:1123
void GfScrShutdown(void)
Shutdown the screen.
Definition: screen.cpp:442
float getDist2(tCarElt *car)
Definition: grcam.cpp:46
float distz
Definition: grcam.cpp:624
void setModelView(void)
Definition: grcam.cpp:124
int event
Definition: grcam.cpp:1125
static void grMakeLookAtMat4(sgMat4 dst, const sgVec3 eye, const sgVec3 center, const sgVec3 up)
Definition: grcam.cpp:56
#define GR_ATT_FOVY
Definition: graphic.h:68
tdble x
x coordinate
Definition: tgf.h:116
tdble RtTrackSideTgAngleL(tTrkLocPos *p)
Used to get the tangent angle for a track position The angle is given in radian.
Definition: rttrack.cpp:514
int grWrldZ
Definition: grscene.cpp:55
#define RELAXATION(target, prev, rate)
Definition: robottools.h:38
float locfovy
Definition: grcam.cpp:726
sgVec3 * getCenterv(void)
Definition: grcam.h:111
float fogend
Definition: grcam.h:159
tDynPt DynGCg
GC data (world axis)
Definition: car.h:193
#define GR_ZOOM_IN
Definition: grcam.h:267
tdble z
z coordinate
Definition: tgf.h:133