Next: , Previous: Cars, Up: Top


1.6 Tracks

Once you get bored with the default, you might want to try driving on some different tracks. The track can be selected using command line arguments. Use either vamos -t <track> or vamos --track==<track>, where <track>, is one of the following

drag
A striaight flat strip of road.
Indianapolis
The Indianapolis Motor Speedway's road course.
jump
A striaight strip of road with a jump.
Magny-Cours
The track for the French grand prix (2003).
Monza
The high-speed Italian circuit (2003).
Mosport
The former home of the Canadian grand prix.
Nurburgring
The new Nurburgring in Germany (2003).
Peanut
default-track
A simple track.
Silverstone
The home of the British grand prix (2003).
skid_pad
A cirular track for testing handling.
Spa
The Spa-Francorchamps track in Belgium.
Suzuka
The track for the Japanase grand prix.

You can use the trk-convert program to turn a track file for RARS (Robot Auto Racing http://rars.sourceforge.net) into a C++ track file for Vamos. The converted files usually need some adjusting, so you'll have to learn a little about Vamos track files.

1.7 Track File Format

Tracks are defined in XML files. Here's the beginning of a track file.

     <track name="Peanut">
       <!-- Material Properties -->
     
       <sky>
         <sides>textures/sky_sides.png</sides>
     	<top>textures/sky_top.png</top>
     	<bottom>textures/sky_bottom.png</bottom>
     	<smooth/>
       </sky>

1.7.1 The Sky Box

All information goes inside the track tag. The sky section describes the sky box, which is a cube onto which a background is mapped. The sides image is wrapped around the front, right, back, and left sides of the sky box. The optional smooth tag can improve the quality of the sky box images.

1.7.2 Materials

After the sky box, the properties of the various materials that make up the track are defined.

       <material name="track" type="asphalt">
     	<friction>1.0</friction>
     	<restitution>0.1</restitution>
     	<rolling>1.0</rolling>
     	<drag>0.0</drag>
     	<bump-amplitude>0.01</bump-amplitude>
     	<bump-wavelength>100.0</bump-wavelength>
     	<texture>
     	  <file>textures/track2.png</file>
     	  <length>200.0</length>
     	  <smooth/>
     	  <mipmap/>
     	</texture>
       </material>

The name is used to identify the material in other parts of the file. The type helps determine what sound is played. The type must be one of rubber, metal, asphalt, concrete, grass, gravel, or dirt.

The friction tag sets the relative friction of the surface. If, for example, you want to specify another surface that has half the friction of asphalt, you whould set the friction value to 0.5. The calculation of the actual frictional force involves the car. Similarly, relative values of the coefficient of restitution, rolling resistance, and velocity-dependent drag are set with the restitution, rolling, and drag tags.

The bumpiness of the surface is set with the bump-amplitude, and bump-wavelength tags. They define a sinusiodal variation in the track's elevation. You may use whatever units you like, as long as you're consistent. See Units.

The texture image is set in the texture section. The file is the name of a PNG image file. The physical size that the image covers is set with the length and width tags. In this example, the width tag is omitted. As a result, the texture is stretched to fit the width of the track.

The smooth and mipmap tags improve the quality of the images, but they also reduce the frame rate.

1.7.3 Segments

The materials are grouped into “segments” that describe the materials for the track, kerbs, shoulders, and barriers.

       <segment name="left turn">
         [ wall grass kerb track kerb gravel tires ]
       </segment>

The name is used to identify the segment in other parts of the file. Inside the segment tag is an array of material names. The material of the right-side barrier (as seen from a car traveling forward around the track) is first.

1.7.4 Track Geometry

The track is made up of road sections. Here is a simple road section

       <road segment="left turn">
         <resolution>5.0</resolution>
     	<length>130.0</length>
     	<radius>160.0</radius>
       </road>

The segment attribute names a list of materials defined earlier in the file. The resolution sets the size of the quadrilateral divisions in the road section. The smaller the resolution, the more closely the section approximates a smooth curve. The length and width are given in meters. However, any system of units can be used as long as they are used consistently throughout the simulation for both derived and fundamental quantities.

The first road section must set the width of the track and shoulder, and also the height of the barriers. These dimensions are specified as (distance, width) pairs. Any number of pairs may be specified for a given width, the program will interpolate linearly between specified points.

       <!-- front straight -->
       <road segment="straight pit">
         <resolution>10.0</resolution>
     	<length>100.0</length>
     	<left-width>[ 0.0, 25.0 ]</left-width>
     	<right-width>[ 0.0, 25.0 ]</right-width>
     	<left-road-width>[ 0.0, 8.0 ]</left-road-width>
     	<right-road-width>[ 0.0, 8.0 ]</right-road-width>
     	<left-wall-height>2.0</left-wall-height>
     	<right-wall-height>2.0</right-wall-height>
     	<elevation>[ 20.0, 0.0 ]</elevation>
     	<elevation>[ 200.0, 5.0 ]</elevation>
       </road>

Similarly, any number of elevation points may be specified. A spline is used to interpolate between elevation points to achieve smooth elevation changes.

1.7.5 Braking Markers

Braking markers are signs that show the distance to an upcoming turn. For turns approached a high speed, markers at 150 m, 100 m, and 50 m are typically shown.

       <road>
         ...
     	<braking-marker>
     	  <file>textures/50.png</file>
     	  <distance>50.0</distance>
     	  <size>[ 1.4, 0.7 ]</size>
     	  <offset>[ 2.0, 0.0 ]</offset>
     	  <side>right</side>
     	</braking-marker>
     	<braking-marker>
     	  <file>textures/100.png</file>
     	  <distance>100.0</distance>
     	</braking-marker>
     	<braking-marker>
     	  <file>textures/150.png</file>
     	  <distance>150.0</distance>
     	</braking-marker>
         ...
       </road>

Once the size and offset parameters have been set, they do not need to be specified again unless you want to use different values.

1.7.6 Kerbs

Concrete kerbs are often placed along the insides of curves, and on the opposite side at the curve exits. I'm not really sure why. Nonetheless, kerbs can be specified in the road sections.

       <road>
         ...
     	<left-kerb>
     	  <start>
             <distance>10.0</distance>
     		<transition>
     		  <length>4.0</length>
     		  <width>1.0</width>
     		</transition>
     	  </start>
     	  <end>
             <distance>100.0</distance>
     		<transition>
     		  <length>4.0</length>
     		  <width>1.0</width>
     		</transition>
     	  </end>
     	  <profile>[ 1.0, 0.1 ][ 3.0, 0.1 ][ 3.1, 0.0 ]</profile>
     	</left-kerb>
     
         <right-kerb>
           ...
         </right-kerb>
         ...
       </road>

Each road section can have a left-side and a right-side kerb. A set of coordinates of the form [ distance-from-edge-of-track, elevation-above-track ] set the shape of the kerb in the profile tag. A [ 0.0, 0.0 ] coordinate is inserted automatically.

The start and end tags tell where and how the kerb begins and ends. The distance is relative to the beginning of the road section. The transition section tells how the ends of the kerb are capped. In the example above, the kerb tapers down track level and a width of 1.0 m in a distance of 4.0 m.

Once the transition length and width, and the profile are set they do not need to be specified again unless you want to use different values. You can use <transition/> to specify a transition with the previously set values. For example, this kerb runs the entire length of its road section and is capped with transitions at both ends.

         <right-kerb>
     	  <start><transition/></start>
     	  <end><transition/></end>
         </right-kerb>

If there's no start tag, the kerb starts at the beginning of the road section with no transition. If there's to end, the kerb ends at the end of the road section. To make the kerb join smoothly across two road sections, omit the end in the first section, and omit the start in the second.

Kerbs are typically serrated. Again, I don't know why. This can be simulated by setting the bump parameters on the kerb material defined near the beginning of the track file.

1.7.7 Closing a Circuit

Adjusting a track to make meet the beginning seamlessly is tedious. If a <circuit/> tag is included, the program will make the adjustments automatically. You can specify how many of the last segments will be adjusted with the segments attribute. For example, with <circuit segments="2"/> only the last two segments will be changed. Note the quotes around the value (required by the XML standard) and the trailing slash.

Allowed values for the segments tag are 0, 1, 2, and 3. The default is 3.

3
Adjust the length of the next-to-last segment (which must be a curve), to make the last segment parallel to the first. Adjust the length of the third-to-last segment (which must be straight) to put the last segment in line with the first. Adjust the length of the last segment so that it meets the beginning of the first.
2
Adjust the radius and length of the next-to-last segment to align the last with the first. Adjust the length of the last segment so that it meets the beginning of the first.
1
Adjust the length of the last segment so that it meets the beginning of the first.
0
Adjust nothing.

In all cases (including 0) the elevation curve is forced to close.

If the track can not be closed with the specified adjustments, or the requirements about what segments must be stright or curved, the exception Vamos_Track::Can_Not_Close is thrown.