// 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_verde = 
  texture{
    pigment{ color rgb < 0.15, 1.00, 0.15 > }
    finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 }
  }

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

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

// MACROS QUE CONSTITUEM OS OBJETOS DA CENA

#macro pe()
  
  union{
    cylinder{
      <0, 0, -40>,
      <10, 0, -40>,
      4
      texture { tx_azul }
    }
    sphere{
      <0, 0, 0>
      4
      texture { tx_azul }
    }
    sphere{
      <10, 0, -40>
      4
      texture { tx_azul }
    }
    cylinder{
      <0, 0, 0>,
      <0, 0, -40>,
      4
      texture { tx_azul }
    }
    sphere{
      <0, 0, -40>
      4
      texture { tx_verde }
    }
  }
#end

#macro perna(p_x)
  union{
    sphere{
      <0, 0, 0>
      4
      texture { tx_verde }
    }
    cylinder{
      <0, 0, 0>,
      <-40, 0, 0>,
      4
      texture { tx_azul }
    }
    sphere{
      <-40, 0, 0>
      4
      texture { tx_verde }
    }
    
    object{ 
            pe()
            rotate p_x*x
    }
  }
#end

#macro garra ()
  cone{
    <0, -40, 0>,
    0,
    <0, 0, 0>,
    2
    texture {tx_vermelho}
  }
#end

#macro braco(g_z)
  #local garra1 = object{ garra() }
  #local garra2 = object{ garra() }
  
  union{
    sphere{
      <0, 0, 0>,
      6
      texture {tx_verde}
    }
    object{
      garra1
      rotate g_z*z
    }
    object{
      garra2
      rotate -g_z*z
    }
    cylinder{
      <0, 0, 0>,
      <0, 60, 0>,
      4
      texture { tx_vermelho }
    }
  }
#end 
              
  

#macro corpo(pe1, pe2, pe3, pe4, 
             perna1_z, perna2_z, perna3_z, perna4_z,
             perna1_y, perna2_y, perna3_y, perna4_y,
             garra1, garra2,
             braco1_z, braco2_z, 
             braco1_y, braco2_y,
             braco1_x, braco2_x)
             
  #local raio = 10;
  
  #local perna1 = object{ perna(pe1) translate <40, 0, 0>}
  #local perna2 = object{ perna(pe2) translate <40, 0, 0> scale <-1, 1, 1>} 
  #local perna3 = object{ perna(pe3) translate <40, 0, 0>}
  #local perna4 = object{ perna(pe4) translate <40, 0, 0> scale <-1, 1, 1>} 
  
  #local braco1 = object{ braco(garra1) translate <0, -60, 0>}
  #local braco2 = object{ braco(garra2) translate <0, -60, 0>}
  
  union{
    cylinder{
      <0, 100, 0>,
      <0, 0, 0>,
      raio
      texture{ tx_azul }
    }
    sphere{
        <0, 0, 0>
        raio
        texture { tx_azul }
    }
    sphere{
        <-raio, 80, 0>
        5
        texture { tx_verde }
    }
    sphere{
        <raio, 20, 0>
        5
        texture { tx_verde }
    }
    sphere{
        <-raio, 20, 0>
        5
        texture { tx_verde }
    }
    sphere{
        <raio, 0, 0>
        7
        texture { tx_verde }
    }
    sphere{
        <-raio, 0, 0>
        7
        texture { tx_verde }
    }
    
    object{  perna1 
             rotate perna1_z*z
             rotate perna1_y*y
             translate <raio, 80, 0>
    }
    object{  perna2 
             rotate perna2_z*z
             rotate perna2_y*y
             translate <-raio, 80, 0>
    }
    object{  perna3 
             rotate perna3_z*z
             rotate perna3_y*y
             translate <raio, 20, 0>
    }
    object{  perna4
             rotate perna4_z*z
             rotate perna4_y*y
             translate <-raio, 20, 0>
    }
    
    object{ braco1
            rotate braco1_z*z
            rotate braco1_y*y
            rotate braco1_x*x
            translate <raio, 0, 0>
    }
    object{ braco2
            rotate braco2_z*z
            rotate braco2_y*y
            rotate braco2_x*x
            translate <-raio, 0, 0>
    }
  }
  
#end


#include "eixos.inc"


//object{eixos (50)}

object{corpo(0, 0, 0, 0
             40, -40, 40, -40,
             0, 0, 0, 0,
             50, 50,
             50, -50,
             0, 0,
             0, 0)}
//object{braco(10)}

#include "camlight.inc"
#declare centro_cena = < 0, 0, 0>;
#declare raio_cena = 140;
#declare dir_camera = < 0, -10, 10 >;
#declare dist_camera = 5*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)