// Felipe Marinho Tavares
// R.A.: 265680
// Unicamp - MC937A/MO603A – Computação Gráfica - 2020-S2 - Jorge Stolfi

#version 3.6;
global_settings{ max_trace_level 30 }

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

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

#declare brown_soft_149_111_82 = color rgb < 149/255, 111/255, 82/255 >;

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.600, 0.600, 0.600 >, color rgb < 0.900, 0.900, 0.900 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 0.45
  }

#declare tx_woodish =
  texture{
    pigment{ brown_soft_149_111_82 }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

#declare tx_espelho =
  texture{
    pigment{ color rgb < 1.000, 1.000, 1.000 > }
    finish{ diffuse 0.05 reflection 0.95*< 1.000, 1.000, 1.000 > ambient 0 }
  }

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

#macro interpola1(tt, tt0, tt1, vv0, vv1)
  #local rr = (tt - tt0) / (tt1 - tt0);
  #local vv = (1 - rr) * vv0 + rr * vv1;
  vv
#end

#macro boiler()
  union{
    cylinder{ <0, 0, 0.3>, <0, 0, 0.8>, 0.1 texture{tx_caldeira}}
    cylinder{ <0.05, 0.05, 0>, <0.05, 0.05, 0.3>, 0.02 texture{tx_woodish}}
    cylinder{ <-0.05, -0.05, 0>, <-0.05, -0.05, 0.3>, 0.02 texture{tx_woodish}}
    cylinder{ <0.05, -0.05, 0>, <0.05, -0.05, 0.3>, 0.02 texture{tx_woodish}}
    cylinder{ <-0.05, 0.05, 0>, <-0.05, 0.05, 0.3>, 0.02 texture{tx_woodish}}
  }
#end

#macro mirror(theta)
  union{
    object{ 
      box{ <0.0, -0.25, 0.0>, <0.01, 0.25, 0.8> texture{ tx_espelho }}
      rotate -theta*y
    }
    object{
      box{ <-0.01, -0.25, 0.0>, <0, 0.25, 0.8> texture{ tx_woodish }}
      rotate -theta*y
    }
    cylinder{ <-cos(radians(90-theta))*0.8/2, 0.0, 0.0>,
              <-cos(radians(90-theta))*0.8/2, 0.0, sin(radians(90-theta))*0.7/2>, 0.02 texture{tx_woodish}}
  }
#end

#include "eixos.inc"
#include "camlight.inc"
#include "frontal.inc" // frontal translates and rotates the obj to infront of camera and light source
#include "direcao_do_sol.inc"

#declare centro_cena = < 0.00, 0.00, 0.3 >;
#declare raio_cena = 2.7;

#declare hour = interpola1(clock, 0, 1, 4.0, 20.0);
#declare dir_camera = direcao_do_sol(-20, +15, hour);

#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1.20;

union{
  //object{ eixos(1.00) translate <0, 0, 0> }

  object { box {<-40, -40, -0.006>, <40, 40, -0.005> texture{tx_xadrez}} } // floor
  object { boiler() }
  
  object { mirror(30) rotate +47*z translate <-0.5, -0.6, 0> }
  object { mirror(25) translate <-0.60, 0, 0> }
  object { mirror(30) rotate -47*z translate <-0.5, +0.6, 0> }

  object { mirror(30) rotate +47*z translate <-0.5, -0.6, 0> scale <-1, 1, 1>}
  object { mirror(25) translate <-0.60, 0, 0> scale <-1, 1, 1>}
  object { mirror(30) rotate -47*z translate <-0.5, +0.6, 0> scale <-1, 1, 1>}
}

camlight(centro_cena, raio_cena, dir_camera, dist_camera, z, intens_luz)