TORCS  1.3.10
The Open Racing Car Simulator
Loading...
Searching...
No Matches
track4.cpp File Reference

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

#include <stdlib.h>
#include <math.h>
#include <stdio.h>
#include <stdarg.h>
#include <limits>
#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 formatTrackPath (char *buffer, const int size, const char *format,...)
 Format a track parameter path and fail if it would be truncated.
static tTrackSeg * findFirstSegmentByName (const tTrack *track, const char *name)
static tTrackSeg * findLastSegmentByName (const tTrack *track, const char *name)
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.
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.
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)
 Common side/border allocation and initialization for straights and turns.
static tTrackSurface * getTrackSurface (void *trackHandle, tTrack *theTrack, const char *material)
 Gets surface properties based on the material.
static void readDefaultSideParameters (void *trackHandle, tTrack *theTrack)
 Reads default side/border track segment parameters.
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.
static void normSeg (tTrackSeg *curSeg)
 Segment coordinate normalization, track is moved to the origin of the coordinate system.
static void CreateSegRing (void *TrackHandle, tTrack *theTrack, int ext)
static void readGeoreference (tTrack *track, void *handle)
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).
static void initAnglesAndGradients (tTrackSeg *const curBorder, const tdble startwidth, const tdble endwidth)
 Set up border segment angles and gradients.

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 tTrackSurface * sideSurface [2]
static int envIndex
static tdble borderWidth [2]
static tdble borderHeight [2]
static int borderStyle [2]
static const char * borderMaterial [2]
static tTrackSurface * borderSurface [2]
static tdble barrierWidth [2]
static tdble barrierHeight [2]
static int barrierStyle [2]
static const char * barrierMaterial [2]
static tTrackSurface * barrierSurface [2]
static tdble GlobalStepLen = 0

Detailed Description

Track loader for tracks of version 4.

Author
Bernhard Wymann, Eric EspiƩ

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 xmin
Definition track3.cpp:30
static tdble xmax
Definition track3.cpp:30

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 Vector y[4]
Definition Convex.cpp:56
static tdble ymin
Definition track3.cpp:30
static tdble ymax
Definition track3.cpp:30

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 zmin
Definition track3.cpp:30
static tdble zmax
Definition track3.cpp:30

Definition at line 48 of file track4.cpp.

Function Documentation

◆ addSides()

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 297 of file track4.cpp.

Here is the call graph for this function:

◆ commonSideInit()

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 1522 of file track4.cpp.

Here is the call graph for this function:

◆ CreateSegRing()

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

Definition at line 458 of file track4.cpp.

Here is the call graph for this function:

◆ findFirstSegmentByName()

tTrackSeg * findFirstSegmentByName ( const tTrack * track,
const char * name )
static

Definition at line 94 of file track4.cpp.

Here is the call graph for this function:

◆ findLastSegmentByName()

tTrackSeg * findLastSegmentByName ( const tTrack * track,
const char * name )
static

Definition at line 107 of file track4.cpp.

Here is the call graph for this function:

◆ formatTrackPath()

void formatTrackPath ( char * buffer,
const int size,
const char * format,
... )
static

Format a track parameter path and fail if it would be truncated.

Truncated parameter paths would read unrelated or default track data, so track loading must stop instead of continuing with a partial path.

Parameters
[in,out]bufferbuffer for the formatted path
[in]sizebuffer size
[in]formatprintf-style format string

Definition at line 72 of file track4.cpp.

Here is the call graph for this function:

◆ getTrackSurface()

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 187 of file track4.cpp.

Here is the call graph for this function:

◆ initAnglesAndGradients()

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 1359 of file track4.cpp.

◆ initSideForStraight()

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 1460 of file track4.cpp.

◆ initSideForTurn()

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 1384 of file track4.cpp.

Here is the call graph for this function:

◆ normSeg()

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 439 of file track4.cpp.

◆ readDefaultSideParameters()

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 230 of file track4.cpp.

Here is the call graph for this function:

◆ readGeoreference()

void readGeoreference ( tTrack * track,
void * handle )
static

Definition at line 973 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 1018 of file track4.cpp.

Here is the call graph for this function:

◆ updateMinMaxForTurn()

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 1333 of file track4.cpp.

Here is the call graph for this function:

Variable Documentation

◆ barrierHeight

tdble barrierHeight[2]
static

Definition at line 135 of file track4.cpp.

◆ barrierMaterial

const char* barrierMaterial[2]
static

Definition at line 137 of file track4.cpp.

◆ barrierStyle

int barrierStyle[2]
static

Definition at line 136 of file track4.cpp.

◆ barrierSurface

tTrackSurface* barrierSurface[2]
static

Definition at line 138 of file track4.cpp.

◆ barrierWidth

tdble barrierWidth[2]
static

Definition at line 134 of file track4.cpp.

◆ borderHeight

tdble borderHeight[2]
static

Definition at line 129 of file track4.cpp.

◆ borderMaterial

const char* borderMaterial[2]
static

Definition at line 131 of file track4.cpp.

◆ borderStyle

int borderStyle[2]
static

Definition at line 130 of file track4.cpp.

◆ borderSurface

tTrackSurface* borderSurface[2]
static

Definition at line 132 of file track4.cpp.

◆ borderWidth

tdble borderWidth[2]
static

Definition at line 128 of file track4.cpp.

◆ envIndex

int envIndex
static

Definition at line 126 of file track4.cpp.

◆ GlobalStepLen

tdble GlobalStepLen = 0
static

Definition at line 140 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 122 of file track4.cpp.

◆ sideEndWidth

tdble sideEndWidth[2]
static

Definition at line 120 of file track4.cpp.

◆ sideMaterial

const char* sideMaterial[2]
static

Definition at line 123 of file track4.cpp.

◆ sideStartWidth

tdble sideStartWidth[2]
static

Definition at line 121 of file track4.cpp.

◆ sideSurface

tTrackSurface* sideSurface[2]
static

Definition at line 124 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.