// Last edited on DATE TIME by stolfi
#include "colors.inc"
#include "stoneold.inc"
#include "glass.inc"
#include "metals.inc"


// Exemplo de arquivo de descricao de cena para POV-ray

// ======================================================================
// C�MERA 

#declare ctr = < 5.00, 3.00, 1.00 >;
#declare camDir = < 0.00, -35.00, 10.00 >;

camera {
  location   ctr + 0.65*camDir
  right      -1.00*x
  up         0.75*y
  sky        z
  look_at    ctr
}
 
// Nota: os par≫metros "right" e "up" devem ter a mesma propor∫√o
// que os par≫metros ${WIDTH} e ${HEIGHT} no Makefile.

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

light_source {
  10 * < +50.0, -30.0, +50.0 >              // Posi∫√o da l≫mpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < +50.0, -10.0, +10.0 >             // Posi∫√o da l≫mpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < 40, 10, 0>
  color rgb 0.8 * <1,1,1>
}

// ======================================================================
// DESCRI��O DA CENA 

background{ color rgb < .6, 0.60, 1 > }

#declare tinta_A = 
  texture {
    pigment { color rgb < 0.10, 0.80, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_B = 
  texture {
    pigment { color rgb < 1.00, 0.80, 0.10 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_C = 
  texture {
    pigment { color rgb < 0.80, 1.00, 0.10 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_D = 
  texture {
    pigment { color rgb < 1.00, 0.80, 1.10 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }
  

#declare chao = 
  plane {z, -1
     pigment { rgb <0.8,0.8,0.8>  }
  }


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


#declare corpo = 
   box {
  <0,0,0>,
  <10,6,1>
  texture { Grnt7 scale 5}
//  translate <0,0,4>
}

#declare pernas =
union {

#declare k = seed(123242);

#declare j = 0;

#while (j<2)

#declare i=0;


#while (i<4)

#declare rdm1 = rand(k)*90;
#declare rdm2 = rand(k)*90;
#declare rdm3 = rand(k)*90;

#declare art4 =
   union {
      box {
  <0,0,0>,
  <.5,.5,1>
  texture { Grnt7 }
      }
      sphere {
  <.25,.25,0>
  .4
  texture {Grnt7}
      }
}

#declare art3 =
   union {
        box {
  <0,0,0>,
  <.5,.5,1.4>
  texture { Grnt7 }
      }
      sphere {
  <.25,.25,0>
  .4
  texture {Grnt7}
      }
}

#declare art2 =
   union {
        box {
  <0,0,0>,
  <.5,.5,1.4>
  texture { Grnt7 }
      }
      sphere {
  <.25,.25,0>
  .4
  texture {Grnt7}
      }
}

#declare art1 =
   union {
        box {
  <0,0,0>,
  <.5,.5,2.2>
  texture { Grnt7 }
      }
      sphere {
  <.25,.25,0>
  .4
  texture {Grnt7}
      }
}

#declare perna3 = 
   union {
  object {art4
    rotate x*rdm1
    translate <0,0,1.3>
    }
  object {art3}
}

#declare perna2 = 
   union {
  object {perna3
    rotate x*rdm2
    translate <0,0,1.4>
    }
  object {art2}
}

#declare perna1 = 
   union {
  object {perna2
    rotate x*rdm3
    translate <0,0,2.2>
    }
  object {art1}
  rotate x*90
}

object {perna1
  rotate <0,0,180*j>
  translate <i*3,j*6,0>
  }
  
#declare i = i + 1;

#end

#declare j = j + 1;

#end

}

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

object {chao}

//union {
//object {perna1
//  rotate z*180
//  translate y*6}
//
//object {corpo}
//rotate z*-90
//}

#declare bicho =
union{
  object {corpo}
  object {pernas}
}

object {bicho
  rotate z*120
  translate <9,0,3>

}