// Last edited on 2003-12-09 02:00:04 by stolfi
#include "colors.inc"

#declare ZCH = -4;
#declare vel = 18.0;

#declare ctr = <0.00, -10.00,  -1.00 > + clock*vel*y;
#declare camDir = < -5.00, 13.00, 7.00 >;

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

camera {
  location   ctr + 1.05*camDir
  right      -1.00*x
  up         0.75*y
  sky        z
  look_at    ctr
}

#declare gama=10;
#declare beta=60;
#declare alfa=120;
#declare c=20;

#declare fonte=seed(456231);

background{ color rgb < 0.95, .85, .50 > }


light_source {
  10*< -10.00, 30.00, 50.00 >
  color rgb 1.2*< 1.00, 1.00, 1.00 >
} 


light_source {
  10*< +30.00, 10.00, 50.00 >
  color rgb 0.4*< 1.00, 1.00, 1.00 >
} 
 

//TEXTURAS E CORES

#declare tx_espelho =
  texture{
  pigment { rgb <1,1,1> }
  finish {
    ambient 0.05 diffuse 0.05
    reflection Gray
    specular 0.30 roughness 0.05
   }
 }


//EIXOS

#declare eixoX =
cylinder{
   <3, 0, 0 >
   <-3, 0 ,0 >
  0.1
texture {
pigment { color Red filter 1}}
}

#declare eixoY =
cylinder{
   <0, 3, 0 >
   <0, -3 ,0 >
  0.1
texture {
pigment { color Blue filter 1}
}
}


//OBJETOS

#declare junta=
  sphere{ <0,0,0>,.2
  texture{pigment{color Green}}
}



#declare garra=
  cone {
    <0,0,0>, .2    // Center and radius of one end
    <0,0,-1>, 0   // Center and radius of other end
  }

#declare patas=

union{
#declare i=0;
#while(i<8)
  
  //angulos

   #if(mod(i,2)=0)
  #declare alfa=(10*sin(2*pi*3*(clock)+pi/4)+30);
  #declare alfa2=(9*sin(2*pi*3*(clock))+5);
  #declare beta=(-30*sin(2*pi*3*(clock))+50);
   #else
  #declare alfa=(10*sin(2*pi*3*(clock)+pi+pi/4)+30);
  #declare alfa2=(9*sin(2*pi*3*(clock)+pi)+5);
  #declare beta=(-30*sin(2*pi*3*(clock)+pi)+50);
   #end



#declare pe=
union{
  cylinder {
      <0,0,0>
      <-1,0,0>
       .2
      texture{pigment{color Red}}
  }
  object{
  junta
  translate <-1,0,0>
  }
  object{
  garra
  rotate gama*-y
  translate <-1,0,0>
  }
}
#declare perna=
union{
 cylinder {
      <0,0,0>
      <-5,0,0>
       .2
      texture{pigment{color Red}}
  }
  object{
  junta
  translate <-5,0,0>
  }
  object{
  pe
  rotate beta*y
  translate <-5,0,0>
  }
}


union{
 cylinder {
      <0,0,0>
      <-3,0,0>
       .2
      texture{pigment{color Red}}
  }
  object{
  junta
  translate <-3,0,0>
  }
  object{
  perna
  rotate 60*-y  
  rotate alfa*-y   //sobe
  translate <-3,0,0>
  }

  rotate c*y
  rotate alfa2*z //frente

translate <0,-2,0>

#if(i<4)
  translate <-3*.8,3,0>
  rotate 20*(i-2)*-z

#else
scale<-1,1,1>
  translate <3*.8,3,0>
  rotate 20*(i-6)*z

#end
}


#declare i=i+1;



#end
}






#declare corpo=
sphere{ <0,0,0>, 3
scale<1,.8,.8>
texture{pigment{color Red}}

}


#declare olho=

 object{
  corpo
  scale <1,1,1>*.1
  texture{pigment{color Black}}
 }

#declare aranha=


union{
  object{
  corpo
}

  object{
  corpo
  scale <1,1,1>*1.5
  translate<0,-5,0>
}

  object{
  corpo
  scale <1,1,1>*.5
  translate<0,3,0>
}

  object{
  olho
  translate<-.7,4,.7>
  }

  object{
  olho
  translate<.7,4,.7>
  }

 

  object{
  patas
 }
}




//CENA
union{
  object{
  aranha
  scale<1,1,1>*.8

  #declare to=(-9)*(1-clock)+clock*(9);
  translate <0,to,0>
  }

  //chao onde ela passa
  object { 
    plane {z,0}
    texture{ 
      pigment{ checker color rgb <0.5,0.6,0.7>, color rgb <0.2,0.5,0.6> }
      finish{ diffuse 0.7 ambient 0.3 }
      scale 0.25*vel
    }
    translate ZCH*z
  }
}