// Last edited on DATE TIME by USER
// Processed by remove-cam-lights

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_vermelho =
  texture{
    pigment{ color rgb < 1, 0, 0 > }
    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.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 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare valores =array[10]
#declare valores [0] = 1*clock+0*(1-clock);
#declare valores [1] = 2*clock+0*(1-clock);
#declare valores [2] = 13*clock+0*(1-clock);
#declare valores [3] = 4*clock+0*(1-clock);
#declare valores [4] = 15*clock+0*(1-clock);
#declare valores [5] = 6*clock+0*(1-clock);
#declare valores [6] = 17*clock+0*(1-clock);
#declare valores [7] = 8*clock+0*(1-clock);
#declare valores [8] = 9*clock+0*(1-clock);
#declare valores [9] = 10*clock+0*(1-clock);

#declare roleta= seed(417);

#macro peca(pos)

union{
        cylinder {<0,0,0>, <3,0,0>, 0.2 texture{ tx_plastico}}
        sphere{ < pos,0,0 >, 0.5 texture{ tx_vermelho }}
}
#end

#macro peca2()

union{
        cylinder {<0,0,0>, <3,0,0>, 0.2 texture{ tx_vermelho}}

}

#end

#macro bit(valor,defeito) //0=ok 1=def

        #local aux=defeito;
        #if ((aux >= 0)&(aux<0.5))
                #local aux=0;
        #else
                #local aux=1;
        #end

        #if (aux = 0)
                #if (valor=0)
                        peca (2.5)
                #else
                        peca (0.5)
                #end
        #else
                peca2()
        #end

#end

#macro fileira(n,valor, prob)

        #local vb=valor;
        #local r=valor;
        #local f=valor - r;
        #local k =0;

union{

        #while (k<n)

                #local vb= mod(r,2);

                #local def=(rand(roleta)<prob);
                #if (rand(roleta)<prob)
                        #local defff=1;
                #else
                        #local defff=0;
                #end

                #if (vb = 0) //eh par
                        #local bitk=f;
                        #local f=0;
                        object {bit(f,defff) translate <0,-1*k,0>}
                #else
                        #local bitk=1-f;
                        #local f=0;
                        object {bit(bitk,defff) translate <0,-1*k,0>}
                #end

                #local r= int(r/2);
                #local k=k+1;

        #end
        }
#end

#macro abaco (m,n,valores, prob)

union{
        #local i=0;
        #while (i<m)
                object {fileira(n,valores[i],prob) translate <4*i,0,0>}

                #local i=i+1;

        #end

}
#end

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

#declare b =
     text{ ttf "verdana.ttf" "B" 1,0 texture{ tx_vermelho}}

#declare r =
     text{ ttf "verdana.ttf" "R" 1,0 texture{ tx_vermelho}}

#declare uu =
     text{ ttf "verdana.ttf" "U" 1,0 texture{ tx_vermelho}}

#declare n =
     text{ ttf "verdana.ttf" "N" 1,0 texture{ tx_vermelho}}

#declare o =
     text{ ttf "verdana.ttf" "O" 1,0 texture{ tx_vermelho}}

#include "eixos.inc"

union{
  object{ eixos(3.00)}

        object {b rotate <0,0,90> }
        object {r rotate <0,0,90> translate <0,1,0> }
        object {uu rotate <0,0,90> translate <0,2,0>}
        object {n rotate <0,0,90> translate <0,3,0>}
        object {o rotate <0,0,90> translate <0,4,0>}

}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0 >;
#declare raio_cena =10.0;
#declare dir_camera = < 0.5, 0, 2 >;
#declare dist_camera = 10.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)