// 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 < 0.20, 0.70, 5.00 > }
    finish{ diffuse 0.9 ambient 0.1 reflection 0.3 }
  }

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

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

#declare raio = 2.000;

// Partes da cena:

#declare bolinha = 
  sphere{ < 0,0,0 >, 0.60 }
 
#declare bolota = 
  sphere{ < 0,0,0 >, 1.50 }
 
#declare bola =
  sphere{
    < 0.00, 0.00, 0.00 >, raio 
    texture{ tx_plastico }
  }
  
#declare pino = 
  cylinder{
    < -2.00, +2.00, -1.00 >,
    < +2.00, -2.00, +1.00 >,
    0.75
    texture{ tx_fosca }
  }
  
#declare furo = 
  cylinder{
    < -1.00, -2.00, -2.00 >,
    < +1.00, +2.00, +2.00 >,
    0.75*raio
    texture{ tx_fosca }
  }

#declare caixa = 
  box{ < 0, 0, 0 >, < 6, 6, 6 > }

#declare abertura =
  box{ < 0.2, 0.2, 0.2 >, < 5.8, 5.8, 6.1 > texture{ tx_fosca } }


#declare topo =
  cylinder{ <+3,+0,+9>, <+3,+6,+9>, 0.5 }

#declare meio =
  sphere{ < 3, 0.5, 8 >, 0.5 }

#declare fundo =
  cone{ < 3, 0.5, 7.5>, 0.5, < 3, 0.5, 6 >, 0 }


#declare olho =
  sphere{ <0,0,0>, 0.3 texture{ tx_espelho } }

#declare orelha =
  box{ < -0.1 , -0.5 , 0 >, < 0.1, 0.5 ,3 > texture { tx_plastico } }

#declare cabeca =
  sphere{ <0,0,0>, 2 texture { tx_plastico } }

#declare tronco =
  cylinder{ <0,0,0>, <0,0,5>, 2 texture { tx_plastico } } 

#declare musculo =
  cylinder{ <0,0,0>, <0,0,2>, 0.5 texture { tx_plastico } }
  
#declare articulacao =
  sphere{ <0,0,0>, 0.3 texture { tx_plastico } }
  
#declare apendice =
  box{ <0,-0.25,0>, <1,0.25,0.5> texture { tx_plastico } }


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

#macro head()
  union{
    object{ cabeca }
    object{ orelha rotate <-30,0,0> translate < 0, 0.5, 1.5 > }
    object{ orelha rotate < 30,0,0> translate < 0, -0.5, 1.5 > }
    object{ olho translate < 2, 0.5, 0.5 > }
    object{ olho translate < 2, -0.5, 0.5 > }
}
#end

#macro mao(M)
  union{
    object{ articulacao }
    object{ apendice translate <0,0,-0.8> rotate <0,M,0> texture{ tx_espelho } }
  }
#end


#macro antebraco(N,M)
  union{
    object{ articulacao }
    object{ musculo translate <0,0,-2.3> rotate <0,N,0> }
    object{ mao(M) translate <0,0,-2.6> rotate <0,N,0> }
  }
#end

#macro braco(X,Y,N,M)
  union{
    object{ articulacao }
    object{ musculo translate <0,0,-2.3> rotate <X,Y,0> }
    object{ antebraco(N,M) translate <0,0,-2.6> rotate <X,Y,0> }
  }
#end

#macro pe(P)
  union{
    object{ articulacao }
    object{ apendice translate <0,0,-0.8> rotate <0,P,0> texture{ tx_espelho } }
  }
#end

#macro canela(C,P)
  union{
    object{ articulacao }
    object{ musculo translate <0,0,-2.3> rotate <0,C,0> }
    object{ pe(P) translate <0,0,-2.6> rotate <0,C,0> }
  }
#end

#macro perna(X,Y,C,P)
  union{
    object{ articulacao }
    object{ musculo translate <0,0,-2.3> rotate <X,Y,0> }
    object{ canela(C,P) translate <0,0,-2.6> rotate <X,Y,0> }
  }
#end


//rabbit: A1,A2,A3,A4 = braco (A1 e A2), antebraco e mao esquerda do coelho
//        B1,B2,B3,B4 = braco (B1 e B2), antebraco e mao direita do coelho
//        C1,C2,C3,C4 = perna (C1 e C2), canela e pe esquerdo do coelho
//        D1,D2,D3,D4 = perna (D1 e D2), canela e pe direito do coelho
#macro rabbit(A1,A2,A3,A4, B1,B2,B3,B4, C1,C2,C3,C4, D1,D2,D3,D4)
  union{
    object{ head() translate <0,0,7> }
    object{ tronco }
    object{ braco(A1,A2,A3,A4) translate <0,2,4> }
    object{ braco(B1,B2,B3,B4) translate <0,-2,4> }
    object{ perna(C1,C2,C3,C4) translate <0, 1.5,0> }
    object{ perna(D1,D2,D3,D4) translate <0,-1.5,0> }    
  }
#end


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


#include "eixos.inc"

// Aqui está a cena, finalmente:

union{
  object{ rabbit(45,-45,-30,30, -45,-45,-30,30, 0,-70,150,-70, 0,-70,150,-70) }
}


#include "camlight.inc"
#declare centro_cena = < 0.00, 0.00, 5.00 >;
#declare raio_cena = 15.0;
#declare dir_camera = < 14.00, 7.00, 8.00 >;
#declare dist_camera = 20.0;
#declare intens_luz = 1.00;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)