// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2017-05-07 20:10:09 by stolfilocal

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

background{ color rgb < 0.75, 0.80, 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 < 0.30, 0.30, 0.30 > }
    finish{ diffuse 0.9  ambient 0.1 }
  }

#declare tx_vermelho = 
  texture{
    pigment{ color rgb < 1.00, 0.00, 0.00 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#declare tx_verde = texture {
  pigment{ color rgb < 0.00, 1.00, 0.00 > }
  finish{ diffuse 0.9  ambient 0.1 }
  
}

// ======================================================================
// Macros

#macro assento (livre)
  union{
    #if (livre)
      box {
        <-1, -1, -0.2>, <1, 1, 0.2> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0, 0, 0> // <x, y, z>
        texture {
          tx_verde
        }
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0.9, 0.9, -1.2> // <x, y, z>
        texture {
          tx_verde
        }
        
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <-0.9, 0.9, -1.2> // <x, y, z>
        texture {
          tx_verde
        }
        
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0.9, -0.9, -1.2> // <x, y, z>
        texture {
          tx_verde
        }
        
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <-0.9, -0.9, -1.2> // <x, y, z>
        texture {
          tx_verde
        }
        
      }
      box {
        <-1, -0.05, -1.2>, <1, 0.05, 1.2> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0, -0.95, 1.4> // <x, y, z>
        texture {
          tx_verde
        }
        
      }
    #else
      box {
        <-1, -1, -0.2>, <1, 1, 0.2> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0, 0, 0> // <x, y, z>
        texture {
          tx_vermelho
        }
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0.9, 0.9, -1.2> // <x, y, z>
        texture {
          tx_vermelho
        }
        
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <-0.9, 0.9, -1.2> // <x, y, z>
        texture {
          tx_vermelho
        }
        
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0.9, -0.9, -1.2> // <x, y, z>
        texture {
          tx_vermelho
        }
        
      }
      box {
        <-0.1, -0.1, -1>, <0.1, 0.1, 1> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <-0.9, -0.9, -1.2> // <x, y, z>
        texture {
          tx_vermelho
        }
        
      }
      box {
        <-1, -0.05, -1.2>, <1, 0.05, 1.2> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
        translate <0, -0.95, 1.4> // <x, y, z>
        texture {
          tx_vermelho
        }
        
      }
    #end
  }
#end

//considerando que uma unidade no povray valha 40cm, a distância de 1627mm seria aproximadamente 4 cadeiras ou 160cm


#macro auditorio(m,n)
  union {

  #local dy = 0;
  #local sdy = 0;
  #local i = 0;
  #local livre = 1;
  
    #while ( i <= m)
      #local dx = 0;
      #local sdx = 0;
      #local j = 0;
      

      #while (j <= n)
        object {assento(livre) translate <dx, dy, 0> }

        #if( mod(j,2) = 0 )
          #local livre = 0;
        #else
          #local livre = 1;
        #end

        #local dx = dx + 2.5;
        #local sdx = sdx + 2.5;
        #local j = j +1;
      #end
      
      #local dx = 0;
      #local dy = dy + 3;
      #local sdy = sdy + 3;
      #local i = i +1;
    #end
  }

#end

#macro cria(m,n)

  union {
    object { auditorio(m,n) }

    object { auditorio(m,n)  translate <0, m*n, 0> }

  }

  

#end
// ======================================================================
// DESCRI��O DA CENA 

// Partes da cena:


#include "eixos.inc"

// Aqui est� a cena, finalmente:

union{
  object{ eixos(3.00) }
 
  object{cria(3,5)}
  

}

#include "camlight.inc" 
#declare centro_cena = < 20.00, 20.00, 0.00 >;
#declare raio_cena = 20.0;
#declare dir_camera = < 14.00, 7.00, 4.00 >;
#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)