// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2010-03-04 15:44:01 by stolfi

// ======================================================================
// 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_preta = 
  texture{
    pigment{ color rgb < 0.20, 0.20, 0.20 > }
    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_rosquinha = 
 texture{
   pigment{ color rgb < 0.566, 0.276, 0.076 > }
   finish{ diffuse 0.9 ambient 0.1 }
 }

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

// ======================================================================
// DESCRIÇÃO DA CENA 
#declare chao = 
  box{ <-70,-70,-6>, <+70,+70,-5> }

#declare orelha = 
  cone{ <0,0,0> , 0.50, <0,0,1>, 0 texture{tx_fosca}}

#declare bola = 
  sphere{ < 0,0,0 >, 0.50  texture{tx_fosca}}


// MACROS
#macro gato(ombroEsquerdo, cotoveloEsquerdo, ombroDireito, cotoveloDireito,
	    coxaEsquerda, joelhoEsquerdo, peEsquerdo
	    coxaDireita, joelhoDireita, peDireita)
  
  union{
    object{bola scale 2}
    object{bracoCompleto(cotoveloDireito, 1) rotate<-ombroDireito+30 ,0,0>translate <0,0,1> rotate<60,0,0>}
    object{bracoCompleto(cotoveloEsquerdo, 0) rotate<ombroEsquerdo -30,0,0> translate <0,0,1> rotate<-60,0,0>}
    object{coxa(joelhoEsquerdo,peEsquerdo) rotate<coxaEsquerda -30 ,0,0> translate <0,0,-1> rotate<30,0,0>}
    object{coxa(joelhoDireita,peDireita) rotate<coxaDireita +30,0,0>  translate <0,0,-1> rotate<-30,0,0>}
    object{cabeca() translate <0,0,1>}
  }
#end

#macro cabeca()
  union{
    object{ bola  translate <0,0,0.4>}
    object {orelha scale 0.4 translate <0,-0.15,0.75>}
    object {orelha scale 0.4 translate <0,+0.15,0.75>}
  }
#end


#macro bracoCompleto(cotovelo, flag)
  union{
    object{ bola scale 0.37}
    object{ cylinder{ <0,0,0>, <0,0,+1> ,0.175 texture{tx_fosca}} }
    object{anteBraco(flag) rotate<0,cotovelo,0> translate<0,0,+1> }
  }
#end

#macro anteBraco(flag)
  //TODO colocar o relogio se flag = 1
  #if(flag =0)
  union{
    object{ bola scale 0.37}
    object{ cylinder{ <0,0,0>, <0,0,0.85> ,0.175 texture{tx_fosca}} }
    object { box  {<0,-0.3,0>, <0.1,0.3,0.6> texture{tx_fosca}} translate<0,0,0.85>}
  }
  #else
  union{
    object{ bola scale 0.37}
    object{ cylinder{ <0,0,0>, <0,0,0.85> ,0.175 texture{tx_fosca}} }
    object{ cylinder{ <+0.1,0,0.5>, <-0.1,0,0.5> ,0.175 texture{tx_preta}} translate<0.1,0,0> }
    object { box  {<0,-0.3,0>, <0.1,0.3,0.6> texture{tx_fosca}} translate<0,0,0.85>}
  }
  #end
#end

#macro coxa(joelho, pe)
  union{
    object{ bola scale 0.37}
    object{ cylinder{ <0,0,0>, <0,0,-1> ,0.175 texture{tx_fosca}} }
    object{canela(pe) rotate<0,joelho,0> translate<0,0,-1> }
  }
#end

#macro canela(pe)
  union{
    object{ bola scale 0.37}
    object{ cylinder{ <0,0,0>, <0,0,-0.85> ,0.175 texture{tx_fosca}} }
    object { peObject() rotate<0,-90,0> rotate<0,pe,0> translate<0,0,-0.85> }
  }
#end

#macro peObject()
    union{
      object { box  {<0,-0.2,0.2>, <0.3,0.2,-0.8> texture{tx_fosca}} }
}
#end



#include "eixos.inc"

// Aqui está a cena, finalmente:
object{ chao texture{ tx_xadrez }  }
object{ gato(-45,90,-45,90,0,0,30,0,0,0)  translate<-2,+2,0>}
object{ gato(-45,90,-45,90,0,0,30,15,45,0)  translate<+2,-2,0>}
//object{coxa(0,0)}
#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 0.00 >;
#declare raio_cena = 6.0;
#declare dir_camera = < 14.00, 7.00, 4.00 >;
#declare dist_camera = 70.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)