TORCS  1.3.9
The Open Racing Car Simulator
track4.cpp File Reference

Track loader for tracks of version 4. More...

#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <tgf.h>
#include <robottools.h>
#include <track.h>
#include <portability.h>
#include "trackinc.h"
Include dependency graph for track4.cpp:

Go to the source code of this file.

Macros

#define TSTX(x)
 
#define TSTY(y)
 
#define TSTZ(z)
 
#define MAX_TMP_INTS   256
 

Functions

static void initSideForTurn (const int turntype, tTrackSeg *const curBorder, const tTrackSeg *const curSeg, const int side, const int bankingtype, const tdble startwidth, const tdble endwidth, const tdble maxwidth)
 Set up side and border track segments for turns. More...
 
static void initSideForStraight (tTrackSeg *const curBorder, const tTrackSeg *const curSeg, const int side, const int bankingtype, const tdble startwidth, const tdble endwidth)
 Set up side and border track segments for straight segments. More...
 
static tTrackSegcommonSideInit (tTrackSeg *const curSeg, const int side, const int lefttype, const int righttype, const int bankingtype, const tdble startwidth, const tdble endwidth, tTrackSurface *surface, const tdble borderheight, const int borderstyle)
 Common side/border allocation and initialization for straights and turns. More...
 
static tTrackSurfacegetTrackSurface (void *trackHandle, tTrack *theTrack, const char *material)
 Gets surface properties based on the material. More...
 
static void readDefaultSideParameters (void *trackHandle, tTrack *theTrack)
 Reads default side/border track segment parameters. More...
 
static void addSides (tTrackSeg *curSeg, void *trackHandle, tTrack *theTrack, int curStep, int steps)
 Adds the specified side/border/barrier segments to given main track segement. More...
 
static void normSeg (tTrackSeg *curSeg)
 Segment coordinate normalization, track is moved to the origin of the coordinate system. More...
 
static void CreateSegRing (void *TrackHandle, tTrack *theTrack, int ext)
 
void ReadTrack4 (tTrack *theTrack, void *TrackHandle, tRoadCam **camList, int ext)
 
static void updateMinMaxForTurn (const tTrackSeg *const curBorder, const tdble radius, const tdble sign, const tdble z)
 Update global min/max values for turns (discretized approximation). More...
 
static void initAnglesAndGradients (tTrackSeg *const curBorder, const tdble startwidth, const tdble endwidth)
 Set up border segment angles and gradients. More...
 

Variables

static tdble xmin
 
static tdble xmax
 
static tdble ymin
 
static tdble ymax
 
static tdble zmin
 
static tdble zmax
 
static const char * SectSide [2] = {TRK_SECT_RSIDE, TRK_SECT_LSIDE}
 
static const char * SectBorder [2] = {TRK_SECT_RBORDER, TRK_SECT_LBORDER}
 
static const char * SectBarrier [2] = {TRK_SECT_RBARRIER, TRK_SECT_LBARRIER}
 
static const char * ValStyle [] = {TRK_VAL_PLAN, TRK_VAL_CURB, TRK_VAL_WALL, TRK_VAL_FENCE, TRK_VAL_FENCE}
 
static tdble sideEndWidth [2]
 
static tdble sideStartWidth [2]
 
static int sideBankType [2]
 
static const char * sideMaterial [2]
 
static tTrackSurfacesideSurface [2]
 
static int envIndex
 
static tdble DoVfactor =1.0
 
static tdble borderWidth [2]
 
static tdble borderHeight [2]
 
static int borderStyle [2]
 
static const char * borderMaterial [2]
 
static tTrackSurfaceborderSurface [2]
 
static tdble barrierWidth [2]
 
static tdble barrierHeight [2]
 
static int barrierStyle [2]
 
static const char * barrierMaterial [2]
 
static tTrackSurfacebarrierSurface [2]
 
static tdble GlobalStepLen = 0
 

Detailed Description

Track loader for tracks of version 4.

Author
Bernhard Wymann, Eric Espie
Version
$Id$

Definition in file track4.cpp.

Macro Definition Documentation

◆ MAX_TMP_INTS

#define MAX_TMP_INTS   256

◆ TSTX

#define TSTX (   x)
Value:
do { \
if (xmin > (x)) xmin = (x); \
if (xmax < (x)) xmax = (x); \
} while (0)
static tdble xmax
Definition: track4.cpp:36
static tdble xmin
Definition: track4.cpp:36

Definition at line 38 of file track4.cpp.

◆ TSTY

#define TSTY (   y)
Value:
do { \
if (ymin > (y)) ymin = (y); \
if (ymax < (y)) ymax = (y); \
} while (0)
static tdble ymax
Definition: track4.cpp:36
static tdble ymin
Definition: track4.cpp:36
static Vector y[4]
Definition: Convex.cpp:56

Definition at line 43 of file track4.cpp.

◆ TSTZ

