// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2020-09-30 19:57:13 by jstolfi

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

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

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

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

#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 }
  }

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


#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 1.0
  }

// ======================================================================
// DESCRI��O DA CENA 
// Comentario do aluno: Não sobrou tempo para implementar os peoes encima do tabuleiro
// nem deu tambem para completamente implementar o numero n de casas por fileira
// Os objetos hiperpeao e hiperdama estao construidos mas nao estao em cena

#include "eixos.inc"

#declare esfera_pe = sphere{ < 0, 0, 0 >, 1 }
#declare esfera_corpo = sphere{ < 0, 0, 1.5 >, 0.5 }
#declare cone_cabeca = cone{ <0,0,1> , 0.1, <0,0, 2>, 0.5 }
#declare cone_corpo = cone{ <0,0,2> , 0.5, <0,0, 3>, 0.01 }
#declare casa_tabuleiro = cylinder { <0,0,0>, <0,0,1>, 0.5 }


//Macro tabuleiro que constroi todo o tabuleiro, n é W.I.P mas o m funciona
#macro tabuleiro(m,n)
  #declare iteration = 0;
  #while (iteration <= m)
    desenhar_borda(1)
    desenhar_borda(6 + 2 * iteration)
    #declare iteration = iteration + 2;
    object { casa_tabuleiro texture{tx_xadrez} translate <iteration, 0, 0> }
    object { casa_tabuleiro texture{tx_xadrez} translate <-iteration, 0, 0> }
    object { casa_tabuleiro texture{tx_xadrez} translate <0, iteration, 0> }
    object { casa_tabuleiro texture{tx_xadrez} translate <0, -iteration, 0> }
  
  #end
#end

//Macro para desenhar a borda de cada casa do tabuleiro
#macro desenhar_borda(raio)
  #declare borda_tabuleiro = cylinder{ <0,0,0>, <0,0,1>, 1 * raio}
  #declare borda_furo = cylinder{ <0,0,0>, <0,0,1>, 0.5 * raio}
  #declare borda = intersection {
    object{borda_furo texture{tx_fosca}} 
    object{borda_tabuleiro texture{tx_fosca}} 
  }
  object{borda texture{tx_fosca}} 
#end

#declare hiperpeao = union {
    object{ eixos(8.00) }
    object{esfera_pe texture {tx_fosca}}
    object{esfera_corpo texture {tx_fosca}}
    object{cone_cabeca texture{tx_plastico}}
}

#declare hiperdama = union {
    object{ eixos(8.00) }
    object{esfera_pe texture {tx_fosca}}
    object{cone_corpo texture {tx_plastico}}
    object{cone_cabeca texture {tx_plastico}}
}



object{ eixos(8.00) }

tabuleiro(4,0)
// object{hiperpeao}
// object{hiperdama}



#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 20.0;
#declare dir_camera = < 14.00, 7.00, 4.00 >;
#declare dist_camera = 2*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)