// Last edited on 2007-07-23 20:33:39 by stolfi
// Processed by remove-cam-lights

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

#declare tinta_red =
  texture {
    pigment { color rgb < 0.65, 0.0, 0.0 >}
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.2 reflection 0.2 }
  }

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

#declare tinta_gold =
  texture {
    pigment { color rgb < 1.0, 0.8, 0.1 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.2 reflection 0.2}
  }

#declare tinta_green =
  texture {
    pigment { color rgb < 0.00, 0.65, 0.0 > filter 1.0}
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_green_metal =
  texture {
    pigment { color rgb < 0.00, 0.65, 0.0 >}
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.2 reflection 0.2 }
  }

#declare tinta_blue =
  texture {
    pigment { color rgb < 0.00, 0.0, 0.65 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_black =
  texture {
    pigment { color rgb < 0.00, 0.00, 0.0 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

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

#declare tinta_silver =
  texture {
    pigment { color rgb < 1.0, 1.0, 1.0 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.2 reflection 0.2 }
  }

#declare tinta_brown =
  texture {
    pigment { color rgb < 0.5, 0.25, 0.1 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.2 reflection 0.2 }
  }

#macro perna()
  intersection{
    union{
      sphere{
        <0, 0, 0>, 0.11
        texture {tinta_green_metal}
      }
      cylinder{
       <0.0, 0.0, 0.0>,
       <0.3, 0.0, 0.0>, 0.1
       texture {tinta_green_metal}
      }
      box{
        <0.29, 0.2, -0.3>,
        <0.45, -0.2, 0.5>
        texture {tinta_green_metal}
      }
    }
    sphere{
      <0.4, 0, 0.1>, 0.35
      texture {tinta_green_metal}
    }
  }
#end

#macro coxa(alfa, beta, gama)
  union{
    sphere{
      <0, 0, 0>, 0.11
      texture {tinta_green_metal}
    }
    cylinder{
      <0.0, 0.0, 0.0>,
      <0.3, 0.0, 0.0>, 0.1
      texture {tinta_green_metal}
    }
    sphere{
      <0.3, 0, 0>, 0.11
      texture {tinta_green_metal}
    }
    object{
      perna()
      rotate alfa*y
      translate 0.3*x
    }
    rotate beta*y
    rotate gama*z
  }
#end

#macro antebraco()
  union{
    sphere{
      <0, 0, 0>, 0.11
      texture {tinta_green_metal}
    }
    cylinder{
     <0.0, 0.0, 0.0>,
     <0.3, 0.0, 0.0>, 0.1
     texture {tinta_green_metal}
    }
    sphere{
      <0.3, 0, 0>, 0.15
      texture {tinta_green_metal}
    }
   }
#end

#macro braco(alfa,beta,gama)
  union{
    sphere{
      <0, 0, 0>, 0.11
      texture {tinta_green_metal}
    }
    cylinder{
     <0.0, 0.0, 0.0>,
     <0.3, 0.0, 0.0>, 0.1
     texture {tinta_green_metal}
    }
    object{
      antebraco()
      rotate alfa*y
      translate 0.3*x
    }
  }
 rotate beta*x
 rotate gama*z
#end

#declare corpo =
   union{
     sphere {
       <2, 2, 1>, 0.5
       texture {tinta_green_metal}
     }
     sphere {
       <1.8, 1.8, 1.2>, 0.2
       texture {tinta_silver}
     }
     sphere {
       <1.8, 2.3, 1.2>, 0.2
       texture {tinta_silver}
     }
     sphere {
       <1.65, 1.7, 1.2>, 0.06
       texture {tinta_black}
     }
     sphere {
       <1.65, 2.4, 1.2>, 0.06
       texture {tinta_black}
     }
     sphere {
       <1.53, 2.0, 0.9>, 0.06
       texture {tinta_red}
     }
   }

#declare casca_noz =
   difference {
     difference {
       sphere {
         <0, 0, 1.1>, 0.6
         texture { tinta_brown }
       }
       sphere {
         <0, 0, 1.1>, 0.55
         texture { tinta_brown }
       }
     }
     box {
      < 1.5, -1.5, 0.0 >,
      < -1.5, 1.5, 1.2 >
      texture { tinta_brown }
     }
   }

#declare tab_preto =
  box {
    < 0.25, 0.00, 0.00 >,
    < 0.00, 0.25, 0.10 >
    texture { tinta_black }
  }

#declare tab_branco =
  box {
    < 0.25, 0.00, 0.00 >,
    < 0.00, 0.25, 0.10 >
    texture { tinta_white }
  }

#declare j = 0;
#declare shift_y = 0;
#declare roleta = seed(12345);
#declare BD1 = 70 + 40 * clock;
#declare BD2 = -180 + 90 * clock;
#declare BD3 = -60 - 40 * clock;
#declare BE1 = -30 - 80 * clock;
#declare BE2 = -90 + 20 * clock;
#declare BE3 = 150 - 50 * clock;

#declare PD1 = 0 + 60 * clock;
#declare PD2 = 90 - 50 * clock;
#declare PD3 = -120 + 20 * clock;
#declare PE1 = 60 - 60 * clock;
#declare PE2 = 40 + 40 * clock;
#declare PE3 = 160 + 20 * clock;

union {

  #while (j<20)

    #declare i = 0;
    #declare shift_x = 0;

    #while (i<20)

      #if (mod(j,2)=0)
        #if (mod(i,2)=0)
            object { tab_preto
            translate <shift_x,shift_y ,0>
        }
        #else
            object { tab_branco
            translate <shift_x,shift_y ,0>
        }
        #end
      #else
        #if (mod(i,2)=0)
            object { tab_branco
            translate <shift_x,shift_y ,0>
        }
        #else
            object { tab_preto
            translate <shift_x,shift_y ,0>
        }
        #end
      #end

      #declare shift_x = shift_x+0.25;
      #declare i = i+1;
    #end

    #declare j = j+1;
    #declare shift_y = shift_y+0.25;

  #end

  union{
    object { corpo }
    object { casca_noz
      rotate 40*y
      translate <1.4, 2, 0.2>
    }

      object {braco(BD1,BD2,BD3)
      translate <2, 1.45, 1>
    }

      object {braco(BE1,BE2,BE3)
      translate <2, 2.55, 1>
    }

      object { coxa(PD1,PD2,PD3)
      translate <2, 1.75, 0.55>
    }

      object { coxa(PE1,PE2,PE3)
      translate <2, 2.25, 0.55>
    }

      translate <0, 0, 0.5>
  }
}

// Original camera parameters:
// #local cam_ctr = <7.00,7.00,-10.00>
// #local cam_vec = (<-0.50,-0.50,4.0>-<7.00,7.00,-10.00>)
// #local cam_sky = z

#include "camlight.inc"
camlight(<2.0,2.0,1.0>,<-10,7,5>,4.0,z,1.0)