// Last edited on 2013-11-04 03:35:46 by stolfilocal
// Processed by remove-cam-lights

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

#declare vermelho =
  texture {
    pigment{ color rgb < 1.00, 0.00, 0.00 > }
  }

#declare verde =
  texture {
    pigment{ color rgb < 0.00, 1.00, 0.00 > }
  }

#declare preto =
  texture {
    pigment{ color rgb < 0.10, 0.10, 0.10 > }
  }

#declare cinza =
  texture {
    pigment{ color rgb < 0.70, 0.70, 0.70 > }
  }

#declare tx_fosca =
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    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
  }

#declare chave_ligada =
  union {
    box { <0, 0, 0>, <0.25, 2.00, 1.00> texture { cinza }}
    cylinder { <-1.00, -1.00, 0.50>, <1.00, 1.00, 0.50>, 0.30  translate <0,1,0> texture { preto }}
  }

#declare chave_desligada =
  union {
    box { <0, 0, 0>, <0.25, 2.00, 1.00> texture { cinza }}
    cylinder { <-1.00, 1.00, 0.50>, <1.00, -1.00, 0.50>, 0.30  translate <0,1,0> texture { preto }}
  }

#declare led =
  sphere{
    < -0.70, 0.00, 0.00 >, 1
    texture { vermelho }
  }

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

#declare painel =
  box{ <0,-10, 0>, <-1,10,10> }

#macro botoes(l, c)
  union {
    #declare i = 0;
    #while (i < c)
      #declare j = 0;
      #while (j < l)
        #if (mod(i + j, 2) = 0)
          object{ chave_ligada texture{ tx_fosca } translate <0, -9 + 3 * i, 8.5 - 2 * j> }
        #else
          object{ chave_desligada texture{ tx_fosca } translate <0, -9 + 3 * i, 8.5 - 2 * j> }
        #end
        #declare j = j + 1;
      #end
      #declare i = i + 1;
    #end
  }
#end

#macro leds(l, c)
  union {
    #declare i = 0;
    #while (i < c)
      #declare j = 0;
      #while (j < l)
        #if (mod(i + j, 2) = 0)
          object{ led texture{ vermelho } translate <0, 4 + 2 * i, 8.5 - 2 * j> }
        #else
          object{ led texture{ verde } translate <0, 4 + 2 * i, 8.5 - 2 * j> }
        #end
        #declare j = j + 1;
      #end
      #declare i = i + 1;
    #end
  }
#end

union{
  object{ chao  translate < 0,0,-5 > texture{ tx_xadrez } }
  object{ painel texture{ tx_fosca } }
  object{ botoes(7, 4) }
  object{ leds(7, 3) }
}

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