1 /***************************************************************************
2 
3     file                 : track.h
4     created              : Sun Jan 30 23:00:06 CET 2000
5     copyright            : (C) 2000-2014 by Eric Espie, Bernhard Wymann
6     email                : torcs@free.fr
7     version              : $Id: track.h,v 1.22.2.5 2014/05/19 15:43:36 berniw Exp $
8 
9  ***************************************************************************/
10 
11 /***************************************************************************
12  *                                                                         *
13  *   This program is free software; you can redistribute it and/or modify  *
14  *   it under the terms of the GNU General Public License as published by  *
15  *   the Free Software Foundation; either version 2 of the License, or     *
16  *   (at your option) any later version.                                   *
17  *                                                                         *
18  ***************************************************************************/
19 
20 /** @file
21     Track Structure and Track Loader Module Definition.
22     @author	<a href=mailto:torcs@free.fr>Bernhard Wymann, Eric Espie</a>
23     @version	$Id: track.h,v 1.22.2.5 2014/05/19 15:43:36 berniw Exp $
24     @ingroup trackstruct
25     @ingroup trackmodint
26 */
27 
28 /**
29    @defgroup trackmodint Track Loader Module Interface
30    @brief Interface for track loader modules, the track loader module is discovered and loaded during runtime.
31    @ingroup	modint
32 */
33 
34 #ifndef _TRACKV1_H_
35 #define _TRACKV1_H_
36 
37 #include <tgf.h>
38 #include <tmath/linalg_t.h>
39 
40 #define TRK_IDENT	0	/* from 0x01 to 0xFF */
41 
42 /* Parameters strings for track files */
43 
44 #define TRK_SECT_HDR	"Header"
45 
46 #define TRK_ATT_WIDTH	"width"
47 #define TRK_ATT_SURF	"surface"
48 #define TRK_ATT_NAME	"name"
49 #define TRK_ATT_VERSION	"version"
50 #define TRK_ATT_AUTHOR	"author"
51 #define TRK_ATT_DESCR	"description"
52 #define TRK_ATT_CAT     "category"
53 
54 #define TRK_SECT_GRAPH	"Graphic"
55 
56 #define TRK_ATT_3DDESC	"3d description"
57 #define TRK_ATT_BKGRND	"background image"
58 #define TRK_ATT_BKGRND2	"background image2"
59 #define TRK_ATT_BGTYPE	"background type"
60 #define TRK_ATT_BGCLR_R	"background color R"
61 #define TRK_ATT_BGCLR_G	"background color G"
62 #define TRK_ATT_BGCLR_B	"background color B"
63 #define TRK_LST_ENV	"Environment Mapping"
64 #define TRK_ATT_ENVNAME	"env map image"
65 #define TRK_ATT_SPEC_R	"specular color R"
66 #define TRK_ATT_SPEC_G	"specular color G"
67 #define TRK_ATT_SPEC_B	"specular color B"
68 #define TRK_ATT_AMBIENT_R	"ambient color R"
69 #define TRK_ATT_AMBIENT_G	"ambient color G"
70 #define TRK_ATT_AMBIENT_B	"ambient color B"
71 #define TRK_ATT_DIFFUSE_R	"diffuse color R"
72 #define TRK_ATT_DIFFUSE_G	"diffuse color G"
73 #define TRK_ATT_DIFFUSE_B	"diffuse color B"
74 #define TRK_ATT_SHIN	"shininess"
75 #define TRK_ATT_LIPOS_X	"light position x"
76 #define TRK_ATT_LIPOS_Y	"light position y"
77 #define TRK_ATT_LIPOS_Z	"light position z"
78 #define TRK_ATT_FOVFACT	"fov factor"
79 
80 #define TRK_SECT_TURNMARKS "Graphic/Turn Marks"
81 #define TRK_ATT_HSPACE	"horizontal space"
82 #define TRK_ATT_VSPACE	"vertical space"
83 
84 #define TRK_SECT_TERRAIN  "Graphic/Terrain Generation"
85 
86 #define TRK_ATT_TSTEP	"track step"
87 #define TRK_ATT_BMARGIN	"border margin"
88 #define TRK_ATT_BSTEP	"border step"
89 #define TRK_ATT_ORIENT	"orientation"
90 #define TRK_VAL_CLOCK	"clockwise"
91 #define TRK_VAL_CCLOCK	"counter-clockwise"
92 #define TRK_ATT_SURFRAND	"texture randomness"
93 #define TRK_ATT_RELIEF	"relief file"
94 #define TRK_ATT_ELEVATION	"elevation map"
95 #define TRK_ATT_ALT_MAX	"maximum altitude"
96 #define TRK_ATT_ALT_MIN	"minimum altitude"
97 #define TRK_ATT_GRPSZ   "group size"
98 #define TRK_ATT_OBJMAP	"object map"
99 #define TRK_ATT_COLOR	"color"
100 #define TRK_ATT_OBJECT	"object"
101 #define TRK_ATT_SEED	"random seed"
102 #define TRK_ATT_ORIENTATION_TYPE "orientation type"
103 #define TRK_ATT_ORIENTATION "orientation"
104 #define TRK_ATT_DH	"delta height"
105 #define TRK_ATT_DV	"delta vert"
106 #define TRK_SECT_OBJMAP	"Object Maps"
107 #define TRK_SECT_SURFACES "Surfaces"
108 #define TRK_SECT_OBJECTS  "Objects"
109 
110 #define TRK_ATT_FRICTION "friction"
111 #define TRK_ATT_ROLLRES  "rolling resistance"
112 #define TRK_ATT_ROUGHT   "roughness"
113 #define TRK_ATT_ROUGHTWL "roughness wavelength"
114 #define TRK_ATT_DAMMAGE  "dammage"
115 #define TRK_ATT_REBOUND  "rebound"
116 #define TRK_ATT_TEXTURE  "texture name"
117 #define TRK_ATT_BUMPNAME "bump name"
118 #define TRK_ATT_RACELINENAME "raceline name"
119 #define TRK_ATT_TEXTYPE  "texture type"
120 #define TRK_ATT_TEXLINK  "texture link with previous"
121 #define TRK_ATT_TEXSIZE  "texture size"
122 #define TRK_ATT_BUMPSIZE "bump size"
123 #define TRK_ATT_TEXSTARTBOUNDARY "texture start on boundary"
124 #define TRK_ATT_TEXMIPMAP "texture mipmap"
125 #define TRK_ATT_R1	 "color R1"
126 #define TRK_ATT_G1	 "color G1"
127 #define TRK_ATT_B1	 "color B1"
128 #define TRK_ATT_R2	 "color R2"
129 #define TRK_ATT_G2	 "color G2"
130 #define TRK_ATT_B2	 "color B2"
131 
132 #define TRK_ATT_STEPLEN	"steps length"
133 
134 #define TRK_VAL_YES	"yes"
135 #define TRK_VAL_NO	"no"
136 
137 #define TRK_SECT_MAIN	"Main Track"
138 #define TRK_LST_SEGMENTS	"Track Segments"
139 #define TRK_ATT_TYPE		"type"
140 #define TRK_ATT_RLEXT	"raceline ext"
141 #define TRK_ATT_RLINT	"raceline int"
142 #define TRK_ATT_RLWIDTHSCALE "raceline widthscale"
143 
144 #define TRK_VAL_STR		"str"
145 #define TRK_VAL_LFT		"lft"
146 #define TRK_VAL_RGT		"rgt"
147 
148 #define TRK_ATT_LG		"lg"
149 #define TRK_ATT_RADIUS		"radius"
150 #define TRK_ATT_RADIUSEND	"end radius"
151 #define TRK_ATT_ARC		"arc"
152 #define TRK_ATT_ZS		"z start"
153 #define TRK_ATT_ZE		"z end"
154 #define TRK_ATT_ZSL		"z start left"
155 #define TRK_ATT_ZSR		"z start right"
156 #define TRK_ATT_ZEL		"z end left"
157 #define TRK_ATT_ZER		"z end right"
158 #define TRK_ATT_GRADE		"grade"
159 #define TRK_ATT_BKS		"banking start"
160 #define TRK_ATT_BKE		"banking end"
161 #define TRK_ATT_ID		"id"
162 #define TRK_ATT_PROFIL		"profil"
163 #define TRK_ATT_PROFSTEPS	"profil steps"
164 #define TRK_ATT_PROFSTEPSLEN	"profil steps length"
165 #define TRK_ATT_PROFTGTS	"profil start tangent"
166 #define TRK_ATT_PROFTGTE	"profil end tangent"
167 #define TRK_ATT_PROFTGTSL	"profil start tangent left"
168 #define TRK_ATT_PROFTGTEL	"profil end tangent left"
169 #define TRK_ATT_PROFTGTSR	"profil start tangent right"
170 #define TRK_ATT_PROFTGTER	"profil end tangent right"
171 #define TRK_ATT_MARKS		"marks"
172 #define TRK_ATT_ENVMAP		"env map"
173 #define TRK_ATT_DOVFACTOR	"DoV factor"
174 
175 #define TRK_SECT_PITS		"Pits"
176 
177 #define TRK_ATT_ENTRY		"entry"
178 #define TRK_ATT_EXIT		"exit"
179 #define TRK_ATT_START		"start"
180 #define TRK_ATT_END		"end"
181 #define TRK_ATT_SIDE		"side"
182 #define TRK_ATT_LEN		"length"
183 #define TRK_ATT_SPD_LIM		"speed limit"
184 
185 #define TRK_SECT_LSIDE		"Left Side"
186 #define TRK_SECT_RSIDE		"Right Side"
187 #define TRK_SECT_LBORDER	"Left Border"
188 #define TRK_SECT_RBORDER	"Right Border"
189 #define TRK_SECT_LBARRIER	"Left Barrier"
190 #define TRK_SECT_RBARRIER	"Right Barrier"
191 
192 #define TRK_ATT_SWIDTH		"start width"
193 #define TRK_ATT_EWIDTH		"end width"
194 #define TRK_ATT_STYLE		"style"
195 #define TRK_ATT_HEIGHT		"height"
196 #define TRK_ATT_BANKTYPE	"banking type"
197 
198 #define TRK_VAL_PLAN		"plan"
199 #define TRK_VAL_WALL		"wall"
200 #define TRK_VAL_CURB		"curb"
201 #define TRK_VAL_FENCE		"fence"
202 
203 
204 #define TRK_SECT_CAM		"Cameras"
205 
206 #define TRK_ATT_SEGMENT		"segment"
207 #define TRK_ATT_TORIGHT 	"to right"
208 #define TRK_ATT_TOSTART 	"to start"
209 #define TRK_ATT_HEIGHT  	"height"
210 #define TRK_ATT_CAM_FOV 	"fov start"
211 #define TRK_ATT_CAM_FOVE 	"fov end"
212 
213 #define TRK_VAL_ASPHALT		"asphalt"
214 #define TRK_VAL_CONCRETE	"concrete"
215 #define TRK_VAL_GRASS		"grass"
216 #define TRK_VAL_SAND		"sand"
217 #define TRK_VAL_DIRT		"dirt"
218 #define TRK_VAL_BARRIER		"barrier"
219 
220 #define TRK_VAL_LINEAR		"linear"
221 #define TRK_VAL_SPLINE		"spline"
222 
223 #define TRK_VAL_TANGENT		"tangent"
224 #define TRK_VAL_LEVEL		"level"
225 
226 /** road camera */
227 typedef struct RoadCam
228 {
229     char		*name;
230     t3Dd		pos;
231     struct RoadCam	*next;
232 } tRoadCam;
233 
234 /** Extended track segment */
235 typedef struct SegExt
236 {
237     int		nbMarks;	/**< turn marks */
238     int		*marks;		/**< marks array */
239 } tSegExt;
240 
241 
242 /** Surface */
243 typedef struct trackSurface {
244     struct trackSurface *next;	/**< Next surface in list */
245 
246     const char *material;		/**< Type of material used */
247 
248     tdble kFriction;		/**< Coefficient of friction */
249     tdble kRebound;		/**< Coefficient of energy restitution */
250     tdble kRollRes;		/**< Rolling resistance */
251     tdble kRoughness;		/**< Roughtness in m of the surface (wave height) */
252     tdble kRoughWaveLen;	/**< Wave length in m of the surface */
253     tdble kDammage;		/**< Dammages in case of collision */
254 
255 } tTrackSurface;
256 
257 
258 
259 /** Barrier */
260 typedef struct trackBarrier {
261     int			style;	/**< Barrier style */
262     tdble		width;	/**< Barrier width */
263     tdble		height;	/**< Barrier height */
264     tTrackSurface	*surface; /**< Barrier surface */
265 	vec2f normal;	// Normal on the vertical track inside pointing towards the track middle.
266 } tTrackBarrier;
267 
268 
269 /** Track segment (tTrackSeg)
270     The segments can be straights (type TR_STR): (the track goes from the right to the left)
271     @image html straight-desc.png
272     Or can be turn segments (type TR_RGT or TR_LFT): (the track goes from the left to the right)
273     @image html turn-1-desc.png
274     The reference angle is the orientation of the first segment of the track.
275     @ingroup trackstruct
276 */
277 typedef struct trackSeg {
278     const char *name;			/**< Segment name */
279     int	id;			/**< Segment number */
280 
281     int type;			/**< Geometrical type:
282 				 - TR_RGT
283 				 - TR_LFT
284 				 - TR_STR
285 				*/
286 #define TR_RGT	    1		/**< Right curve */
287 #define TR_LFT	    2		/**< Left curve */
288 #define TR_STR	    3		/**< Straight */
289 
290     int type2;			/**< Position type:
291 				   - TR_MAIN
292 				   - TR_LSIDE
293 				   - TR_RSIDE
294 				   - TR_LBORDER
295 				   - TR_RBORDER
296 				*/
297 #define TR_MAIN	    1		/**< Main track segment (ie road part) */
298 #define TR_LSIDE    2		/**< Left side segment (outer segment) */
299 #define TR_RSIDE    3		/**< Right side segment (outer segment) */
300 #define TR_LBORDER  4		/**< Left border segment (inner segment) */
301 #define TR_RBORDER  5		/**< Right border segment (inner segment) */
302 
303     int style;			/**< Border and barrier segments style:
304 				   - TR_PLAN
305 				   - TR_CURB
306 				   - TR_WALL
307 				   - TR_FENCE
308 				   - TR_PITBUILDING
309 				 */
310 #define TR_PLAN		0	/**< Flat (border only) */
311 #define TR_CURB		1	/**< Curb (border only) */
312 #define TR_WALL		2	/**< Wall (barrier only) */
313 #define TR_FENCE	3	/**< Fence (no width) (barrier only) */
314 #define TR_PITBUILDING	4	/**< Pit building wall (barrier only) */
315 
316     tdble length;		/**< Length in meters of the middle of the track */
317     tdble width;		/**< Width of the segment (if constant width) */
318     tdble startWidth;		/**< Width of the beginning of the segment */
319     tdble endWidth;		/**< Width of the end of the segment */
320     tdble lgfromstart;		/**< Length of begining of segment from starting line */
321     tdble radius;		/**< Radius in meters of the middle of the track (>0) */
322     tdble radiusr;		/**< Radius in meters of the right side of the track (>0) */
323     tdble radiusl;		/**< Radius in meters of the left side of the track (>0) */
324     tdble arc;			/**< Arc in rad of the curve (>0) */
325     t3Dd center;		/**< Center of the curve */
326     t3Dd vertex[4];		/**< Coord of the 4 corners of the segment.
327 				   <br>Index in:
328 				   - TR_SL
329 				   - TR_SL
330 				   - TR_EL
331 				   - TR_ER
332 				 */
333 #define TR_SL	0		/**< Start-Left corner */
334 #define TR_SR	1		/**< Start-Right corner */
335 #define TR_EL	2		/**< End-Left corner */
336 #define TR_ER	3		/**< End_Right corner */
337 
338     tdble angle[7];		/** Rotation angles of the track in rad anti-clockwise:
339 				    <br>Index in:
340 				   - TR_ZS
341 				   - TR_ZE
342 				   - TR_YL
343 				   - TR_YR
344 				   - TR_XS
345 				   - TR_XE
346 				   - TR_CS
347 				 */
348 #define TR_ZS	0		/**< Z Start angle */
349 #define TR_ZE	1		/**< Z End angle */
350 #define TR_YL	2		/**< Y Left angle */
351 #define TR_YR	3		/**< Y Right angle */
352 #define TR_XS	4		/**< X Start angle */
353 #define TR_XE	5		/**< X End angle */
354 #define TR_CS   6		/**< Center start angle */
355 
356     /* constants used to find the height of a point */
357     tdble Kzl;		/* long constant */
358     tdble Kzw;		/* width constant */
359     /* constant used to find the width of a segment */
360     tdble	Kyl;		/* find y along x */
361     t3Dd	rgtSideNormal;	/* normal to the right side in case of straight segment */
362     int		envIndex;	/* Environment mapping image index */
363 
364     tdble	height;		/**< Max height for curbs */
365 
366     unsigned int raceInfo;	/**< Type of segment regarding the race:
367 				   <br>Mask value in:
368 				   - TR_NORMAL
369 				   - TR_LAST
370 				   - TR_START
371 				   - TR_PITLANE
372 				   - TR_SPEEDLIMIT
373 				   - TR_PITENTRY
374 				   - TR_PITEXIT
375 				   - TR_PIT
376 				*/
377 #define TR_NORMAL	0x00000000 /**< Normal segment */
378 #define TR_LAST		0x00000001 /**< Segment before start line */
379 #define TR_START	0x00000002 /**< Segment after start line */
380 #define TR_PITLANE	0x00000004 /**< Pit lane segment */
381 #define TR_SPEEDLIMIT	0x00000008 /**< Segment where the speed is limited */
382 #define TR_PITENTRY	0x00000010 /**< Segment where the pit lane cross the main track */
383 #define TR_PITEXIT	0x00000020 /**< Segment where the pit lane cross the main track */
384 #define TR_PIT		0x00000040 /**< Car pit */
385 #define TR_PITSTART	0x00000080 /**< Car pit Star */
386 #define TR_PITEND	0x00000100 /**< Car pit End */
387 
388     tdble DoVfactor;            /* the factor to use in calculating DoV for this Seg */
389 
390     /* pointers */
391 
392     /* optionnal extensions */
393     tSegExt		*ext;
394 
395     tTrackSurface	*surface; /**< Segment surface */
396 	tTrackBarrier	*barrier[2]; /**< Segment barriers */
397     tRoadCam        *cam;	/* current camera */
398     struct trackSeg *next;	/**< Next segment */
399     struct trackSeg *prev;	/**< Previous segment */
400 
401 	// Union to avoid code duplication for left/right side cases and to
402 	// keep compatibility of code. The side definition is so ugly to
403 	// match the one of the barrier[].
404 #define TR_SIDE_LFT 1
405 #define TR_SIDE_RGT 0
406 	union {
407 		struct { struct trackSeg *rside, *lside; };
408 		struct trackSeg* side[2];
409 	};
410 
411 } tTrackSeg;
412 
413 /* selection for local position structure */
414 #define TR_TORIGHT	0
415 #define TR_TOMIDDLE	1
416 #define TR_TOLEFT	2
417 
418 /** Location on the track in local coordinates */
419 typedef struct
420 {
421     tTrackSeg	*seg;		/**< Track segment */
422     int		type;		/**< Type of description:
423 				   - TR_LPOS_MAIN
424 				   - TR_LPOS_SEGMENT
425 				   - TR_LPOS_TRACK
426 				 */
427 
428 #define TR_LPOS_MAIN	0	/**< Relative to the main segment */
429 #define TR_LPOS_SEGMENT	1	/**< If the point is on a side, relative to this side */
430 #define TR_LPOS_TRACK	2	/**< Local pos includes all the track width */
431 
432     tdble	toStart;	/**< Distance to start of segment (or arc if turn) */
433     tdble	toRight;	/**< Distance to right side of segment (+ to inside of track - to outside) */
434     tdble	toMiddle;	/**< Distance to middle of segment (+ to left - to right) */
435     tdble	toLeft;		/**< Distance to left side of segment (+ to inside of track - to outside) */
436 } tTrkLocPos;
437 
438 struct CarElt;
439 
440 /** Driver's pit */
441 typedef struct TrackOwnPit
442 {
443 	tTrkLocPos pos;	/**< Center of the pit position */
444 	int pitCarIndex;	/**< Index of the car in the car array below which occupies the pit. If the pit is free the value is TR_PIT_STATE_FREE */
445 #define TR_PIT_STATE_FREE	-1
446 #define TR_PIT_MAXCARPERPIT 4		// maximum cars per pit
447 	tdble lmin;	/**< Pitting area length min */
448 	tdble lmax;	/**< Pitting area length max */
449 	int freeCarIndex;	// Index of next free car entry (look at the next line).
450 	struct CarElt	*car[TR_PIT_MAXCARPERPIT];	/**< Car links for pit */
451 } tTrackOwnPit;
452 
453 /** Pits Info Structure */
454 typedef struct
455 {
456 	int type;		/**< Type of Pit:
457 				   - TR_PIT_NONE
458 				   - TR_PIT_ON_TRACK_SIDE
459 				 */
460 #define TR_PIT_NONE		0 /**< No pits for that tracks */
461 #define TR_PIT_ON_TRACK_SIDE	1 /**< The pits are on the track side */
462 #define TR_PIT_ON_SEPARATE_PATH 2
463 	int nMaxPits;	/**< number max of pits */
464 	int nPitSeg;	/**< actual number of pits */
465 	int side;		/**< Pits side:
466 				   - TR_RGT
467 				   - TR_LFT
468 				*/
469 	tdble len;					/**< Lenght of each pit stop */
470 	tdble width;				/**< Width of each pit stop */
471 	tdble speedLimit;			/**< Speed limit between pitStart and pitEnd */
472 	tTrackSeg *pitEntry;		/**< Pit lane segment */
473 	tTrackSeg *pitStart;		/**< Pit lane segment */
474 	tTrackSeg *pitEnd;			/**< Pit lane segment */
475 	tTrackSeg *pitExit;			/**< Pit lane segment */
476 	tTrackOwnPit *driversPits;	/**< List of pits by driver */
477 	int carsPerPit;
478 	int driversPitsNb;			/**< Number of drivers */
479 } tTrackPitInfo;
480 
481 typedef struct
482 {
483     tdble	height;
484     tdble	width;
485     tdble	hSpace;
486     tdble	vSpace;
487 } tTurnMarksInfo;
488 
489 typedef struct
490 {
491     const char *background;
492     char		*background2;
493     int			bgtype;
494     float		bgColor[3];
495     int			envnb;
496     const char		**env;
497     tTurnMarksInfo	turnMarksInfo;
498 } tTrackGraphicInfo;
499 
500 /** Track structure
501     @ingroup trackstruct
502 */
503 typedef struct
504 {
505     const char *name;	/**< Name of the track */
506     const char *author;	/**< Author's name */
507     char	  *filename;	/**< Filename of the track description */
508     void	  *params;	/**< Parameters handle */
509     char	  *internalname; /**< Internal name of the track */
510     const char *category;	/**< Category of the track */
511     int		  nseg;		/**< Number of segments */
512     int		  version;	/**< Version of the track type */
513     tdble	  length;	/**< main track length */
514     tdble	  width;	/**< main track width */
515     tTrackPitInfo pits;		/**< Pits information */
516     tTrackSeg	  *seg;		/**< Main track */
517     tTrackSurface *surfaces;	/**< Segment surface list */
518 
519     t3Dd		min;
520     t3Dd		max;
521     tTrackGraphicInfo	graphic;
522 } tTrack;
523 
524 
525 /** @brief Read given track from @e filename into tTrack struct.
526  *  @ingroup trackmodint
527  *  @param[in] filename filename including path to file
528  *  @return tTrack structure on success
529  *  @note The given file must exist and must be correct
530  */
531 typedef tTrack*(*tfTrackBuild)(char* filename);
532 
533 /** @brief Returns the absolute height in meters of the road at the given global position.
534  *  @ingroup trackmodint
535  *  @param[in] seg Segment tTrackSeg to start search for coordinates
536  *  @param[in] X Global X coordinate
537  *  @param[in] Y Global Y coordinate
538  *  @return Height in meters
539  *  @see RtTrackHeightG
540  *  @see RtTrackHeightL
541  */
542 typedef tdble(*tfTrackHeightG)(tTrackSeg* seg, tdble X, tdble Y);
543 
544 /** @brief Returns the absolute height in meters of the road at the local position
545  *  @ingroup trackmodint
546  *  @param[in] pos tTrkLocPos containing the loacal position
547  *  @return Height in meters
548  *  @see RtTrackHeightL
549  */
550 typedef tdble(*tfTrackHeightL)(tTrkLocPos* pos);
551 
552 /** @brief Convert a global position (segment, X, Y) into a local position (segment, toRight, toStart)
553  *  @ingroup trackmodint
554  *  @param[in] seg	Segment tTrackSeg to start search for coordinates
555  *  @param[in] X Global X coordinate
556  *  @param[in] Y Global Y coordinate
557  *  @param[in,out] pos tTrkLocPos passed from the caller to fill in the local position
558  *  @param[in] type Type of local position desired:
559  *  - #TR_LPOS_MAIN Relative to the main segment
560  *  - #TR_LPOS_SEGMENT If the point is on a side, relative to this side
561  *  - #TR_LPOS_TRACK Local position includes all the track width (distance to barrier)
562  *  @see RtTrackGlobal2Local
563  */
564 typedef void(*tfTrackGlobal2Local)(tTrackSeg* seg, tdble X, tdble Y, tTrkLocPos* pos, int type);
565 
566 /** @brief Convert a local position (segment, toRight, toStart) into a global one (X, Y)
567  *  @ingroup trackmodint
568  *  @param[in] pos Local position
569  *  @param[in,out] X Pointer to tdble passed by the caller to fill in X position
570  *  @param[in,out] Y Pointer to tdble passed by the caller to fill in Y position
571  *  @see RtTrackLocal2Global
572  */
573 typedef void(*tfTrackLocal2Global)(tTrkLocPos* pos, tdble* X, tdble* Y);
574 
575 /** @brief Get the normal vector (in global coordinate system) of the border of the track including the sides.
576  *  @ingroup trackmodint
577  *  @param[in] seg Current segment
578  *  @param[in] X Global X position
579  *  @param[in] Y Global Y position
580  *  @param[in] side Side where the normal is wanted
581  *  - #TR_LFT for left side
582  *  - #TR_RGT for right side
583  *  @param[in,out] norm t3Dd passed from the caller to fill in the normalized side normal vector
584  *  @see RtTrackSideNormalG
585  */
586 typedef void(*tfTrackSideNormal)(tTrackSeg* seg, tdble X, tdble Y, int side, t3Dd* norm);
587 
588 /** @brief Get the normal vector of the road (pointing upward).
589  *  @ingroup trackmodint
590  *  @param[in] pos Local position
591  *  @param[in,out] norm t3Dd passed from the caller to fill in the normal vector
592  *  @see RtTrackSurfaceNormalL
593  */
594 typedef void(*tfTrackSurfaceNormal)(tTrkLocPos *pos, t3Dd* norm);
595 
596 /** @brief Release current track and all its resources
597  *  @ingroup trackmodint
598  */
599 typedef void(*tfTrackShutdown)(void);
600 
601 /** @brief Interface Structure for Track Loader
602  *  @ingroup trackmodint
603  */
604 typedef struct {
605 	tfTrackBuild			trkBuild;		/**< build track structure for simu */
606 	tfTrackBuild			trkBuildEx;		/**< build with graphic extensions (used by trackgen tool) */
607 	tfTrackHeightG			trkHeightG;
608 	tfTrackHeightL			trkHeightL;
609 	tfTrackGlobal2Local		trkGlobal2Local;
610 	tfTrackLocal2Global		trkLocal2Global;
611 	tfTrackSideNormal   	trkSideNormal;
612 	tfTrackSurfaceNormal	trkSurfaceNormal;
613 	tfTrackShutdown			trkShutdown;
614 } tTrackItf;
615 
616 
617 /* For Type 3 tracks (now obsolete) */
618 
619 #define TRK_LST_SURF			"List"
620 #define TRK_LST_CAM			"list"
621 #define TRK_ATT_PIT_ENTRY		"pit entry"
622 #define TRK_ATT_PIT_EXIT		"pit exit"
623 #define TRK_ATT_PIT_START		"pit start"
624 #define TRK_ATT_PIT_END			"pit end"
625 #define TRK_ATT_PIT_TYPE		"pit type"
626 #define TRK_ATT_PIT_SIDE		"pit side"
627 #define TRK_ATT_PIT_LEN			"pit length"
628 #define TRK_ATT_PIT_WIDTH		"pit width"
629 
630 #define TRK_LST_SEG	"segments"
631 #define TRK_ATT_ENVIND	"env map index"
632 
633 
634 #define TRK_ATT_LST	"lside type"
635 #define TRK_ATT_LSW	"lside width"
636 #define TRK_ATT_LSWS	"lside start width"
637 #define TRK_ATT_LSWE	"lside end width"
638 #define TRK_ATT_LSSURF	"lside surface"
639 #define TRK_ATT_RST	"rside type"
640 #define TRK_ATT_RSW	"rside width"
641 #define TRK_ATT_RSWS	"rside start width"
642 #define TRK_ATT_RSWE	"rside end width"
643 #define TRK_ATT_RSSURF	"rside surface"
644 #define TRK_ATT_LBS	"lborder style"
645 #define TRK_ATT_LBW	"lborder width"
646 #define TRK_ATT_LBH	"lborder height"
647 #define TRK_ATT_LBSURF	"lborder surface"
648 #define TRK_ATT_RBS	"rborder style"
649 #define TRK_ATT_RBW	"rborder width"
650 #define TRK_ATT_RBH	"rborder height"
651 #define TRK_ATT_RBSURF	"rborder surface"
652 
653 #define TRK_ATT_BHEIGHT	"border height"
654 
655 #define TRK_ATT_LBAS	"lbarrier style"
656 #define TRK_ATT_LBAW	"lbarrier width"
657 #define TRK_ATT_LBAH	"lbarrier height"
658 #define TRK_ATT_LBAFRCT	"lbarrier friction"
659 #define TRK_ATT_LBASURF	"lbarrier surface"
660 #define TRK_ATT_RBAS	"rbarrier style"
661 #define TRK_ATT_RBAW	"rbarrier width"
662 #define TRK_ATT_RBAH	"rbarrier height"
663 #define TRK_ATT_LBAFRCT	"lbarrier friction"
664 #define TRK_ATT_RBASURF	"rbarrier surface"
665 
666 #define TRK_VAL_PIT_TYPE_NONE		"no pit"
667 #define TRK_VAL_PIT_TYPE_SIDE		"track side"
668 #define TRK_VAL_PIT_TYPE_SEP_PATH	"seperate path"
669 
670 #define TRK_ATT_FINISH	"finish segment"
671 
672 #endif /* _TRACKV1_H_ */
673 
674 
675 
676