82 tdble CosA, SinA, r, a;
92 toRight = (width / 2.0) +
p->toMiddle;
94 toRight = width -
p->toLeft;
108 tr = toRight - seg->
Kyl *
p->toStart;
167 while (segnotfound) {
179 ts = x * cosine +
y * sine;
182 p->toRight =
y * cosine - x * sine;
183 if ((
ts < 0) && (depl < 1)) {
187 }
else if ((
ts > seg->
length) && (depl > -1)) {
203 p->toStart = theta + a2;
205 if ((theta < -a2) && (depl < 1)) {
208 }
else if ((theta > a2) && (depl > -1)) {
225 p->toStart = theta + a2;
227 if ((theta < -a2) && (depl < 1)) {
230 }
else if ((theta > a2) && (depl > -1)) {
242 p->toMiddle =
p->toRight - seg->
width / 2.0;
243 p->toLeft = seg->
width -
p->toRight;
251 while ((sseg = sseg->
side[side]) != NULL) {
278 while ((*toSide < 0.0f) && (sseg->
side[trSide] != NULL)) {
279 sseg = sseg->
side[trSide];
282 *toOppositeSide -= prevWidth;
284 p->toMiddle +=
sign*(prevWidth + curWidth)/2.0f;
285 prevWidth = curWidth;
320 if ((tr < 0) && (seg->
rside != NULL)) {
324 if ((tr < 0) && (seg->
rside != NULL)) {
328 }
else if ((tr > seg->
width) && (seg->
lside != NULL)) {
331 if ((tr > seg->
width) && (seg->
lside != NULL)) {
351 tdble base_height = height_right_side + banking_height;
362 alpha = seg->
width - tr;
366 return base_height + alpha * (seg->
height + curb_roughness) / seg->
width;
385 if (current->
side[tr_side] != NULL) {
386 return current->
side[tr_side];
394 while (neighbour->
side[tr_other_side] != NULL) {
395 otherSurface = neighbour;
396 if (neighbour->
side[tr_other_side] == current) {
399 neighbour = neighbour->
side[tr_other_side];
418 if ((tr < 0) && (seg->
rside != NULL)) {
421 if ((tr < 0) && (seg->
rside != NULL)) {
424 }
else if ((tr > seg->
width) && (seg->
lside != NULL)) {
427 if ((tr > seg->
width) && (seg->
lside != NULL)) {
487 if (side == seg->
type) {
497 lg = 1.0 / sqrt(norm->
x * norm->
x + norm->
y * norm->
y);
516 switch (
p->seg->type) {
518 return p->seg->angle[
TR_ZS];
521 return p->seg->angle[
TR_ZS] -
p->toStart;
524 return p->seg->angle[
TR_ZS] +
p->toStart;
543 t3Dd px1, px2, py1, py2;
587 v1.
x = px2.
x - px1.
x;
588 v1.
y = px2.
y - px1.
y;
589 v1.
z = px2.
z - px1.
z;
592 v2.
x = py2.
x - py1.
x;
593 v2.
y = py2.
y - py1.
y;
594 v2.
z = py2.
z - py1.
z;
596 norm->
x = v1.
y * v2.
z - v2.
y * v1.
z;
597 norm->
y = v2.
x * v1.
z - v1.
x * v2.
z;
598 norm->
z = v1.
x * v2.
y - v2.
x * v1.
y;
599 lg = sqrt(norm->
x * norm->
x + norm->
y * norm->
y + norm->
z * norm->
z);
644 lg +=
p->toStart * seg->
radius;
669 if (car->_pit == NULL)
return 1;
671 pitpos = &(car->_pit->pos);
672 carpos = &(car->_trkPos);
688 *dL +=
track->length;
689 }
else if (*dL >
track->length) {
690 *dL -=
track->length;
718 const int BUFSIZE = 256;
725 for (i=0; i < 4; i++) {
749 for (i=0; i < 2; i++) {
755 for (i=0; i < 2; i++) {
763 for (i=0; i < 8; i++) {
770 for (i=0; i < 2; i++) {
776 for (i=0; i < 3; i++) {
801 static const char*
CarPitSetupFilenames[6] = {
"practice",
"qualifying",
"race",
"backup1",
"backup2",
"backup3" };
817 const char* trackname,
822 snprintf(filename, len,
"%s_%s_%d_%s" , carname, trackname, robidx,
CarPitSetupFilenames[type]);
837 if (fabs(v->
min - v->
max) >= 0.0001f) {
853 const char* filepath,
857 const int BUFSIZE = 256;
868 for (i=0; i < 4; i++) {
892 for (i=0; i < 2; i++) {
898 for (i=0; i < 2; i++) {
906 for (i=0; i < 8; i++) {
913 for (i=0; i < 2; i++) {
920 for (i=0; i < 3; i++) {
956 const char* modulename,
958 const char* trackname,
962 const int filelen = 256;
963 char filename[filelen];
966 const int pathlen = 1024;
969 snprintf(path, pathlen,
"%sdrivers/%s/setups",
GetLocalDir(), modulename);
971 snprintf(path, pathlen,
"%sdrivers/%s/setups/%s.xml",
GetLocalDir(), modulename, filename);
974 GfError(
"RtSaveCarPitSetup, could not create %s\n", path);
990 const char* modulename,
992 const char* trackname,
996 const int filelen = 256;
997 char filename[filelen];
1000 const int pathlen = 1024;
1003 snprintf(path, pathlen,
"%sdrivers/%s/setups/%s.xml",
GetLocalDir(), modulename, filename);
1004 FILE* file = fopen(path,
"r");
1055 const char* modulename,
1057 const char* trackname,
1058 const char* carname,
1062 const int filelen = 256;
1063 char filename[filelen];
1066 const int pathlen = 1024;
1069 snprintf(path, pathlen,
"%sdrivers/%s/setups/%s.xml",
GetLocalDir(), modulename, filename);
1082 const int BUFSIZE = 1024;
1086 snprintf(buf, BUFSIZE,
"%scars/%s/%s.xml",
GetDataDir(), carname, carname);
1089 GfError(
"carhdle NULL in %s, line %d\n", __FILE__, __LINE__);
1095 if (category == 0) {
1096 GfError(
"category string NULL in %s, line %d\n", __FILE__, __LINE__);
1102 snprintf(buf, BUFSIZE,
"%scategories/%s.xml",
GetDataDir(), category);
1105 GfError(
"cathdle NULL in %s, line %d\n", __FILE__, __LINE__);
1128 if (carhandle == 0) {
1129 GfError(
"carhandle NULL in %s, line %d\n", __FILE__, __LINE__);
1151 const char* modulename,
1153 const char* trackname,
1157 const int filelen = 256;
1158 char filename[filelen];
1161 const int pathlen = 1024;
1164 snprintf(path, pathlen,
"%sdrivers/%s/setups/%s.xml",
GetLocalDir(), modulename, filename);
tdble kRoughness
Roughtness in m of the surface (wave height)
int GfParmSetStr(void *handle, const char *path, const char *key, const char *val)
Set a string parameter in the parameter set handle.
#define TR_SR
Start-Right corner.
int type
Geometrical type:
t3Dd center
Center of the curve.
void * GfParmReadFile(const char *file, int mode)
Read parameter set from file and return handle to parameter set.
tCarPitSetupValue gearsratio[MAX_GEARS - 2]
tdble toRight
Distance (+ to left, - to right) relative to the right side of segment.
tCarPitSetupValue suspslowrebound[4]
#define TR_LSIDE
Left side segment (outer segment)
#define GFPARM_RMODE_STD
if handle already openned return it
void * GfParmMergeHandles(void *ref, void *tgt, int mode)
Merge two parameter sets into a new one, either containing parameters from ref, tgt or from both sets...
#define TR_ZS
Rotation angles of the track in rad anti-clockwise: Index in:
tdble width
Width of the segment (if constant width)
int GfParmSetNumEx(void *handle, const char *path, const char *key, const char *unit, tdble val, tdble min, tdble max)
Set a numerical parameter in the parameter set handle including min and max.
tCarPitSetupValue thirdX0[2]
Location on the track in local coordinates.
static const char * SuspSect[4]
tCarPitSetupValue diffmaxtqbias[3]
void GfParmReleaseHandle(void *parmHandle)
Release given parameter set handle parmHandle.
#define SECT_FRNTLFTWHEEL
tCarPitSetupValue suspslowbump[4]
int GfCreateDir(char *path)
Create directory for given path recursively, so all missing parent directories are created as well...
#define TR_CS
Center start angle.
#define VAL_DIFF_LIMITED_SLIP
#define SECT_REARRGTWHEEL
tCarPitSetupValue brakePressure
#define PRM_MAX_SLIP_BIAS
tdble lgfromstart
Length of beginning of segment from starting line.
tdble endWidth
Width of the end of the segment.
int GfParmWriteFile(const char *file, void *parmHandle, const char *name)
Write parameter set into file.
tdble length
Length in meters of the middle of the track.
tdble startWidth
Width of the beginning of the segment.
tdble GfParmSI2Unit(const char *unit, tdble val)
Convert a value from SI to given unit.
#define SECT_FRNTRGTWHEEL
#define SECT_REARLFTWHEEL
tCarPitSetupValue diffratio[3]
const char * GfParmGetStr(void *parmHandle, const char *path, const char *key, const char *deflt)
Get a string parameter from the parameter set handle.
#define GFPARM_MMODE_RELDST
release tgt after the merge
tCarPitSetupValue brakeRepartition
static const char * WheelSect[4]
tCarPitSetupValue steerLock
tCarPitSetupValue suspbumpthreshold[4]
tCarPitSetupValue arbspring[2]
tCarPitSetupValue difflockinginputtq[3]
#define PRM_BUMPTHRESHOLD
#define TR_RBORDER
Right border segment (inner segment)
#define VAL_DIFF_VISCOUS_COUPLER
tCarPitSetupValue thirdspring[2]
int GfParmGetNumBoundaries(void *handle, const char *path, const char *key, tdble *min, tdble *max)
Get the min and max of a numerical parameter from the parameter set handle.
static const char * WingSect[2]
#define TR_LFT
Left curve.
#define TR_RSIDE
Right side segment (outer segment)
int main(int argc, char *argv[])
tdble radiusr
Radius in meters of the right side of the track (>0)
float tdble
Floating point type used in TORCS.
static const char * CarPitSetupFilenames[6]
Array with names for rtCarPitSetupType enumeration.
tdble radiusl
Radius in meters of the left side of the track (>0)
#define TR_CURB
Curb (border only)
struct trackSeg * side[2]
tCarPitSetupValue susppackers[4]
tCarPitSetupValue wheelrideheight[4]
#define SECT_FRNTDIFFERENTIAL
The Gaming Framework API.
tCarPitSetupValue thirdrebound[2]
tCarPitSetupValue thirdbump[2]
tdble arc
Arc in rad of the curve (>0)
#define TR_LBORDER
Left border segment (inner segment)
#define TR_XS
X Start angle.
tdble radius
Radius in meters of the middle of the track (>0)
#define SECT_CENTRALDIFFERENTIAL
tCarPitSetupValue suspfastbump[4]
t3Dd vertex[4]
Coordinates of the 4 corners of the segment.
This is the car structure.
tCarPitSetupValue wheelcamber[4]
#define PRM_REBOUNDTHRESHOLD
tCarPitSetupValue wingangle[2]
tCarPitSetupValue diffmintqbias[3]
tCarPitSetupValue suspreboundthreshold[4]
tdble height
Max height for curbs.
tTrackSeg * seg
Track segment.
tdble GfParmGetNum(void *handle, const char *path, const char *key, const char *unit, tdble deflt)
Get a numerical parameter from the parameter set handle.
Track segment (tTrackSeg) The segments can be straights (type TR_STR): (the track goes from the right...
int track(tModInfo *modInfo)
#define GFPARM_MMODE_RELSRC
release ref after the merge
#define TR_RGT
Right curve.
tdble toStart
Distance to start of segment (or arc if turn)
struct trackSeg * prev
Previous segment.
tTrackSurface * surface
Segment surface.
struct trackSeg * next
Next segment.
#define TR_LPOS_SEGMENT
Relative to the segment which the point is located, including border and sides, mostly used for conta...
#define GFPARM_MMODE_DST
use tgt and verify ref parameters
static void RtReadCarPitSetupEntry(tCarPitSetupValue *v, const char *path, const char *key, void *hdle, bool minmaxonly)
tCarPitSetupValue suspfastrebound[4]
#define TR_MAIN
Main track segment (ie road part)
#define SECT_REARDIFFERENTIAL
#define NORM_PI_PI(x)
Angle normalization between -PI and PI.
tCarPitSetupValue suspspring[4]
int style
Border and barrier segments style:
Track Structure and Track Loader Module Definition.
tCarPitSetupValue wheelcaster[4]
tCarPitSetupValue diffslipbias[3]
#define TR_LPOS_TRACK
Local position relative to the outermost barriers, mostly used for collision detection with barrier...
tdble kRoughWaveLen
Wave length in m of the surface.
#define GFPARM_RMODE_CREAT
Create the file if doesn't exist.
tCarPitSetupValue wheeltoe[4]
#define PRM_LOCKINGBRAKE_TQ
static const char * AxleSect[2]
#define GFPARM_MMODE_SRC
use ref and modify existing parameters with tgt
tCarPitSetupValue difflockinginputbraketq[3]