<?xml version="1.0"?>

<track name="Istanbul">

  <racing-line>
    <distance-factor>1.0</distance-factor>
    <stiffness>2.0</stiffness>
  </racing-line>

  <sky>
    <sides>textures/sky_sides.png</sides>
    <top>textures/sky_top.png</top>
    <bottom>textures/sky_bottom.png</bottom>
    <smooth/>
  </sky>

  <!-- Material Properties -->

  <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>

  <material name="grass" type="grass">
    <friction>0.7</friction>
    <restitution>0.1</restitution>
    <rolling>5.0</rolling>
    <drag>20.0</drag> 
    <bump-amplitude>0.03</bump-amplitude>
    <bump-wavelength>2.0</bump-wavelength>
    <texture>
      <file>textures/grass.png</file>
      <width>10.0</width>
      <length>12.0</length>
      <smooth/>
      <mipmap/>
    </texture>
  </material>

  <material name="gravel" type="gravel">
    <friction>0.8</friction>
    <restitution>0.0</restitution>
    <rolling>40.0</rolling>
    <drag>200.0</drag>  
    <bump-amplitude>0.05</bump-amplitude>
    <bump-wavelength>2.0</bump-wavelength>
    <texture>
      <file>textures/gravel3.png</file>
      <width>10.0</width>
      <length>10.0</length>
      <smooth/>
      <mipmap/>
    </texture>
  </material>

  <material name="tires" type="rubber">
    <friction>1.0</friction>
    <restitution>0.8</restitution>
    <rolling>1.0</rolling>
    <drag>5.0</drag>
    <bump-amplitude>0.0</bump-amplitude>
    <bump-wavelength>1.0</bump-wavelength>
    <texture>
      <file>textures/red-tires.png</file>
      <width>0.33</width>
      <length>3.0</length>
      <smooth/>
      <mipmap/>
    </texture>
  </material>

  <material name="rail" type="metal">
    <friction>1.0</friction>
    <restitution>0.1</restitution>
    <rolling>1.0</rolling>
    <drag>0.0</drag>  
    <bump-amplitude>0.0</bump-amplitude>
    <bump-wavelength>1.0</bump-wavelength>
    <texture>
      <file>textures/rail.png</file>
      <width>0.34</width>
      <length>10.0</length>
      <smooth/>
      <mipmap/>
    </texture>
  </material>

  <material name="wall" type="concrete">
    <friction>1.0</friction>
    <restitution>0.1</restitution>
    <rolling>1.0</rolling>
    <drag>0.0</drag>
    <bump-amplitude>0.0</bump-amplitude>
    <bump-wavelength>1.0</bump-wavelength>
    <texture>
      <file>textures/wall.png</file>
      <width>1.0</width>
      <length>10.0</length>
      <smooth/>
      <mipmap/>
    </texture>
  </material>

  <material name="kerb" type="concrete">
    <friction>1.0</friction>
    <restitution>0.1</restitution>
    <rolling>1.0</rolling>
    <drag>0.0</drag>
    <bump-amplitude>0.06</bump-amplitude>
    <bump-wavelength>2.0</bump-wavelength>
    <texture>
      <file>textures/red-kerb.png</file>
      <width>2.0</width>
      <length>4.0</length>
      <smooth/>
      <mipmap/>
    </texture>
  </material>

  <!-- Segment Properties -->

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

  <!-- The track -->

  <!-- Front Straight -->
  <road segment="straight">
    <resolution>10.0</resolution>
    <length>255.5</length>
    <left-width>[ 0.0, 25.0 ]</left-width>
    <right-width>[ 0.0, 25.0 ]</right-width>
    <left-road-width>[ 0.0, 7.5 ]</left-road-width>
    <right-road-width>[ 0.0, 7.5 ]</right-road-width>
    <left-wall-height>1.0</left-wall-height>
    <right-wall-height>1.0</right-wall-height>
    <right-kerb>
      <start>
        <distance>155.0</distance>
        <transition>
          <length>4.0</length>
          <width>0.8</width>
        </transition>
      </start>
      <end>
        <transition>
          <length>4.0</length>
          <width>0.8</width>
        </transition>
      </end>
      <profile>[ 0.5, 0.05 ][ 1.0, 0.05 ][ 1.1, 0.0 ]</profile>
    </right-kerb>
    <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>
    <elevation>[ 100.0, 0.0 ]</elevation>
    <elevation>[ 200.0, 0.0 ]</elevation>
  </road>

  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>48.0</length>
    <radius>30.0</radius>
    <left-kerb>
      <start>
        <transition>
          <length>4.0</length>
          <width>0.8</width>
        </transition>
      </start>
      <end>
        <transition>
          <length>4.0</length>
          <width>0.8</width>
        </transition>
      </end>
      <profile>[ 0.5, 0.05 ][ 1.0, 0.05 ][ 1.1, 0.0 ]</profile>
    </left-kerb>
  </road>

  <road segment="straight">
    <resolution>10.0</resolution>
    <length>50.0</length>
    <right-kerb>
      <start><transition/></start>
    </right-kerb>
    <elevation>[ 0.0, -4.0 ]</elevation>
  </road>

  <road segment="right turn">
    <resolution>2.0</resolution>
    <length>120.0</length>
    <radius>-120.0</radius>
    <right-kerb>
      <end><transition/></end>
    </right-kerb>
  </road>

  <road segment="straight">
    <resolution>2.0</resolution>
    <length>600.0</length>
    <radius>-600.0</radius>
    <braking-marker>
      <file>textures/50.png</file>
      <distance>50.0</distance>
      <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>
    <left-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    </left-kerb>
  </road>

  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>150.0</length>
    <radius>80.0</radius>
    <curvature-factor>1.1</curvature-factor>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
    <elevation>[ 0.0, 30.0 ]</elevation>
  </road>

  <road segment="straight">
    <resolution>10.0</resolution>
    <length>80.0</length>
  </road>

  <road segment="right turn">
    <resolution>2.0</resolution>
    <length>32.0</length>
    <radius>-18.0</radius>
    <right-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </right-kerb>
    <skew>0.7</skew>
    <elevation>[ 0.0, 28.0 ]</elevation>
  </road>

  <road segment="straight">
    <resolution>10.0</resolution>
    <length>120.0</length>
    <left-kerb>
      <start><transition/></start>
      <end>
        <distance>50.0</distance>
        <transition/>
      </end>
    </left-kerb>
  </road>

  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>48.0</length>
    <radius>30.0</radius>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
    <elevation>[ 0.0, 25.0 ]</elevation>
  </road>

  <road segment="left turn">
    <resolution>10.0</resolution>
    <length>50.0</length>
    <right-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </right-kerb>
  </road>

  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>25.0</length>
    <radius>40.0</radius>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
  </road>

  <road segment="straight">
    <resolution>2.0</resolution>
    <length>300.0</length>
    <radius>400.0</radius>
    <right-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    </right-kerb>
  </road>
  <road segment="straight">
    <resolution>10.0</resolution>
    <length>200.0</length>
    <braking-marker>
      <file>textures/50.png</file>
      <distance>50.0</distance>
      <side>left</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>
    <elevation>[ 0.0, 15.0 ]</elevation>
  </road>

  <!-- Hairpin -->
  <road segment="right turn">
    <resolution>2.0</resolution>
    <length>70.0</length>
    <radius>-40.0</radius>
    <right-kerb>
      <start><transition/></start>
    </right-kerb>
    <elevation>[ 0.0, 15.0 ]</elevation>
  </road>
  <road segment="right turn">
    <resolution>2.0</resolution>
    <length>70.0</length>
    <radius>-70.0</radius>
    <right-kerb>
      <end><transition/></end>
    </right-kerb>
  </road>

  <road segment="straight">
    <resolution>10.0</resolution>
    <length>200.0</length>
    <braking-marker>
      <file>textures/50.png</file>
      <distance>50.0</distance>
      <side>right</side>
    </braking-marker>
    <braking-marker>
      <file>textures/100.png</file>
      <distance>100.0</distance>
    </braking-marker>
    <left-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    </left-kerb>
    <elevation>[ 100.0, 30.0 ]</elevation>
  </road>

  <!-- Quadruple-apex Turn -->
  <road segment="right paved">
    <resolution>2.0</resolution>
    <length>20.0</length>
    <radius>30.0</radius>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
    <elevation>[ 0.0, 30.0 ]</elevation>
  </road>
  <road segment="right paved">
    <resolution>10.0</resolution>
    <length>80.0</length>
  </road>
  <road segment="right paved">
    <resolution>2.0</resolution>
    <length>20.0</length>
    <radius>30.0</radius>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
  </road>
  <road segment="right paved">
    <resolution>10.0</resolution>
    <length>60.0</length>
  </road>
  <road segment="right paved">
    <resolution>2.0</resolution>
    <length>20.0</length>
    <radius>30.0</radius>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
  </road>
  <road segment="right paved">
    <resolution>10.0</resolution>
    <length>100.0</length>
    <radius>200.0</radius>
    <right-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </right-kerb>
  </road>
  <road segment="right paved">
    <resolution>2.0</resolution>
    <length>62.0</length>
    <radius>60.0</radius>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
  </road>
  <road segment="straight">
    <resolution>10.0</resolution>
    <length>580.0</length>
    <right-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    </right-kerb>
    <elevation>[ 0.0, 40.0 ]</elevation>
    <braking-marker>
      <file>textures/50.png</file>
      <distance>50.0</distance>
      <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>

  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>38.0</length>
    <radius>25.0</radius>
    <racing-line-adjustment>1.0</racing-line-adjustment>
    <curvature-factor>1.2</curvature-factor>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
    <skew>-0.5</skew>
  </road>
  <road segment="left turn">
    <resolution>10.0</resolution>
    <length>40.0</length>
    <right-kerb>
      <start><transition/></start>
    </right-kerb>
  </road>
  <road segment="right turn">
    <resolution>2.0</resolution>
    <length>63.0</length>
    <radius>-60.0</radius>
    <racing-line-adjustment>-1.0</racing-line-adjustment>
    <curvature-factor>0.9</curvature-factor>
    <right-kerb>
      <end><transition/></end>
    </right-kerb>
  </road>

  <road segment="straight">
    <resolution>10.0</resolution>
    <length>550.0</length>
    <racing-line-adjustment>1.0</racing-line-adjustment>
    <left-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    </left-kerb>
  </road>
  <!-- Kink -->
  <road segment="straight">
    <resolution>2.0</resolution>
    <length>58.0</length>
    <radius>-100.0</radius>
    <right-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </right-kerb>
    <elevation>[ 0.0, 0.0 ]</elevation>
  </road>
  <road segment="straight">
    <resolution>10.0</resolution>
    <length>700.0</length>
    <right-kerb>
      <start>
        <distance>600.0</distance>
        <transition/>
      </start>
      <end><transition/></end>
    </right-kerb>
    <left-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    </left-kerb>
    <braking-marker>
      <file>textures/50.png</file>
      <distance>50.0</distance>
      <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>
    <elevation>[ 0.0, 0.0 ]</elevation>
    <elevation>[ 300.0, 10.0 ]</elevation>
    <elevation>[ 600.0, 0.0 ]</elevation>
  </road>

  <!-- Ending Complex -->
  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>80.0</length>
    <radius>30.0</radius>
    <curvature-factor>1.1</curvature-factor>
    <left-kerb>
      <start><transition/></start>
      <end><transition/></end>
    </left-kerb>
    <elevation>[ 0.0, 0.0 ]</elevation>
  </road>
  <road segment="straight">
    <resolution>10.0</resolution>
    <length>40.0</length>
    <right-kerb>
      <start><transition/></start>
    </right-kerb>
  </road>
  <road segment="right turn">
    <resolution>2.0</resolution>
    <length>40.0</length>
    <radius>-25.0</radius>
    <right-kerb>
      <end><transition/></end>
    </right-kerb>
  </road>
  <road segment="straight">
    <resolution>10.0</resolution>
    <length>80.0</length>
    <left-kerb>
      <start><transition/></start>
      <end>
        <distance>50.0</distance>
        <transition/>
      </end>
    </left-kerb>
    <elevation>[ 0.0, 0.0 ]</elevation>
  </road>
  <road segment="left turn">
    <resolution>2.0</resolution>
    <length>42.0</length>
    <radius>25.0</radius>
    <left-kerb>
      <start><transition/></start>
    </left-kerb>
  </road>

  <road segment="straight">
    <resolution>10.0</resolution>
    <length>400.0</length>
    <racing-line-adjustment>-1.0</racing-line-adjustment>
    <right-kerb>
      <start><transition/></start>
      <end>
        <distance>100.0</distance>
        <transition/>
      </end>
    <elevation>[ 0.0, 0.0 ]</elevation>
    </right-kerb>
  </road>

  <!-- Force the track to close -->
  <circuit/>

  <!-- Define the timing sectors -->
  <timing-line>10.0</timing-line>
  <timing-line>1900.0</timing-line>
  <timing-line>3100.0</timing-line>

  <!-- Adjust the total length if necessary. -->
  <track-length>5378.0</track-length>
</track>
