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

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

#declare tx_xadrez =
  texture{
    pigment{ checker color rgb < 0.10, 0.32, 0.60 >, color rgb < 1.00, 0.97, 0.90 > }
    finish{ diffuse 0.9 ambient 0.1 }
    scale 2.0
  }

#declare tx_vidro = 
  texture{
    pigment{ color rgb < 0.85, 0.95, 1.00 > filter 0.70 }  // filter cria o efeito de difracao
    finish{ diffuse 0.03 reflection 0.25 ambient 0.02 specular 0.25 roughness 0.005 }
  }

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

#declare tx_espelho = 
  texture{
    pigment{ color rgb < 1.00, 0.85, 0.30 > }
    finish{ diffuse 0.2 reflection 0.7*< 1.00, 0.85, 0.30 > ambient 0.1 }
  }

// ======================================================================
// DESCRIÇÃO DA CENA 

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

#declare raio = 2.000;

#declare raio_dodecaedro = 1.0820;

//declaracao de plano: plane{ <normal>, distancia }

#declare tetra_plane_1 =
  plane{ <0,0,1>, 1 }
  
#declare tetra_plane_2 =
  plane{ <1,0,0>, 1 }
  
#declare tetra_plane_3 =
  plane{ <0,1,0>, 1 }
  
#declare tetra_plane_4 =
  plane{ <-1,-1,-1>, 1 }
  
  
#declare cubo =
  box{ <2,2,2>, <-2,-2,-2> }  
  
  
#declare octa_plane_1 =
  plane{ <1,1,1>, 1 }
  
#declare octa_plane_2 =
  plane{ <1,1,-1>, 1 }

#declare octa_plane_3 =
  plane{ <1,-1,1>, 1 }

#declare octa_plane_4 =
  plane{ <-1,1,1>, 1 }
  
#declare octa_plane_5 =
  plane{ <1,-1,-1>, 1 }
  
#declare octa_plane_6 =
  plane{ <-1,1,-1>, 1 }
  
#declare octa_plane_7 =
  plane{ <-1,-1,1>, 1 }
  
#declare octa_plane_8 =
  plane{ <-1,-1,-1>, 1 }

// dodecaedro: p=(sqrt(5) - 1)/2)

#declare dode_plane_1 =
  plane{ <1,0,(sqrt(5) - 1)/2>, raio_dodecaedro }

#declare dode_plane_2 =
  plane{ <1,0,-(sqrt(5) - 1)/2>, raio_dodecaedro }

#declare dode_plane_3 =
  plane{ <-1,0,(sqrt(5) - 1)/2>, raio_dodecaedro }

#declare dode_plane_4 =
  plane{ <-1,0,-(sqrt(5) - 1)/2>, raio_dodecaedro }

#declare dode_plane_5 =
  plane{ <(sqrt(5) - 1)/2, 1, 0>, raio_dodecaedro }

#declare dode_plane_6 =
  plane{ <(sqrt(5) - 1)/2, -1, 0>, raio_dodecaedro }

#declare dode_plane_7 =
  plane{ <-(sqrt(5) - 1)/2, 1, 0>, raio_dodecaedro }

#declare dode_plane_8 =
  plane{ <-(sqrt(5) - 1)/2, -1, 0>, raio_dodecaedro }

#declare dode_plane_9 =
  plane{ <0,(sqrt(5) - 1)/2, 1>, raio_dodecaedro }

#declare dode_plane_10 =
  plane{ <0,(sqrt(5) - 1)/2, -1>, raio_dodecaedro }

#declare dode_plane_11 =
  plane{ <0,-(sqrt(5) - 1)/2, 1>, raio_dodecaedro }

#declare dode_plane_12 =
  plane{ <0,-(sqrt(5) - 1)/2, -1>, raio_dodecaedro }
  


// ======================================================================
// MACROS

#macro tetraedro(textura)
  intersection{
    object{ tetra_plane_1 texture{ textura } }
    object{ tetra_plane_2 texture{ textura } }
    object{ tetra_plane_3 texture{ textura } }
    object{ tetra_plane_4 texture{ textura } }
  }
#end

#macro octaedro(textura)
  intersection{
    object{ octa_plane_1 texture{ textura } }
    object{ octa_plane_2 texture{ textura } }
    object{ octa_plane_3 texture{ textura } }
    object{ octa_plane_4 texture{ textura } }
    object{ octa_plane_5 texture{ textura } }
    object{ octa_plane_6 texture{ textura } }
    object{ octa_plane_7 texture{ textura } }
    object{ octa_plane_8 texture{ textura } }
  }
#end

#macro dodecaedro(textura)
  intersection{
    object{ dode_plane_1 texture{ textura } }
    object{ dode_plane_2 texture{ textura } }
    object{ dode_plane_3 texture{ textura } }
    object{ dode_plane_4 texture{ textura } }
    object{ dode_plane_5 texture{ textura } }
    object{ dode_plane_6 texture{ textura } }
    object{ dode_plane_7 texture{ textura } }
    object{ dode_plane_8 texture{ textura } }
    object{ dode_plane_9 texture{ textura } }
    object{ dode_plane_10 texture{ textura } }
    object{ dode_plane_11 texture{ textura } }
    object{ dode_plane_12 texture{ textura } }
    
  }
#end

// ======================================================================

#include "eixos.inc"

// Aqui está a cena, finalmente:

union{
	object{ chao translate < 0,0,-5 > texture{ tx_xadrez } }
//	object{ tetraedro(tx_vidro) translate <-8,-9,0> interior{ ior 1.3 } } // ior cria a refracao
	object{ octaedro(tx_plastico) translate <-1,4,0> }
	object{ dodecaedro(tx_plastico_2) translate <-1,4,0> }
	object{ cubo texture{ tx_vidro } interior{ ior 1.35 } translate <3,0,0> }
	object{ octaedro(tx_plastico) translate <3,0,0> }
}



#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 9.0;
#declare dir_camera = < 5.00, 7.00, 2.00 >;
#declare dist_camera = 35.00;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)