#include "camlight.inc"
#include "eixos.inc"
#include "textures.inc"
#include "retalho.inc"
#include "objs.inc"

#declare tx_painel = texture {
  pigment { color rgb< 1, 0, 0 > }
  finish { ambient 1 diffuse 0 }
}

#declare chao = box{ <-50,-50,-1>, <+50,+50,0> }

#macro lateral(wid, dep, hei)
  #local pad = 0.5;

  #local l1 = union {
    box {
      <0, 0, 0>,
      <wid, dep, hei>
      texture { tx_verde }
      rotate <45, 0, 0> // <x°, y°, z°>
      translate < -(wid / 2), hei * 0.72, -dep >
    }
    box {
      <0, 0, 0>,
      <wid - pad, 1.2, hei*0.71>
      texture { tx_painel }
      rotate <45, 0, 0> // <x°, y°, z°>
      translate < -((wid - pad) / 2) , hei * 0.7, -0.5 >
    }
  }
  
  #local l2 = object{ l1 rotate < 0, 0, 90 > } 
  #local l3 = object{ l1 rotate < 0, 0, 180 > } 
  #local l4 = object{ l1 rotate < 0, 0, 270 > } 

  difference {
    union {
      object { l1 }
      object { l2 }
      object { l3 }
      object { l4 }
      box {
        <0, 0, 0.69 * (hei-dep)>,
        <wid, wid, 0.6 * (hei-dep)>
        translate < -(wid / 2), -(wid / 2), 0 >
        texture { tx_verde }
      }
    }
    box {
      <-hei, -hei, 0.69 * (hei-dep)>,
      <hei, hei, hei>
      texture { tx_verde }
    }
  }
#end

union {
  object { eixos(5) }
  object { chao translate < 0,0,2 > texture{ tx_xadrez } }
  object { lateral(5, 2, 10) }
  object { lateral(5, 2, 10) scale <0.7, 0.7, 1> rotate < 0, 0, 45 >} // <x, y, z> }
}

#include "direcao_do_sol.inc"
#include "parametros.inc"

#local dir_sol = direcao_do_sol(lat, lon, mes, hora);
#declare dir_camera = dir_sol;

#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 15.0;
// #declare dir_camera = < 45.00, 45.00, 45.00 >;
#declare dist_camera = 200 * raio_cena;
#declare intens_luz = 1.0;
camlight(centro_cena, raio_cena, dir_camera, dist_camera, z, intens_luz)