// Last edited on 2003-05-29 22:52:04 by stolfi

#include "colors.inc"
#include "metals.inc"
#include "woods.inc"
#include "glass.inc"
#include "skies.inc"

background { color rgb < 0.8, 1.0, 1.0 > }

#declare camX=2;
#declare camY=-1;
#declare camZ=15;

light_source {
  10*< 15.00, 20, 3.00 >
  color rgb 0.9*< 1,1,1 >
} 

light_source {
  < -10.00, 0, 20.00 >
  color rgb 0.9*<1,1,1>
} 

light_source {
  < 30.00, 0, 20.00 >
  color rgb 0.9*<1,1,1>
} 

// light_source {
//   < camX, camY, camZ >
//   color rgb < 2.00, 2.00, 2.00 >
// } 

camera {
  location  <camX , camY, camZ>
  right     -x
  up        y
  sky       y
  look_at   < camX, 0, 0 >
}

#declare pe = object {
  cylinder {
  <-1,-.3,0>,
  <4,-.3,0>,
   0.5
   pigment { White}
  }
}

#declare coxa_max_ang=45;

#declare pe_ang_max=15;

#if (clock <0.4)
 #declare pe_ang=-pe_ang_max/0.4*clock;
#else
#if (clock < 0.6)
 #declare pe_ang=-pe_ang_max - (3/2*pe_ang_max)/0.2*(clock-0.4);
#else
#if (clock < 0.8)
 #declare pe_ang=pe_ang_max/2;
#else
 #declare pe_ang= pe_ang_max/2 - pe_ang_max/0.4*(clock -0.8);
#end
#end
#end

#if (clock < 0.4)
  #declare coxa_ang =  acos((5 -4.5*sin(-pe_ang/180*pi))/5)*180/pi;
#else
#if (clock < 0.6)
  #declare aux=acos((5 -4.5*sin(-(-pe_ang_max/0.4*0.4) /180*pi))/5)*180/pi;
  #declare coxa_ang= aux + (coxa_max_ang - aux)/0.2*(clock -0.4);
#else
#if (clock < 0.8)
  #declare coxa_ang = coxa_max_ang - coxa_max_ang/0.2*(clock -0.6);
#else
  #declare coxa_ang = 0;
#end
#end
#end

#declare tornozelod = union {
  cylinder {
  <0,0,0>,
  <0,5,0>,
  1
  pigment { White}
  }
  object {pe translate <0.5,0,0>  rotate <0,0,pe_ang> translate <-0.5,0.5 ,0>}
}

#declare tornozeloe = union {
  cylinder {
  <0,0,0>,
  <0,5,0>,
  1
  pigment { White}
  }
  object {pe translate <0.5,0,0>  rotate <0,0,0> translate <-0.5,0.5 ,0>}
}

#declare pernad = union {
  cylinder {
    <0,0,0>,
    <0,5,0>,
    1.5
    pigment { White}
    translate <0,-5,0>
    rotate <0,0,coxa_ang>
    translate <0,5,0>
  }
  object{ tornozelod translate <5*sin(coxa_ang*pi/180),-4.5+5*(1-cos(coxa_ang*pi/180)),0> }
}

#declare pernae = union {
  cylinder {
    <0,0,0>,
    <0,5,0>,
    1.5
    pigment { White}
    translate <0,-5,0>
    rotate <0,0,0>
    translate <0,5,0>
  }
  object{ tornozeloe translate <0,-4.5,0> }
}

#declare tronco = union {
  cylinder {
    <0,0,0>,
    <0,10,0>,
    4
    pigment {White}
    translate <0,5,0>
  }
  object{pernae translate <0,0,-1.8>}
  object{pernad translate <0,0,1.8>}
}

tronco

plane { y,-6 pigment { checker color rgb <1,1,1>, color rgb <1,0.9,0.7> } }