// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2010-03-04 15:44:01 by stolfi

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

#declare roleta = seed(417);

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

#declare tx_preto = 
  texture{
    pigment{ color rgb < 0, 0, 0 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_fosca = 
  texture{
    pigment{ color rgb < 1,1,1 > }
    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 > }
    scale 2.0
  }

// ==================

// DESCRIÇÃO DA CENA 

// Partes da cena:
#macro criaBastao (temp, erro)

#local def = (rand(roleta) < erro);

#if (def = 1)
cylinder { <0,-2,0.8>, <0,6,0.8>, 0.2 texture { tx_vidro }}

#else


#if (temp = 0)

union {
	cylinder { <0,-2,0.8>, <0,6,0.8>, 0.2 texture { tx_vidro }}
	cylinder { <0,4,0.8>, <0,5,0.8>, 0.3 texture { tx_xadrez }}
}

#else

union {
	cylinder { <0,-2,0.8>, <0,6,0.8>, 0.2 texture { tx_vidro }}
	cylinder { <0,-1,0.8>, <0,0,0.8>, 0.3 texture { tx_xadrez }}
}

#end
#end
#end

#macro abaco() 

union {

difference { 
box {<-2,-2,-2>, <3,6,2> texture { tx_fosca } }
box { <-2.1,-1.5,-1.5>, <3.1,5.5,1.5> texture { tx_fosca }}
}
}

#end


#macro bastoes(fileiras, numero, erro)
union {
#local temp = fileiras;
#local temp2 = numero;
	
   #while (temp > 0)
	#local temp = temp - 1;

	object { criaBastao(mod(temp2, 2), erro) translate 0.5*temp*z }

	#local temp2 = int(temp2/2);

         #end
}
	#end



#macro variasFilas (i, j, erro)

 union {

   #local temp = i;

   #while (temp > 0)

     object { bastoes (j, mod(rand(roleta),9), erro) translate temp*1.2*x }

     #local temp = temp - 1;

   #end
 }
#end

object { variasFilas(10, 2, 0.3) }

#include "eixos.inc"

// Aqui está a cena, finalmente:



#include "camlight.inc"
#declare centro_cena = < 7.00, 0.00, 1.00 >;
#declare raio_cena = 11.0;
#declare dir_camera = <3, 3, 5 >;
#declare dist_camera = 50.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)