torcs - 1.2.2

src/modules/simu/simuv3/carstruct.h

Go to the documentation of this file.
00001 /***************************************************************************
00002 
00003     file                 : carstruct.h
00004     created              : Sun Mar 19 00:06:07 CET 2000
00005     copyright            : (C) 2000 by Eric Espie
00006     email                : torcs@free.fr
00007     version              : $Id: carstruct.h,v 1.5 2004/01/15 09:54:06 olethros 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 #ifndef _CAR__H_
00021 #define _CAR__H_
00022 
00023 #include <plib/sg.h>
00024 #include <SOLID/solid.h>
00025 
00026 #include "aero.h"
00027 #include "susp.h"
00028 #include "brake.h"
00029 #include "axle.h"
00030 #include "steer.h"
00031 #include "wheel.h"
00032 #include "transmission.h"
00033 #include "engine.h"
00034 
00035 typedef struct
00036 {
00037     /* driver's interface */
00038     tCarCtrl    *ctrl;
00039     void        *params;
00040     tCarElt     *carElt;
00041 
00042     tCarCtrl    preCtrl;
00043 
00044     /* components */
00045     tAxle               axle[2];
00046     tWheel              wheel[4];
00047     tSteer              steer;
00048     tBrakeSyst          brkSyst;
00049     tAero               aero;
00050     tWing               wing[2];
00051     tTransmission       transmission;   /* includes clutch, gearbox and driveshaft */
00052     tEngine             engine;
00053 
00054     /* static */
00055     t3Dd        dimension;      /* car's mesures */
00056     tdble       mass;           /* mass with pilot (without fuel) */
00057     tdble       Minv;           /* 1 / mass with pilot (without fuel) */
00058     tdble       tank;           /* fuel tank capa */
00059     t3Dd        statGC;         /* static pos of GC */
00060     t3Dd        Iinv;           /* inverse of inertial moment along the car's 3 axis */
00061 
00062     /* dynamic */
00063     tdble       fuel;           /* current fuel load */
00064     tDynPt      DynGC;          /* GC local data except position */
00065     tDynPt      DynGCg;         /* GC global data */
00066     tPosd       VelColl;        /* resulting velocity after collision */
00067     tDynPt      preDynGC;       /* previous one */
00068     tTrkLocPos  trkPos;         /* current track position */
00069     tdble       airSpeed2;      /* current air speed (squared) for aerodynamic forces */
00070 
00071     /* internals */
00072     tdble       Cosz;
00073     tdble       Sinz;
00074     tDynPt      corner[4];      /* x,y,z for static relative pos, ax,ay,az for dyn. world coord */
00075     int         collision;
00076     t3Dd        normal;
00077     t3Dd        collpos;
00078     tdble       wheelbase;
00079     tdble       wheeltrack;
00080     sgMat4      posMat;
00081     DtShapeRef  shape;          /* for collision */
00082     int         blocked;
00083     int         dammage;
00084     
00085     tDynPt      restPos;        /* target rest position after the car is broken */
00086 
00087     int         collisionAware;
00088 } tCar;
00089 
00090 #if 0
00091 
00092 #define CHECK_VAR(_var_, _msg_) do {                                            \
00093     if (isnan(_var_) || isinf(_var_)) {                                         \
00094         printf("%s = %f  in %s line %d\n", _msg_, _var_, __FILE__, __LINE__);   \
00095         assert (0);                                                             \
00096         exit(0);                                                                \
00097     }                                                                           \
00098 } while (0)
00099 
00100 #define DUMP_CAR(_car_) do {                                    \
00101         printf("DynGC.acc.x  = %f\n", (_car_)->DynGC.acc.x);    \
00102         printf("DynGC.acc.y  = %f\n", (_car_)->DynGC.acc.y);    \
00103         printf("DynGC.acc.y  = %f\n", (_car_)->DynGC.acc.y);    \
00104         printf("DynGC.vel.x  = %f\n", (_car_)->DynGC.vel.x);    \
00105         printf("DynGC.vel.y  = %f\n", (_car_)->DynGC.vel.y);    \
00106         printf("DynGC.pos.x  = %f\n", (_car_)->DynGC.pos.x);    \
00107         printf("DynGC.pos.y  = %f\n", (_car_)->DynGC.pos.y);    \
00108         printf("DynGCg.acc.x = %f\n", (_car_)->DynGCg.acc.x);   \
00109         printf("DynGCg.acc.y = %f\n", (_car_)->DynGCg.acc.y);   \
00110         printf("DynGCg.vel.x = %f\n", (_car_)->DynGCg.vel.x);   \
00111         printf("DynGCg.vel.y = %f\n", (_car_)->DynGCg.vel.y);   \
00112         printf("DynGCg.pos.x = %f\n", (_car_)->DynGCg.pos.x);   \
00113         printf("DynGCg.pos.y = %f\n", (_car_)->DynGCg.pos.y);   \
00114         printf("aero.drag    = %f\n", (_car_)->aero.drag);      \
00115 } while (0)
00116 
00117 
00118 #define CHECK(_car_) do {                                                                       \
00119     if (isnan((_car_)->DynGC.acc.x) || isinf((_car_)->DynGC.acc.x) ||                           \
00120         isnan((_car_)->DynGC.acc.y) || isinf((_car_)->DynGC.acc.y) ||                           \
00121         isnan((_car_)->DynGC.vel.x) || isinf((_car_)->DynGC.vel.x) ||                           \
00122         isnan((_car_)->DynGC.vel.y) || isinf((_car_)->DynGC.vel.y) ||                           \
00123         isnan((_car_)->DynGC.pos.x) || isinf((_car_)->DynGC.pos.x) ||                           \
00124         isnan((_car_)->DynGC.pos.y) || isinf((_car_)->DynGC.pos.y) ||                           \
00125         isnan((_car_)->DynGC.acc.x) || isinf((_car_)->DynGC.acc.x) ||                           \
00126         isnan((_car_)->DynGCg.acc.y) || isinf((_car_)->DynGCg.acc.y) ||                         \
00127         isnan((_car_)->DynGCg.vel.x) || isinf((_car_)->DynGCg.vel.x) ||                         \
00128         isnan((_car_)->DynGCg.vel.y) || isinf((_car_)->DynGCg.vel.y) ||                         \
00129         isnan((_car_)->DynGCg.pos.x) || isinf((_car_)->DynGCg.pos.x) ||                         \
00130         isnan((_car_)->DynGCg.pos.y) || isinf((_car_)->DynGCg.pos.y) ||                         \
00131         isnan((_car_)->aero.drag) || isinf((_car_)->aero.drag)) {                               \
00132         printf("Problem for %s in %s line %d\n", (_car_)->carElt->_name, __FILE__, __LINE__);   \
00133         DUMP_CAR(_car_);                                                                        \
00134         assert (0);                                                                             \
00135         /* GfScrShutdown(); */                                                                  \
00136         exit(0);                                                                                \
00137     }                                                                                           \
00138 } while (0)
00139 
00140 #else
00141 
00142 #define CHECK_VAR(_var_, _msg_)
00143 #define CHECK(_car_)
00144 
00145 #endif
00146 
00147 #endif /* _CAR__H_ */ 
00148 
00149 
00150 
00151 
00152 
00153 
00154 
00155 

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