/// Exemplo de arquivo de descricao de cena para POV-ray

// ======================================================================
// 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 < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }


#declare tx_preta = 
  texture{
    pigment{ color rgb < 0.20, 0.20, 0.20 > }
    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_rosquinha = 
 texture{
   pigment{ color rgb < 0.566, 0.276, 0.076 > }
   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 chao = 
  box{ <-70,-70,-6>, <+70,+70,-5> }

#declare orelha = 
  cone{ <0,0,0> , 0.50, <0,0,1>, 0 texture{tx_fosca}}

#declare bola = 
  sphere{ < 0,0,0 >, 0.50  texture{tx_fosca}}
#declare bitBox = box{<0.2,0.35,0.6>,<-0.2,-0.35,-0.6> }

#declare tampaLateralBox = box{<0.7,0.1,1.3>, <-0.7,-0.1,-1.3> texture{tx_fosca}}
#declare tampaSuperior = box{<0.7,1,1.3>, <-0.7,-1,+1.5> texture{tx_fosca}}
#declare valores = array[10];
#declare valores[0] = 2;
#declare valores[2] = 4;
#declare valores[3] = 8;
#declare valores[4] = 16;
#declare valores[5] = 3;
#macro bit(state, defeito)
  #if(defeito)
    object{bitBox translate<0,0,2*0.4*state -0.4> texture{tx_vidro}}
  #else
    object{bitBox translate<0,0,2*0.4*state -0.4> texture{tx_preta}}
  #end
#end
#macro lateral(nBits,nLinhas)
  union{
    object{tampaLateralBox scale <1,1,nLinhas> translate<0,-0.7-nBits+1,0>}
    object{tampaSuperior scale <1,(-1.4+1-nBits)/2,1> translate<0,0.7+(-1.4+1-nBits)/2,-1.5+1.3*nLinhas>}
    object{tampaSuperior scale <1,(-1.4+1-nBits)/2,1> translate<0,0.7+(-1.4+1-nBits)/2,-1.3*nLinhas -1.3>}
    object{tampaSuperior scale <1,(-1.4+1-nBits)/2,1> scale<1.2,1.2,0> translate<0,0.7+(-1.4+1-nBits)/2,-1.3*nLinhas -1.3 -0.2>}
    object{tampaSuperior scale <1,(-1.4+1-nBits)/2,1> scale<1.3,1.3,0> translate<0,0.7+(-1.4+1-nBits)/2,-1.3*nLinhas -1.3 -0.4>}
    object{tampaLateralBox scale <1,1,nLinhas> translate<0,+0.7,0>}
  }
#end
#macro fileira(nBits, valor)
  #local i=0;
  #local condicao=valor;
  union{
  #while(i<nBits)
    object{bit(mod(condicao,2), 1) translate<0,-i,0>}
    #local condicao=int(condicao/2);
    #local i = i+1;
  #end
  }
#end
#include "eixos.inc"
#macro abaco(m,n,valoresArray)
  union{
    fileira(n,8)
    lateral(n,m)
}
#end
// Aqui está a cena, finalmente:
object{ chao texture{ tx_xadrez }  }
object{abaco(4,5,valores) scale 0.4}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 6.0;
#declare dir_camera = < 14.00, 7.00, 4.00 >;
#declare dist_camera = 70.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)