#define TSTZ (   z)
Value:
do { \
if (zmin > (z)) zmin = (z); \
if (zmax < (z)) zmax = (z); \
} while (0)
static tdble zmax
Definition: track4.cpp:36
static tdble zmin
Definition: track4.cpp:36

Definition at line 48 of file track4.cpp.

Function Documentation

◆ addSides()

static void addSides ( tTrackSeg curSeg,
void *  trackHandle,
tTrack theTrack,
int  curStep,
int  steps 
)
static

Adds the specified side/border/barrier segments to given main track segement.

Parameters
[in,out]curSegMain track segment to process
[in]trackHandleHandle to track parameter set
[in]theTrackPointer to track structure
[in]curStepCurrent step (for segment subdivision)
[in]stepsNumber of steps (segment subdivisions)

Definition at line 235 of file track4.cpp.

Here is the call graph for this function:

◆ commonSideInit()

static tTrackSeg * commonSideInit ( tTrackSeg *const  curSeg,
const int  side,
const int  lefttype,
const int  righttype,
const int  bankingtype,
const tdble  startwidth,
const tdble  endwidth,
tTrackSurface surface,
const tdble  borderheight,
const int  borderstyle 
)
static

Common side/border allocation and initialization for straights and turns.

Parameters
[in,out]curSegSegment to attach the new side/border
[in]side0 for right side, 1 for left side (TRK_SECT_RSIDE, TRK_SECT_LSIDE)
[in]lefttypeFor side: TR_LSIDE, for border: TR_LBORDER
[in]righttypeFor side: TR_RSIDE, for border: TR_RBORDER
[in]bankingtypeFor TRK_VAL_TANGENT 1, for TRK_VAL_LEVEL 0
[in]startwidthStart width of the side/border
[in]endwidthEnd width of the side/border
[in]surfaceSurface for the side/border
[in]borderheightBorder height for borders, should usually be 0.0 for sides
[in]borderstyleType of segment, for sides always TR_PLAN, for borders either TR_PLAN, TR_CURB or TR_WALL
Returns
Pointer to the newly created side/border segment

Definition at line 1438 of file track4.cpp.

Here is the call graph for this function:

◆ CreateSegRing()

static void CreateSegRing ( void *  TrackHandle,
tTrack theTrack,
int  ext 
)
static

Definition at line 390 of file track4.cpp.

Here is the call graph for this function:

◆ getTrackSurface()

static tTrackSurface* getTrackSurface ( void *  trackHandle,
tTrack theTrack,
const char *  material 
)
static

Gets surface properties based on the material.

If the material is not known, then a new material is created, initialized and attached to tTrack.

Parameters
[in]trackHandleHandle to track parameter set
[in,out]theTrackPointer to track structure
[in]materialMaterial name of the surface
Returns
tTrackSurface* for the material

Definition at line 130 of file track4.cpp.

Here is the call graph for this function:

◆ initAnglesAndGradients()

static void initAnglesAndGradients ( tTrackSeg *const  curBorder,
const tdble  startwidth,
const tdble  endwidth 
)
static

Set up border segment angles and gradients.

Parameters
[in,out]curBorderBorder segment to set up
[in]startwidthStart width of the border
[in]endwidthEnd width of the border

Definition at line 1276 of file track4.cpp.

◆ initSideForStraight()

static void initSideForStraight ( tTrackSeg *const  curBorder,
const tTrackSeg *const  curSeg,
const int  side,
const int  bankingtype,
const tdble  startwidth,
const tdble  endwidth 
)
static

Set up side and border track segments for straight segments.

Border segments are the ones touching the main segment (e.g. curbs), side segments are the segments touching the barrier.

Parameters
[in,out]curBorderBorder segment to set up
[in]curSegConnecting inner segment (e.g. main track segment for borders)
[in]side0 for right side, 1 for left side (TRK_SECT_RSIDE, TRK_SECT_LSIDE)
[in]bankingtypeFor TRK_VAL_TANGENT 1, for TRK_VAL_LEVEL 0
[in]startwidthStart width of the border
[in]endwidthEnd width of the border

Definition at line 1376 of file track4.cpp.

◆ initSideForTurn()

static void initSideForTurn ( const int  turntype,
tTrackSeg *const  curBorder,
const tTrackSeg *const  curSeg,
const int  side,
const int  bankingtype,
const tdble  startwidth,
const tdble  endwidth,
const tdble  maxwidth 
)
static

Set up side and border track segments for turns.

Border segments are the ones touching the main segment (e.g. curbs), side segments are the segments touching the barrier.

Parameters
[in]turntypeTurn type, either TR_LFT or TR_RGT
[in,out]curBorderBorder segment to set up
[in]curSegConnecting inner segment (e.g. main track segment for borders)
[in]side0 for right side, 1 for left side (TRK_SECT_RSIDE, TRK_SECT_LSIDE)
[in]bankingtypeFor TRK_VAL_TANGENT 1, for TRK_VAL_LEVEL 0
[in]startwidthStart width of the border
[in]endwidthEnd width of the border
[in]maxwidthMaximum width of the border

