// Last edited on DATE TIME by USER
// Processed by remove-cam-lights

background{ color rgb < 0.75, 0.80, 0.85 > }

#declare tx_plastico =
  texture{
    pigment{ color rgb < 0.30, 0.95, 0.10 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_fosca =
  texture{
    pigment{ color rgb < 0.75, 0.25, 0.05 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_arq =
  texture{
    pigment{ color rgb < 0.25, 0.25, 0.05 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_cadeira =
  texture{
    pigment{ color rgb < 0.3, 0.3, 0.8 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_torc1 =
  texture{
    pigment{ color rgb < 0.5, 0, 0.8 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_torc2 =
  texture{
    pigment{ color rgb < 1, 1, 1 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_cabeca =
  texture{
    pigment{ color rgb < 0.9, 0.53, 0.39 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_espelho =
  texture{
    pigment{ color rgb < 1.00, 0.85, 0.30 > }
    finish{ diffuse 0.2 reflection 0.7*< 1.00, 0.85, 0.30 > ambient 0.1 }
  }

#declare tx_vidro =
  texture{
    pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 }
    finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 }
  }

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare raio = 2.000;

#declare bolinha =
  sphere{ < 0,0,0 >, 0.8 }

#declare bolota =
  sphere{ < 0,0,0 >, 2 }

#declare bola =
  sphere{
    < 0.00, 0.00, 0.00 >, raio
    texture{ tx_fosca }
  }

#declare pino =
  cylinder{
    < -2.00, +2.00, -1.00 >,
    < +2.00, -2.00, +1.00 >,
    0.75
    texture{ tx_plastico }
  }

#declare furo =
  cylinder{
    < -1.00, -2.00, -2.00 >,
    < +1.00, +2.00, +2.00 >,
    0.5*raio
    texture{ tx_espelho }
  }

#declare chao =
  box{ <-20,-20,-1>, <+20,+20,0> }

#declare campo =
  box{ < 0,0,-1>, < 14, 28, 0> }

#macro Escada(fileiras, largura)
  #declare nivel =
    box {
      < 0, 0, 0>,
      < 1, largura, 1 >
      texture { tx_fosca }
    }
  #declare i = fileiras;
  #declare filFixa = fileiras;
  union{
    #while (fileiras > 0)
      #while (i > 0)
        object { nivel translate < i, 0, filFixa - fileiras > }
        #declare i = i - 1;
      #end
      #declare fileiras = fileiras - 1;
      #declare i = fileiras;
    #end
  }
#end

#macro Torcedor(tipo, j)
  #if(tipo = 1)
          union{
                cone {
                  < 0.5, j+0.5, 1 >, 0.5
                  < 0.5, j+0.5, 1.5 >, 0.3
                  texture { tx_torc1 }
                }
                sphere{
                  < 0.5, j+0.5, 1.8 >, 0.3
                  texture{ tx_cabeca }
                }
          }
  #end
  #if(tipo = 2)
          union{
                cone {
                  < 0.5, j+0.5, 1 >, 0.5
                  < 0.5, j+0.5, 1.5 >, 0.3
                  texture { tx_torc2 }
                }
                sphere{
                  < 0.5, j+0.5, 1.8 >, 0.3
                  texture{ tx_cabeca }
                }
          }
  #end
#end

#declare roleta = seed(720);

#macro nivelArq2(largura)
  #local j = 0.5;
  union{
    box {
      < 0, 0, 0>,
      < 1, largura, 1 >
      texture { tx_arq }
    }
    #while(j<largura)
      union{
        box {
          < 0, j, 1>,
          < 1, j+1, 1.2 >
          texture { tx_cadeira }
        }
        box {
          < 0, j, 1>,
          < 0.1, j+1, 1.8 >
          texture { tx_cadeira }
        }
        #if(rand(roleta) < 0.25)
          Torcedor(1, j)
        #else
          #if(rand(roleta) < 0.33)
            Torcedor(2, j)
          #end
        #end
      }
      #local j = j + 2;
    #end
  }
#end

#macro Arquibancada(fileiras, largura)
  #declare nivelArq =
    box {
      < 0, 0, 0>,
      < 1, largura, 1 >
      texture { tx_arq }
    }

  #declare assento =
    union{
      box {
        < 0, 0, 0>,
        < 1, 1, 0.2 >
        texture { tx_arq }
      }
      box {
        < 0, 0, 0>,
        < 0.1, 1, 0.8 >
        texture { tx_arq }
      }
    }
  #local i = fileiras;
  #local filFixa = fileiras;
  union{
    #while (fileiras > 0)
      #while (i > 0)
        object { nivelArq2(largura) translate < i, 0, filFixa - fileiras > }
        #local i = i - 1;
      #end
      #local fileiras = fileiras - 1;
      #local i = fileiras;
    #end
  }
#end

#include "eixos.inc"

union{
  object{ eixos(10.00) }

  object{ campo translate < 0, -3, 0 > texture{ tx_plastico } }
  object{
    union{
      object{ Escada(5, 2) translate < -5, 0, 0 > }
      object{ Arquibancada(5, 8) translate < -5, 2, 0 > }
      object{ Arquibancada(5, 4) translate < -5, -4, 0 > }
    }
    rotate < 0, 0, 90 >
    translate < 10, -4, 0 >
  }
  object{
    union{
      object{ Escada(3, 2) translate < -3, 0, 0 > }
      object{ Arquibancada(3, 8) translate < -3, 2, 0 > }
      object{ Arquibancada(5, 4) translate < -5, -4, 0 > }
    }
    rotate < 0, 0, -90 >
    translate < 4, 26, 0 >
  }
  object{
    union{
      object{ Escada(7, 2) translate < -7, 0, 0 > }
      object{ Arquibancada(7, 8) translate < -7, 2, 0 > }
      object{ Arquibancada(5, 4) translate < -5, -4, 0 > }
      object{ Escada(5, 4) translate < -5, 10, 0 > }
      object{ Arquibancada(5, 10) translate < -5, 14, 0 > }
    }
    translate < -1, 0, 0 >
  }
  object{
    union{
      object{ Escada(8, 2) translate < -8, 0, 0 > }
      object{ Arquibancada(5, 8) translate < -5, 2, 0 > }
      object{ Arquibancada(8, 4) translate < -8, -4, 0 > }
      object{ Escada(5, 4) translate < -5, 10, 0 > }
      object{ Arquibancada(5, 10) translate < -5, 14, 0 > }
    }
    rotate < 0, 0, 180 >
    translate < 15, 21, 0 >
  }

}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 40.0;
#declare dir_camera = < 10.00, 30.00, 15.00 >;
#declare dist_camera = 120.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)