// Last edited on 2023-12-30 09:52:43 by stolfi
#version 3.7; global_settings { assumed_gamma 2.2 }

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

background{ color rgb < 0.8, 0.8, 0.8 > }
#declare roleta = seed(1246553);

#declare tx_templo = 
  texture{
    pigment{ color rgb < 0.6, 0.6, 0.6 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

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

#macro wall(p1, p2, p3, p4) 
    polygon {
        9, 
        p1, p2, p3, p4, p1,
        (9*p1+p2+p3+p4)/12,
        (p1+9*p2+p3+p4)/12,
        (p1+p2+9*p3+p4)/12,
        (p1+p2+p3+9*p4)/12
        texture { tx_templo }
    }
#end

#macro base(p1, p2, p3, p4, p5) 
  polygon {
      11,
      p1, p2, p3, p4, p5, p1
      (9*p1+p2+p3+p4+p5)/13,
      (p1+9*p2+p3+p4+p5)/13,
      (p1+p2+9*p3+p4+p5)/13,
      (p1+p2+p3+9*p4+p5)/13,
      (p1+p2+p3+p4+9*p5)/13
      texture { tx_templo }
  }
#end

#macro painel(p1, p2, p3, p4)
    polygon {
        4 // Number of points
        (9*p1+p2+p3+p4)/12,
        (p1+9*p2+p3+p4)/12,
        (p1+p2+9*p3+p4)/12,
        (p1+p2+p3+9*p4)/12
        texture {texture_painel}
    }
#end

#macro painel_cima(p1, p2, p3, p4, p5)
    polygon {
        5 // Number of points
        (9*p1+p2+p3+p4+p5)/13,
        (p1+9*p2+p3+p4+p5)/13,
        (p1+p2+9*p3+p4+p5)/13,
        (p1+p2+p3+9*p4+p5)/13,
        (p1+p2+p3+p4+9*p5)/13
        texture {texture_painel}
    }
#end

#macro pyramid()

  #local b1 = <-4,-4,0>;
  #local b2 = <-4,4,0>;
  #local b3 = <4,6,0>;
  #local b4 = <8,0,0>;
  #local b5 = <4,-6,0>;

  #local t1 = <-2,-2,5>;
  #local t2 = <-2,2,5>;
  #local t3 = <2,3,5>;
  #local t4 = <4,0,5>;
  #local t5 = <2,-3,5>;
  union{

    object{ base(b1, b2, b3, b4, b5) }
    object{ base(t1, t2, t3, t4, t5) }
    object{ wall(b1, t1, t2, b2) }
    object{ wall(b2, t2, t3, b3) }
    object{ wall(b3, t3, t4, b4) }
    object{ wall(b4, t4, t5, b5) }
    object{ wall(b5, t5, t1, b1) }

    object{ painel(b1, t1, t2, b2) }
    object{ painel(b2, t2, t3, b3) }
    object{ painel(b3, t3, t4, b4) }
    object{ painel(b4, t4, t5, b5) }
    object{ painel(b5, t5, t1, b1) }
    object{ painel_cima(t1, t2, t3, t4, t5) }
  }
#end

object{ pyramid() }

#local dir_norte = < 0.0, cos(radians(lat)), sin(radians(lat)) >; 
#local dir_sol = direcao_do_sol(lat, lon, mes, hora);

#include "eixos.inc"
#local cmp_eixos = 5.0;
// object{ eixos(cmp_eixos) }

#declare cmin = < -4.5, -6.3, 00.0 >;
#declare cmax = < +8.5, +6.3, +5.5 >;
#declare centro_cena = (cmin + cmax)/2;

#include "gaiola.inc"
// object{ gaiola(cmin,cmax) }
object{ gaichao(cmin,cmax) }

#include "camsol.inc"
#declare raio_cena = 0.65*vlength(cmax-cmin);
#declare intens_luz = 1.20;
// #declare vista = 3;
camsol(centro_cena, raio_cena, vista, dir_norte, dir_sol, intens_luz)