// Last edited on 2009-07-24 18:13:13 by stolfilocal
// Processed by remove-cam-lights

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

#declare raio = 2.000;

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

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

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

#declare marrom =
  texture {
    pigment {color rgb < 0.90, 0.65, 0.20 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 } 
  }

#declare azul = 
  texture {
    pigment { color rgb < 0.10, 0.00, 0.80 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare amarelo = 
  texture {
    pigment { color rgb < 1.00, 1.00, 0.00 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare verde = 
  texture {
    pigment { color rgb < 0.10, 0.85, 0.10 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare vermelho = 
  texture {
    pigment { color rgb < 0.85, 0.05, 0.10 > }
    finish { diffuse 0.8 specular 0.1 roughness 0.005 ambient 0.1 }
  }

#declare colher =
  difference{
    object{ 
      sphere {
        <0,0,0>, 0.5
        texture {amarelo}
      }
    }
    object{
      union{
        box {
          <1,-1,0>, <-1,1,1>
          texture {amarelo}
        }
        sphere {
          <0,0,0>, 0.4
          texture {verde}
        }
      }
    }
  }

#declare pegador =
  difference{
    object{ 
      sphere {
        <0,0,0>, 0.5
        texture {amarelo}
      }
    }
    object{
      union{
        cylinder {
          <0,0,-0.1>, <0,0,0.1>, 0.5
          texture {amarelo}
        }
        sphere {
          <0,0,0>, 0.4
          texture {verde}
        }
      }
    }
  }

#declare apoio =
  union {
    object{
    cylinder {
      <0,0,0>, <0,0,2>, 0.25
      texture {azul}
    }}
    object{
    sphere {
      <0,0,0> , 0.25
      texture {cinza}
    }
    translate <0,0,2>
    }
   }

#declare apoio_simples =
  cylinder {
    <0,0,0>, <0,0,2>, 0.25
    texture {azul}
  }

#macro folha()
  union {
    object {
      apoio_simples
      scale<0,0,0.5>
      rotate <-90,0,0>
    }
    object {
      colher
      translate <0,1.5,0>
    }
  }
#end

#macro folha2()
  union {
    object {
      apoio_simples
      scale<0,0,0.5>
      rotate <-90,0,0>
    }
    object {
      pegador
      translate <0,1.5,0>
    }
  }
#end

#macro cabo(alfa)
  union{
    object {
      apoio
      rotate <-90,0,0>
    }
    object {
      folha()
      rotate <alfa,0,0>
      translate <0,2,0>
    }
  }
#end

#macro cabo2(alfa)
  union{
    object {
      apoio
      rotate <-90,0,0>
    }
    object {
      folha2()
      rotate <alfa,0,0>
      translate <0,2,0>
    }
  }
#end

#macro cabo_mestre(c1_alfa, c2_alfa, beta, teta)
  union{
    object {
      apoio
      scale<0,0,2>
      rotate<180,0,0>
      
    }
    object {
      sphere {
        <0,0,0>, 0.25
        texture {cinza}
      }
    }
    object {
      cabo(c1_alfa)
      rotate <beta,0,teta>
      translate <0,0,-4>
    }
    object {
      cabo2(c2_alfa)
      rotate <beta,0,teta+180>
      translate <0,0,-4>
    }
  }
#end

#macro cabo_apoio_mestre(zappa, c1_alfa, c2_alfa, beta, teta)
  union{
    object {
      apoio
      rotate <90,0,0>
      translate <0,2,0>
    }
    object {
      cabo_mestre(c1_alfa, c2_alfa, beta, teta)
      rotate <zappa,0,0>
      translate <0,2,0>
    }
  }
#end

#declare c0 = 0.00;
#declare c1 = 0.50;
#declare c2 = 1.00;

#declare nh = 5;
#declare nv = 4;
#declare nquadros = (nv*nh);
#declare clock_init = 0.0;
#declare clock_end = 1.0;
#declare passo = ((clock_end - clock_init)/(nquadros - 0.9999));

#declare ck = clock_init;
#declare iv = 0;

#while(iv < nv)

  #declare ih = 0.0;

  #while(ih < nh)

    #if((ck >= c0) & (ck < c1))
      #declare rr = (ck-c0)/(c1-c0);
      #declare ss = (c1-ck)/(c1-c0);

      #declare zappa = ss*0 + rr*45;
      #declare c1_alfa = ss*30 + rr*90;
      #declare c2_alfa = ss*30 + rr*130;
      #declare beta = ss*(-30) + rr*(-50);
      #declare teta = ss*0 + rr*60;
    #end

    #if((ck >= c1) & (ck <= c2))
      #declare rr = (ck-c1)/(c2-c1);
      #declare ss = (c2-ck)/(c2-c1);

      #declare zappa = ss*45 + rr*0;
      #declare c1_alfa = ss*90 + rr*30;
      #declare c2_alfa = ss*130 + rr*30;
      #declare beta = ss*(-50) + rr*(-30);
      #declare teta = ss*60 + rr*0;
    #end

    object{
      cabo_apoio_mestre(zappa, c1_alfa, c2_alfa, beta, teta)
      translate<0,ih*7.1,-iv*7.1>
    }

    

    #declare ck = ck + passo;

    #declare ih = ih+1;
  
  #end

  #declare iv = iv+1;
#end

// Original camera parameters:
// #local cam_ctr = <0.00,17.00,-13.00>
// #local cam_vec = (<40.00,17.00,-13.00>-<0.00,17.00,-13.00>)
// #local cam_sky = z

#include "camlight.inc"
camlight(<0.00,17.00,-13.00>,<10,4,5>,60.0,z,1.0)