// Last edited on DATE TIME by USER
// Processed by remove-cam-lights

#include "eixos.inc"
#include "dados.inc"
#include "retalho-simples.inc"

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

#declare txylw =
  texture{
    pigment{ color rgb < 1.00, 0.80, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
}
#declare txred =
  texture{
    pigment{ color rgb < 1.00, 0.10, 0.10 > }
    finish{ diffuse 0.9 ambient 0.1 }
}

#macro emenda_retalho(PP,r0,s0,r1,s1)
  #for(i,0,3)
    #declare PP[r0][s0][i][3] = (PP[r0][s0][i][2] + PP[r1][s1][i][1])/2;
    #declare PP[r1][s1][i][0] = (PP[r0][s0][i][2] + PP[r1][s1][i][1])/2;
  #end
#end

#macro carro(PP,NV,NH)
union{

  emenda_retalho(PP,0,0,0,1)
  emenda_retalho(PP,0,1,0,2)

  #for(lin,0,NV-1)
    #for(col,0,NH-1)
      #local P = array[dens][dens];

      #for(i,0,dens-1)
        #for(j,0,dens-1)
          #local P[i][j] = PP[lin][col][i][j];
        #end
      #end

      object{ retalho(P,0.01,txylw,txred) }
      object{ retalho(P,0.01,txylw,txred) scale <-1,1,1> }
    #end
  #end
}
#end

object{ eixos(1.00) translate < 0,0,0 > }
object{ carro(PP,NV,NH) }

#include "camlight.inc"
#declare centro_cena = < 0, 4.5, 1>;
#declare raio_cena = 7;
#declare dir_camera = < 10, 10, 8 >;
#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)