// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2020-09-30 19:57:13 by jstolfi

// ======================================================================
// CORES E TEXTURAS

#include "retalho.inc"

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

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

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

// ======================================================================
// RETALHOS

#declare HEIGHT = 10;
#declare DEPTH = 10;
#declare WIDTH = 10;

// #declare feet_support =
//   array[4][4]
//   {
//     {<0, -0.5, 1>, <1, -0.5, 1> <2, -0.5, 1>, <3, -0.5, 1>},
//     {<0, -1, 0.6>, <1, -1, 0.6> <2, -1, 0.6>, <3, -1, 0.6>},
//     {<0, -1, 0.3>, <1, -1, 0.3> <2, -1, 0.3>, <3, -1, 0.3>},
//     {<0, 0, 0>, <1, 0, 0> <2, 0, 0>, <3, 0, 0>},
//   }

#declare feet_support =
  array[4][4]
  {
    {<-0.5, 0, HEIGHT / 5>, <-0.5, 1, HEIGHT / 5> <-0.5, 2, HEIGHT / 5>, <-0.5, 3, HEIGHT / 5>},
    {<-1, 0, 2 * HEIGHT / 15>, <-1, 1, 2 * HEIGHT / 15> <-1, 2, 2 * HEIGHT / 15>, <-1, 3, 2 * HEIGHT / 15>},
    {<-1, 0, HEIGHT / 15>, <-1, 1, HEIGHT / 15> <-1, 2, HEIGHT / 15>, <-1, 3, HEIGHT / 15>},
    {<0, 0, 0>, <0, 1, 0> <0, 2, 0>, <0, 3, 0>},
  }

// #declare bottom =
//   array[4][4]
//   {
//     {<0, 0, 0>, <0, 1, 1> <0, 2, 2>, <0, 3, 2>},
//     {<1, 0, 0>, <1, 1, 1> <1, 2, 2>, <1, 3, 2>},
//     {<2, 0, 0>, <2, 1, 1> <2, 2, 2>, <2, 3, 2>},
//     {<3, 0, 0>, <3, 1, 1> <3, 2, 2>, <3, 3, 2>},
//   }

#declare bottom =
  array[4][4]
  {
    {<0, 0, 0>, <1, 0, HEIGHT / 5> <2, 0, HEIGHT / 3>, <3, 0, HEIGHT / 3>},
    {<0, 1, 0>, <1, 1, HEIGHT / 5> <2, 1, HEIGHT / 3>, <3, 1, HEIGHT / 3>},
    {<0, 2, 0>, <1, 2, HEIGHT / 5> <2, 2, HEIGHT / 3>, <3, 2, HEIGHT / 3>},
    {<0, 3, 0>, <1, 3, HEIGHT / 5> <2, 3, HEIGHT / 3>, <3, 3, HEIGHT / 3>},
  }

// #declare bottom =
//   array[4][4]
//   {
//     {<0, 0, 0>, <1, 0, 0> <2, 0, 0>, <3, 0, 0>},
//     {<0, 1, HEIGHT / 5>, <1, 1, HEIGHT / 5> <2, 1, HEIGHT / 3>, <3, 1, HEIGHT / 3>},
//     {<0, 2, HEIGHT / 3>, <1, 2, HEIGHT / 5> <2, 2, HEIGHT / 3>, <3, 2, HEIGHT / 3>},
//     {<0, 3, HEIGHT / 3>, <1, 3, HEIGHT / 5> <2, 3, HEIGHT / 3>, <3, 3, HEIGHT / 3>},
//   }



#declare test =
  array[4][4]
  {
    {<0, 0, 0>, <0, 1, 1> <0, 2, 2>, <0, 3, 2>},
    {<1, 0, 0>, <1, 1, 1> <1, 2, 2>, <1, 3, 2>},
    {<2, 0, 0>, <2, 1, 1> <2, 2, 2>, <2, 3, 2>},
    {<3, 0, 0>, <3, 1, 1> <3, 2, 2>, <3, 3, 2>},
  }


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

#declare raio = 2.000;

#include "eixos.inc"

union{
  #local current = 0;

  #while (current < 4)
    #declare feet_support[3][current] = (feet_support[2][current] + bottom[current][1]) / 2;
    #declare bottom[current][0] = feet_support[3][current];
    #local current = current + 1;
  #end

  object{ eixos(5.00) }

  object { retalho(feet_support, 0.00, tx_plastico2, tx_plastico, 0, 0, 10, 10)}
  object { retalho(bottom, 0.00, tx_plastico2, tx_plastico, 0, 0, 10, 10)}


}

#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 1.00 >;
#declare raio_cena = 10.0;
#declare dir_camera = < -2.00, -1, 0.5 >;
#declare dist_camera = 1*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)