// Last edited on 2003-12-08 19:46:17 by stolfi
// Daniel Kalil Franulovic ra 001525

// ======================================================================

global_settings { assumed_gamma 1.5 }

#declare ctr = < +07.50, +15.00, -05.00 >;
#declare camDir = < 50, 20.00, 30.00 >;

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

// ======================================================================
// FONTES DE LUZ

light_source {
   10*< +30.0, -10.0, +70.0 >              // Posição da lâmpada.
  color rgb 1.0 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10*< +10.0, +30.0, +70.0 >             // Posição da lâmpada.
  color rgb 0.5 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10*< +10.0, +15.0, +100.0 >             // Posição da lâmpada.
  color rgb 0.4 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

// ======================================================================
// DESCRIÇÃO DA CENA 

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

#declare fonte = seed(464134659);

#include "colors.inc"
#include "stoneold.inc"
#include "skies.inc"
 
#declare tinta_marrom = 
  texture {
    pigment { color rgb < 0.3, 0.2, 0.05 > }
    finish { diffuse 0.9 specular 0.4 roughness 0.005 ambient 0.1 }
  }

 
#declare tinta_corpo = 
  texture {
    pigment { color rgb < 0.3, 0.2, 0.05 > }
    finish { diffuse 0.9 specular 0.4 roughness 0.005 ambient 0.1 }
  }

#declare mao = 

  prism {
    linear_sweep
    linear_spline
    0, // sweep the following shape from here ...
    0.7, // ... up through here
    5, // the number of points making up the shape ...
    <-0.6,-0.2>, <0.1,-0.15>, <0.1,0.15>, <-0.6,0.2>, <-0.6, -0.2>
    texture { tinta_marrom }
  }

#declare garra = 

  prism {
    linear_sweep
    linear_spline
    0, // sweep the following shape from here ...
    0.2, // ... up through here
    5, // the number of points making up the shape ...
    <-1.2,0>, <-0.6,0.15>, <-0.6,0.2>, <-0.9,0.1>, <-1.2, 0>
    texture { tinta_marrom }
    }

#declare pata = 

  object {union{
      object{mao}
      object{garra}
      object{garra translate<0,0.5,0>}
      }
    translate <0,-0.35,0>
    scale <1,1,-1>
  }

#declare articulacao = 

  cylinder{

  <0,-0.4,0>,
  <0,0.4,0>,
  0.4
  texture {tinta_marrom}
  }

#declare braco1 = 

  cylinder{

  <0,0,0>,
  <0,0,3>,
  0.4
  texture {tinta_marrom}

  }

#declare braco2 = 

  cylinder{

  <0,0,0>,
  <0,0,3.5>,
  0.4
  texture {tinta_marrom}

  }

#declare braco3 = 

  cylinder{

  <0,0,0>,
  <0,0,5>,
  0.4
  texture {tinta_marrom}

  }

#declare braco1pata = 
  union
  {
    object {pata scale 1.3 rotate <0,105,0> translate <0,0,3>}
    object {articulacao translate <0,0,3>}
    object {braco1}
}

#declare perna1 = 
  union
  {
    object {braco1pata  rotate <0,15,0> translate <0,0,3.5>}
    object {articulacao translate <0,0,3.5>}
    object {braco2}
  }

#declare perna = 
  union
  {
    object {perna1  rotate <0,45,0> translate <0,0,5>}
    object {articulacao translate <0,0,5>}
    object {braco3}
  }

#declare cabeca = 
  object {
    sphere {
      <0,0,0>,4
      texture {tinta_corpo}
      }
    translate <-7.5,-15,0>
    }

#declare corpo = 
  object{
  difference 
  {
    object {sphere {<0,0,0>,10 texture {tinta_corpo} scale <1,3,0.6>}}
    object {box   {<-100,-100,0>,<100,100,100> texture {tinta_corpo}} }
  }
  translate <-7.5,15,0>
  }

#declare i = 0;

#if (clock < 0.25)
  #declare alfa = 60 + 120*clock;
#end
#if ((clock >= 0.25)&(clock<0.5))
  #declare alfa = 90 - 120*(clock-0.25);
#end
#if (clock >= 0.5)
  #declare alfa = 60;
  #declare beta = 30 - 120*(clock-0.5);
  #declare gama = -30 + 120*(clock-0.5);
#end

#if (clock < 0.5)
  #declare delta = 60;
  #declare beta = -30 + 120*clock;
  #declare gama = 30 - 120*clock;
#end
#if ((clock >= 0.5)&(clock<0.75))
  #declare delta = 60 + 120*(clock-0.5);
#end
#if (clock >= 0.75)
  #declare delta = 90 - 120*(clock-0.75);
#end

#declare pernas = 
  union
  {

#while (i<3)

  object{
    union {
      object {  
      union
      {
        object { 

        union
        {
          object {pata scale 1.3 rotate <0,105,0> translate <0,0,3>}
          object {articulacao translate <0,0,3>}
          object {braco1}
        }
           rotate <0,15,0> translate <0,0,3.5>}
        object {articulacao translate <0,0,3.5>}
        object {braco2}
       }

        rotate <0,45 -(alfa-60)/2,0> translate <0,0,5>}
      object {articulacao translate <0,0,5>}
      object {braco3}
      object {articulacao}
    }

  #if (i = 1)
    rotate <0,-alfa,beta> scale<-1.5,1.5,1.5> translate<0,15*i,0>}
  #else
    rotate <0,-alfa,beta> scale 1.5 translate<-15,15*i,0>}
  #end

  object{
    union {
      object {  
      union
      {
        object { 

        union
        {
          object {pata  scale 1.3 rotate <0,105,0> translate <0,0,3>}
          object {articulacao translate <0,0,3>}
          object {braco1}
        }

          rotate <0,15,0> translate <0,0,3.5>}
        object {articulacao translate <0,0,3.5>}
        object {braco2}
       }

        rotate <0,45 - (delta-60)/2,0> translate <0,0,5>}
      object {articulacao translate <0,0,5>}
      object {braco3}
      object {articulacao}

    }

  #if (i = 1)
    rotate <0,-delta,gama>  scale 1.5 translate<-15,15*i,0>} //scale 1.5 pq a perna estava muito pequena
  #else
    rotate <0,-delta,gama>  scale<-1.5,1.5,1.5> translate<0,15*i,0>}
  #end

#declare i = i + 1;

#end

}

#declare chao = 
  plane { z,-16.0
  texture{ 
    pigment{ checker color rgb <0.7,0.6,0.5>, color rgb <0.6,0.5,0.2> }
    finish{ diffuse 0.7 ambient 0.3 }
    normal{ granite 0.1 scale 0.2 }
    scale 0.25*10.0
  }
}

#declare teste = 
  object {perna  rotate <0,0,90> translate <0,0,10>scale 2
    }

#declare inseto = 
  object{  union
    {
    object {pernas}
    object {corpo}
    object {cabeca}
    }
    rotate <0,180,0>
  }

sky_sphere{ S_Cloud5} //pq tah de lado???

inseto
chao