// background{ color rgb < 0.90, 0.60, 0.85 > }

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

#declare tx_fosca = 
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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

// DESCRI��O DA CENA 

#declare raio = 0.10;
#declare roleta = seed(1273);

// Partes da cena:

#declare caixa = 
  box{
    < -0.20, -0.20, 0.00 >,
    < 0.20, 0.20, 0.10 >
    texture{ tx_plastico }
  }

#declare bola =
  sphere{
    < 0, 0, 0 >, raio 
    texture{ tx_plastico }
  }

#declare cilindro = 
  cylinder{
    < 0.00, 0.00, 0.00 >,
    < 0.00, 0.00, 0.40 >,
    raio
    texture{ tx_fosca }
  }

#declare coninho = 
  cone{
    < 0.0, 0.0, 0.0 >,
    raio,
    < 0.0, 0.0, 0.30 >,
    0
    texture{ tx_fosca }
  }

#macro tanque_cubo (coord_x, coord_y)
  union{
    object { caixa }
    object{ cilindro  scale < 0.50, 0.50, 1.00 > texture{ tx_plastico } }
    translate < coord_x, coord_x, 0.1 >
    texture{ tx_plastico }
  }
  // #local p1 = <  >;
  // #local q1 = <  >;
  // #local p2 = <  >;
  // #local q2 = <  >;
  // #local tq = union{  }

  // #declare A[N]=q1; #declare N=N+1;
  // #declare A[N]=q2; #declare N=N+1;
#end
  
#macro tanque_redondo (coord_x,coord_y)
  difference{
    object { bola translate < coord_x, coord_y, 0 > texture{ tx_plastico } }
    object{ caixa translate < coord_x, coord_y, -0.1 > scale < 1,1,2 > texture{ tx_plastico } }
  }
#end

#macro tanque_cilindro (coord_x, coord_y)
  union{
    object { cilindro translate < coord_x, coord_y, 0 > texture{ tx_plastico } }
    object{ coninho translate < coord_x, coord_y, 0.4 > texture{ tx_plastico } }
  }
#end

#macro gerar_aleatorio ()
  #local aleatorio = int(rand(roleta));
  aleatorio
#end

#macro gera_tanques (m,n)
  union{
  #local i = 1;
  #while (i <= m) 
    #local j = 1;
    #while (j <= n)
      #local k = int(3*rand(roleta));
      #if (k = 0)
        object{tanque_cubo(i,j)}
      #end
      #if (k = 1)
        object{tanque_redondo(i,j)}
      #end
      #if (k = 2)
        object{tanque_cilindro(i,j)}
      #end
      #local j = j + 1;
      #end
    #local i = i + 1;
    #end
  }
#end

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

#include "eixos.inc"

// Aqui est� a cena, finalmente:

union{
    object { eixos(10) }

    object{ chao translate < 0,0,-5 > texture{ tx_fosca } }

    object{ gera_tanques(3,2) }

    // object{ tanque_cilindro translate < 0,0,0 > texture{ tx_plastico } }
}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 6.0;
#declare dir_camera = < 14.00, 0.00, 40.00 >;
#declare dist_camera = 200*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)