// Last edited on 2007-07-23 21:35:02 by stolfi
// Processed by remove-cam-lights

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

#declare ouro =
  texture {
    pigment { color rgb < 1.00, 0.80, 0.3 > }
    finish { ambient 0.1 diffuse 0.1 specular 0.3 roughness 0.1  reflection < 1.00, 0.80, 0.3 > }
  }

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

#declare marrom =
  texture {
    pigment { color rgb < 0.8, 0.5, 0.1 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }
#declare preto =
  texture {
    pigment { color rgb < 0, 0, 0 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }
#declare branco =
  texture {
    pigment { color rgb < 1, 1, 1 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

plane{y,-15.7
      texture {
         pigment {checker color rgb <0.75, 0.80, 0.85>, color <1, 1, 1>
                 }
      }
}

#declare dente =
   box {
      <-0.2,-0.3,0.2><0.2,0.3,-0.2> texture{branco}
   }

#declare olho =
   union {
     sphere {
        <0.0,0.0,0.0> 0.4 texture{branco}
     }
     sphere {
 <0.0,0.0,0.4> 0.1 texture{preto}
     }
  }

#declare orelha =
   difference {
      sphere {
         <0.0,0.0,0.0> 0.8 texture {marrom}
      }
      sphere {
         <0.0,0.0,0.8> 0.5 texture {branco}
      }
   }

#macro cabeca()
  union {
    difference {
      sphere {
        <0.0,0.0,0.0> 3.0 texture { marrom }
      }
      cylinder {
        <-1.5,-1.3,3>,<1.5,-1.3,3>,0.7 texture {preto}
      }
    }
    cylinder {
       <0.0,-2.9,0.0>,<0.0,-3.6,0.0>,0.4 texture {marrom}
    }
    object {dente translate <-0.3,-0.9,2.7>}
    object {dente translate <0.3,-0.9,2.7>}
    object {olho translate <0.7,0.9,3.0>}
    object {olho translate <-0.7,0.9,3.0>}
    object {orelha translate <-1,3.1,0>}
    object {orelha translate <1,3.1,0>}
  }
#end

#macro antebraco()
   union {
     cylinder {
       <0.0,0.0,0.0>,<3.8,0.0,0.0>,0.7 texture {marrom}
     }
     sphere {
       <0.0,0.0,0.0>,0.8 texture {marrom}
     }
     sphere {
       <4.5,0.0,0.0>,1.0 texture {marrom}
     }
   }
#end

#macro braco(beta)
   union {
     cylinder {<0.0,0.0,0.0>,<3.5,0.0,0.0>,0.7 texture {marrom}}
     sphere {
       <0.0,0.0,0.0>,0.8 texture {marrom}
     }
     object { antebraco() rotate beta*z translate 3.3*x  }
   }
#end

#macro lanca()
   union {
   cylinder {
       <0.0,-15.0,0.0>,<0.0,15.0,0.0>,0.5 texture {prata}
     }
     cone {
       <0.0,15.0,0.0>,1.0,<0.0,17.0,0.0>,0.0 texture {ouro}
     }
   }
#end

#macro antebraco_direito(lan1,lan2,lan3)
   union {
     object { antebraco() }
     object { lanca() rotate lan1*x rotate lan2*y rotate lan3*z translate 5.6*x }
   }
#end

#macro braco_direito(beta,lan1,lan2,lan3)
    union {
     cylinder {<0.0,0.0,0.0>,<3.5,0.0,0.0>,0.7 texture {marrom}}
     sphere {
       <0.0,0.0,0.0>,0.8 texture {marrom}
    }
    object { antebraco_direito(lan1,lan2,lan3) rotate beta*z translate 3.3*x  }
   }
#end

#macro batata()
union {
     cylinder {
       <0.0,0.0,0.0>,<0.0,-5.0,0.0>,0.8 texture {marrom}
     }
     sphere {
       <0.0,0.0,0.0>,1.0 texture {marrom}
     }
     sphere {
       <0,-5.7,0.0>,1.5 texture {marrom}
     }
   }
#end

#macro perna(gama)
   union {
     cylinder {<0.0,0.0,0.0>,<0.0,-5.0,0.0>,0.8 texture {marrom}}
     sphere {
       <0.0,0.0,0.0>,1.0 texture {marrom}
     }
     object { batata() rotate gama*x  translate -4.8*y }
   }
#end

#macro Tronco(a,b,c,d,e,f,g,h,i,j,k,lan1,lan2,lan3,TOTAL)
   union {
    sphere {
      <0,0,0>,4.5 texture { marrom } scale<1.0,1.2,1.0>
    }
    object { cabeca() rotate a*y translate 8.5*y }
    object { braco_direito(b,lan1,lan2,lan3) rotate c*y rotate d*z translate 3.5*x translate 3.0*y }
    object { braco(e) rotate f*y rotate g*z translate 3.5*x translate 3.0*y scale <-1,1,1>}
    object { perna(h) rotate i*x translate -4.5*y translate -1.5*x}
    object { perna(j) rotate k*x translate -4.5*y translate  1.5*x}
    rotate TOTAL*y
  }
#end

#if (clock <= 0.2)
   #declare clock2 = clock/0.2;
   #declare B = -(90*clock2);
   #declare C = -(90*(1.0-clock2));
   #declare D = -(20*clock2);
   #declare E = -90;
   #declare F = 0;
   #declare G = -20;
   #declare H = 0;
   #declare I = 0;
   #declare J = 0;
   #declare K = 0;
   #declare LAN1 = 90*clock2;
   #declare LAN2 = -(20*clock2);
   #declare LAN3 = 0;
   #declare TOTAL = 0;
#end

#if ( (clock > 0.2) & (clock <= 0.4) )
    #declare clock2 = (clock-0.2)/(0.4-0.2);
    #declare B = -90+clock2*(40+90);
    #declare C = -90*clock2;
    #declare D = -20+clock2*20;
    #declare E = -90+clock2*(40+90);
    #declare F = -90*clock2;
    #declare G = -20+clock2*20;
    #declare H = 0;
    #declare I = 0;
    #declare J = 0;
    #declare K = 0;
    #declare LAN1 = 90+clock2*(-180);
    #declare LAN2 = -20+clock2*20;
    #declare LAN3 = 90*clock2;
   #declare TOTAL = 0;
#end

#if ( (clock > 0.4) & (clock <= 0.45) )
    #declare clock2 = (clock-0.4)/(0.45-0.4);
    #declare B = 40;
    #declare C = -90;
    #declare D = 0;
    #declare E = 40;
    #declare F = -90;
    #declare G = 0;
    #declare H = 40*clock2;
    #declare I = 80*clock2;
    #declare J = 0;
    #declare K = 0;
    #declare LAN1 = -90;
    #declare LAN2 = 0;
    #declare LAN3 = 90;
   #declare TOTAL = 0;
#end

#if ( (clock > 0.45) & (clock <= 1.0) )
    #declare clock2 = (clock-0.45)/(1.0-0.45);
    #declare B = 40;
    #declare C = -90;
    #declare D = 0;
    #declare E = 40;
    #declare F = -90;
    #declare G = 0;
    #declare H = 40;
    #declare I = 80;
    #declare J = 0;
    #declare K = 0;
    #declare LAN1 = -90;
    #declare LAN2 = 0;
    #declare LAN3 = 90;
    #declare TOTAL = 360*clock2;
#end

Tronco(0.0,B,C,D,E,F,G,H,I,J,K,LAN1,LAN2,LAN3,TOTAL)

// Original camera parameters:
// #local cam_ctr = <0,0,0>
// #local cam_vec = <0.0,10,40.00>
// #local cam_sky = y

#include "camlight.inc"
camlight(<0,0,0>,<10,5,7>,40.0,y,1.0)