00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
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
00038 tCarCtrl *ctrl;
00039 void *params;
00040 tCarElt *carElt;
00041
00042 tCarCtrl preCtrl;
00043
00044
00045 tAxle axle[2];
00046 tWheel wheel[4];
00047 tSteer steer;
00048 tBrakeSyst brkSyst;
00049 tAero aero;
00050 tWing wing[2];
00051 tTransmission transmission;
00052 tEngine engine;
00053
00054
00055 t3Dd dimension;
00056 tdble mass;
00057 tdble Minv;
00058 tdble tank;
00059 t3Dd statGC;
00060 t3Dd Iinv;
00061
00062
00063 tdble fuel;
00064 tDynPt DynGC;
00065 tDynPt DynGCg;
00066 tPosd VelColl;
00067 tDynPt preDynGC;
00068 tTrkLocPos trkPos;
00069 tdble airSpeed2;
00070
00071
00072 tdble Cosz;
00073 tdble Sinz;
00074 tDynPt corner[4];
00075 int collision;
00076 t3Dd normal;
00077 t3Dd collpos;
00078 tdble wheelbase;
00079 tdble wheeltrack;
00080 sgMat4 posMat;
00081 DtShapeRef shape;
00082 int blocked;
00083 int dammage;
00084
00085 tDynPt restPos;
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 \
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
00148
00149
00150
00151
00152
00153
00154
00155