// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2023-09-25 16:38:38 by stolfilocal

// ======================================================================
// CORES E TEXTURAS

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

#declare tx_plastico = 
  texture{
    pigment{ color rgb < 0.80, 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_espelho = 
  texture{
    pigment{ color rgb < 1.51, 0.50, 0.68 > }
    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_bug = 
  texture{
    pigment{ color rgb < 1.00, 0.20, 0.10 > }
    finish{ diffuse 0.5 ambient 0.5 }
  }


#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 = 5.000;
#declare A = array[1000];
#declare N = 0;

// Partes da cena:
  
#declare pino = 
  cylinder{
    < 0, 0, 0 >,
    < 0, 0, +1.00 >,
    0.75
    texture{ tx_fosca }
  }
  

#declare MyCone = cone {
  <0, 0, 0>, 1.0 // <x, y, z>, center & radius of one end
  <0, 0, 1>, 0.25 // <x, y, z>, center & radius of the other end
  
}

#declare MyCylinder = cylinder {
  <0, 0, -1>, <0, 0, 1>, 1 // center of one end, center of other end, radius
  open // remove end caps
}

#declare tubos = cylinder {
  <0, 0, -1>, <0, 0, 3>, 0.10 // center of one end, center of other end, radius
  open // remove end caps
  
}

#declare MySphere = sphere {
  <0, 0, 0>, 1.5 // <x, y, z>, radius 
}

#declare MyBox = box {
  <0, 0, 0>, <3, 3, 3> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
 
}

#declare roleta1 = seed(1003);

#macro tabuleiro(rows, columns)
  union{   
  #local i = 0;
  #while(i<rows)
    #local j = 0;
    #while(j<columns)
      sphere{<i,0,0>,0.2 rotate <0,0,360/columns*j>}
      #local j = j+1;
      #end
    #local i = i+1;
    #end
  }
  
#end

#macro tanque1 (posx,posy)
  union {
    object{MyCylinder translate<posx,posy,0>}
    object{MyCone translate<posx,posy,1>}
    object{tubos translate<posx,posy,2>}
    object{tubos translate<posx,posy,0.5> rotate <30, 30, 30>} // <x°, y°, z°>
    object{tubos translate<posx,posy,0.5> rotate <-60, 0, 0>} // <x°, y°, z°>
    texture{ tx_bug }
  }
#end

#macro tanque2 (posx,posy)
  union {
    object{MySphere translate <posx, posy, 0>} // <x, y, z>
    object{MySphere translate <posx+2.5, posy, 0>} // <x, y, z>
    object{tubos translate<posx,posy,2>}
    object{tubos translate<posx,posy,0.5> rotate <30, 30, 30>} // <x°, y°, z°>
    object{tubos translate<posx,posy,0.5> rotate <-60, 0, 0>} // <x°, y°, z°>
    object{tubos translate<posx,posy-2,0.5>}
    object{tubos translate<posx,posy-2,0.5> rotate <30, 30, 30>} // <x°, y°, z°>
    texture{ tx_bug }
  }
#end

#macro tanque3 (posx,posy)
  union {
    object{MyBox translate <posx, posy, 0>} // <x, y, z>}
    object{MyCone translate <posx+1.5, posy+1.5, 3>} // <x, y, z>
    object{tubos translate<posx+1.5,posy+1.5,2>}
    object{tubos translate<posx,posy,0.5> rotate <30, 30, 30>} // <x°, y°, z°>
    object{tubos translate<posx,posy,0.5> rotate <-60, 0, 0>} // <x°, y°, z°>
    texture{ tx_bug }
  }
#end

#macro define_tanque(posx, posy)
  #local k = int(3*rand(roleta1));
  #if(k = 0)
    object{tanque1(posx, posy)}
  #end
  #if(k = 1)
    object{tanque2(posx, posy)}
  #end
  #if(k = 2) // Professor.
    object{tanque3(posx, posy)}
  #end
#end

#macro gera_tanques(m,n)
  union{   
    #local i = 0;
    #local posicaoy = 0;
    #while(i<m)
      #local posicaox = 0; // Professor.
      #local j = 0;
      #while(j<n)
        define_tanque(posicaox,posicaoy)
        #local posicaox = posicaox + 3;
        #local j = j+1;
      #end
      #local posicaoy = posicaoy + 3; // Professor.
      #local i = i+1;
    #end
  }
#end


#include "eixos.inc"

// Aqui está a cena, finalmente:

#declare nfilas = 11;
#declare ncolunas = 7;

union{
  
  object{ eixos(6.00) }
  object{gera_tanques(nfilas, ncolunas)}
  
  object{tanque1(0,0) translate <0, -8, 10>}
  object{tanque2(0,0) translate <0, 00, 10>}
  object{tanque3(0,0) translate <0, +8, 10>}
}

#include "camlight.inc"
#declare centro_cena = < 3*ncolunas/2, 3*nfilas/2, 3.00 >;
#declare raio_cena = 1.9*sqrt(nfilas*nfilas + ncolunas*ncolunas);
#declare dir_camera = < 14.00, 7.00, 4.00 >;
#declare dist_camera = 7*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)