Definition at line 1301 of file track4.cpp.

Here is the call graph for this function:

◆ normSeg()

static void normSeg ( tTrackSeg curSeg)
static

Segment coordinate normalization, track is moved to the origin of the coordinate system.

Parameters
[in,out]curSegSegment to normalize

Definition at line 371 of file track4.cpp.

◆ readDefaultSideParameters()

static void readDefaultSideParameters ( void *  trackHandle,
tTrack theTrack 
)
static

Reads default side/border track segment parameters.

Parameters
[in]trackHandleHandle to track parameter set
[in,out]theTrackPointer to track structure

Definition at line 172 of file track4.cpp.

Here is the call graph for this function:

◆ ReadTrack4()

void ReadTrack4 ( tTrack theTrack,
void *  TrackHandle,
tRoadCam **  camList,
int  ext 
)

Definition at line 898 of file track4.cpp.

Here is the call graph for this function:

◆ updateMinMaxForTurn()

static void updateMinMaxForTurn ( const tTrackSeg *const  curBorder,
const tdble  radius,
const tdble  sign,
const tdble  z 
)
static

Update global min/max values for turns (discretized approximation).

Parameters
[in]curBorderBorder segment
[in]radiusRadius to hand over, either curBorder->radiusl or curBorder->radiusr
[in]signSign to consider turn type (TR_LFT or TR_RGT)
[in]zZ value

Definition at line 1250 of file track4.cpp.

Here is the call graph for this function:

Variable Documentation

◆ barrierHeight

tdble barrierHeight[2]
static

Definition at line 78 of file track4.cpp.

◆ barrierMaterial

const char* barrierMaterial[2]
static

Definition at line 80 of file track4.cpp.

◆ barrierStyle

int barrierStyle[2]
static

Definition at line 79 of file track4.cpp.

◆ barrierSurface

tTrackSurface* barrierSurface[2]
static

Definition at line 81 of file track4.cpp.

◆ barrierWidth

tdble barrierWidth[2]
static

Definition at line 77 of file track4.cpp.

◆ borderHeight

tdble borderHeight[2]
static

Definition at line 72 of file track4.cpp.

◆ borderMaterial

const char* borderMaterial[2]
static

Definition at line 74 of file track4.cpp.

◆ borderStyle

int borderStyle[2]
static

Definition at line 73 of file track4.cpp.

◆ borderSurface

tTrackSurface* borderSurface[2]
static

Definition at line 75 of file track4.cpp.

◆ borderWidth

tdble borderWidth[2]
static

Definition at line 71 of file track4.cpp.

◆ DoVfactor

tdble DoVfactor =1.0
static

Definition at line 69 of file track4.cpp.

◆ envIndex

int envIndex
static

Definition at line 68 of file track4.cpp.

◆ GlobalStepLen

tdble GlobalStepLen = 0
static

Definition at line 83 of file track4.cpp.

◆ SectBarrier

const char* SectBarrier[2] = {TRK_SECT_RBARRIER, TRK_SECT_LBARRIER}
static

Definition at line 58 of file track4.cpp.

◆ SectBorder

const char* SectBorder[2] = {TRK_SECT_RBORDER, TRK_SECT_LBORDER}
static

Definition at line 57 of file track4.cpp.

◆ SectSide

const char* SectSide[2] = {TRK_SECT_RSIDE, TRK_SECT_LSIDE}
static

Definition at line 56 of file track4.cpp.

◆ sideBankType

int sideBankType[2]
static

Definition at line 64 of file track4.cpp.

◆ sideEndWidth

tdble sideEndWidth[2]
static

Definition at line 62 of file track4.cpp.

◆ sideMaterial

const char* sideMaterial[2]
static

Definition at line 65 of file track4.cpp.

◆ sideStartWidth

tdble sideStartWidth[2]
static

Definition at line 63 of file track4.cpp.

◆ sideSurface

tTrackSurface* sideSurface[2]
static

Definition at line 66 of file track4.cpp.

◆ ValStyle

const char* ValStyle[] = {TRK_VAL_PLAN, TRK_VAL_CURB, TRK_VAL_WALL, TRK_VAL_FENCE, TRK_VAL_FENCE}
static

Definition at line 60 of file track4.cpp.

◆ xmax

tdble xmax
static

Definition at line 36 of file track4.cpp.

◆ xmin

tdble xmin
static

Definition at line 36 of file track4.cpp.

◆ ymax

tdble ymax
static

Definition at line 36 of file track4.cpp.

◆ ymin

tdble ymin
static

Definition at line 36 of file track4.cpp.

◆ zmax

tdble zmax
static

Definition at line 36 of file track4.cpp.

◆ zmin

tdble zmin
static

Definition at line 36 of file track4.cpp.