// Last edited on 2003-12-09 02:02:30 by stolfi
#include "colors.inc"
#include "textures.inc"
#include "metals.inc"
#include "skies.inc"
#include "glass.inc"

#declare YCH = -2.3;
#declare velocity = 3;

#declare ctr = < 0.00, -1.50, 2.00 > + <0,0,3*sin(2*pi*clock)>;
#declare camDir = < 8.00, 3.0, 5.00 >;

// sphere{ ctr, 1 texture{ pigment{ color rgb <1,0,1> } finish { ambient 0.6 diffuse 0.4 } } }

camera {
  location   ctr + 1.00*camDir
  right      -0.80*x
  up         0.60*y
  sky        y
  look_at    ctr
}

plane {
  y, YCH
  texture{ 
    pigment{ checker color rgb <0.7,0.5,0.6>, color rgb <0.6,0.2,0.5> }
    finish{ diffuse 0.7 ambient 0.3 }
    scale 0.5*velocity
  }
}

sky_sphere{S_Cloud1}


background{ color rgb < 0.2, 0.7, 0.85 > }

light_source{<1500,2500,2500> color White}

light_source{<-1500,2500,2500> color White}

#declare clockp=mod(clock+0.5,1);
 

#declare A = 0;
#declare B = 0;
#declare C = 0;
#declare D = 0;

#declare inseto  = 
  union{
    sphere { <0, 0, 0>, 0.5 
      scale <1,1,5>
      pigment { Green }
    } 
    sphere { <0, 0, 2.5>, 0.5
      pigment { DarkGreen }
    }
  }


// a perna eh composta de 4 partes, saindo do tronco ate chegar no chao, respectivamente: p4, p3, p2, p1

#declare k1 = 0.5; // size
#declare k2 = 0.9;
#declare k3 = 1.2;
#declare k4 = 1.4;
#declare a1 = 2; // angle
#declare a2 = 3;
#declare a3 = -4;
#declare a4 = -45;

#declare p1 =  
  cylinder { <0, 0, 0>, <k1, 0, 0>, 0.125
    pigment { Yellow }
    rotate a1
    translate <0,1*sin(2*pi*clock),0>
  }

#declare p2 =  
  union {
    cylinder { <0, 0, 0>, <k2, 0, 0>, 0.125
      pigment { White } }
    object {p1 
      translate <k2,0,0>      
    }
    rotate a2
    translate <0,1*sin(2*pi*clock),0>
  }

#declare p3 =  
  union {
    cylinder { <0, 0, 0>, <k3, 0, 0>, 0.125
      pigment { Red } }
    object {p2 
      translate <k3,0,0>      
    }
    rotate a3
    translate <0,1*sin(2*pi*clock),0>
  }

#declare p4 =  
  union {
    cylinder { <0, 0, 0>, <k4, 0, 0>, 0.125
      pigment { Violet } }
    object {p3 
      translate <k4,0,0>      
    }
    rotate a4
    translate <0,0,3*sin(2*pi*clock)>
  }

#declare gerador = seed(1234567);

#declare j = 0;

#while (j <= 4)
  object {p4
    translate <0 ,0 ,rand(gerador)*2.5>
    rotate <0,0,5*sin(2*pi*clock)>
  }
  object {p4
    translate <0 ,0 ,rand(gerador)*-2.5>
       rotate <0,0,5*cos(2*pi*clock)>
  }
  #declare j = j + 1;
#end

#declare j = 0;
#while (j <= 4)
  object {p4
    translate <0 ,0 ,rand(gerador)*2.5>
    scale <-1, 1, 1>
  }
  object {p4
    translate <0 ,0 ,rand(gerador)*-2.5>
    scale <-1, 1, 1>
  }
  #declare j = j + 1;
#end

object{inseto
  translate <0,0,3*sin(2*pi*clock)>
}