// 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.90, 0.80, 0.85 > }
#declare tx_fosca_cinza = 
texture{
pigment{ color rgb < 0.3, 0.3, 0.3 > }
finish{ diffuse 0.9 ambient 0.1 }
}

#declare roleta = seed(1);
#declare NMAX = 50;

// ======================================================================
// FORMAS

#declare raio = 2.000;  // A principio pode-se usar declare ou local
#declare pontoFinalCilindroVertice = <0, 2, 4>;
#declare pontoInicialCilindroVertice = < 0, 0, 3>;

#declare bolaVertice1 =
  sphere{
    < 0, 0, 0 >, 1.2 
    texture{ tx_fosca_cinza }
  }

#declare cilindroVertice1 = 
    cylinder {
        < 0, 0, 0>, <0, 1, 2>, 0.25 // center of one end, center of other end, radius
    }


#declare tanque = 
    cylinder {
        < 0, 0, 0>, <0, 0, 3>, 1 // center of one end, center of other end, radius
    }

#declare coneTanque1 =
    cone {
        <0, 0, 3>, 1 // <x, y, z>, center & radius of one end
        <0, 0, 4.5>, 0 // <x, y, z>, center & radius of the other end
    }

#declare cilindroCortaTanque1 = 
    cylinder {
        < 0, -2, 2.5>, <0, 2, 2.5>, 0.25 // center of one end, center of other end, radius
    }

#declare bolaTanque2 =
  sphere{
    < 0, 0, 3 >, 1.2 
    texture{ tx_fosca_cinza }
  }

#declare cilindroCortaTanque2 = 
    cylinder {
        < 0, 0, 3>, <0, 2, 4>, 0.25 // center of one end, center of other end, radius
    }


#declare cilindroCortaTanque3 = 
    cylinder {
        < 0, -2, 3.5>, <0, 2, 3.5>, 0.25 // center of one end, center of other end, radius
    }

    
#declare corpo =
    box {
        <-1, -2, -3>, <1, 2, 3> // <x, y, z> near lower left corner, <x, y, z> far upper right corner
    }
// ======================================================================
// Objetos



// ======================================================================
// Lógica
#macro pata()
  #local dedo1 = cylinder{<-1,-1,-8>, <-1,-3,-8>, 0.3}
  #local dedo2 = cylinder{<-1,-1,-8>, <-1,-5,-8>, 0.3}
  #local dedo3 = cylinder{<-2,-1,-7.5>, <-2,-3,-7.5>, 0.3}
  #local dedo4 = cylinder{<2,0,-7.5>, <2,-3,-7.5>, 0.3}
  union {
    object{dedo1 texture{tx_fosca_cinza}}
    object{dedo2 texture{tx_fosca_cinza}}
    object{dedo3 rotate<0,0,90> texture{tx_fosca_cinza}}
    object{dedo4 rotate<0,0,270> texture{tx_fosca_cinza}}
  }
#end


#macro subPerna(p3,p4)
  #local quadriceps = cylinder {<-1,-1,-5>, <-1,-1,-8>, 0.5}
  #local sub = object{pata()}
  #local juntas = sphere {<-1,-1,-8>, 0.6}
  union {
    object{quadriceps texture{tx_fosca_cinza}}
    object{sub rotate p3*y translate<0,2,0>}
    object{juntas texture{tx_fosca_cinza}}
  }
#end

#macro perna(p1,p2,p3,p4)
  #local origem = cylinder {<-1,1,-3>, <-1,1,-5>, 0.5}
  #local sub = object{subPerna(p3,p4)}
  #local juntas = sphere {<-1,1,-5>, 0.6}
  union {
    object{origem texture{tx_fosca_cinza}}
    object{sub rotate p2*y translate<0,2,0>}
    object{juntas texture{tx_fosca_cinza}}
  }
#end
// sdfvsdvsdfvdf


#macro dedos_braco()
  #local dedo1 = cylinder{<0,0,0>, <0,1.5,1>, 0.3}
  #local dedo2 = cylinder{<0,0,0>, <0,2,1>, 0.3}
  #local dedo3 = cylinder{<0,0,0>, <0,2.5,1>, 0.3}
  #local dedo4 = cylinder{<0,0,0>, <0,3,1>, 0.3}
  union {
    object{dedo1 texture{tx_fosca_cinza}}
    object{dedo2 texture{tx_fosca_cinza}}
    object{dedo3 texture{tx_fosca_cinza}}
    object{dedo4 texture{tx_fosca_cinza}}
  }
#end


#macro subbraco(p3,p4)
  #local triceps = cylinder {<1, 4, 2.5>, <1, 4, 0>, 0.5}
  #local sub = object{dedos_braco()}
  #local juntas = sphere {<1, 4, 0>, 0.6}
  union {
    object{triceps texture{tx_fosca_cinza}}
    object{sub rotate p3*y translate<1, 4, 0>}
    object{juntas texture{tx_fosca_cinza}}
  }
#end

#macro braco(p1,p2,p3,p4)
  #local origem = cylinder {<1, 2, 2.5>, <1, 6, 2.5>, 0.5}
  #local sub = object{subbraco(p3,p4)}
  #local juntas = sphere {<1, 6, 2.5>, 0.6}
  union {
    object{origem texture{tx_fosca_cinza}}
    object{sub rotate p2*y translate<0,2,0>}
    object{juntas texture{tx_fosca_cinza}}
  }
#end
// sdvfsdvdfv


#macro cranio()
  object{ sphere {
  <0, 0, 0>, 1 // <x, y, z>, radius
  
  }}
#end

#macro subcabeca(c3,c4)
  #local triceps = cylinder {<0, 0, 0>, <0,0,8>, 0.5}
  #local juntas = sphere {<0,0,8>, 0.6}
  #local k = object{cranio()}
  union {
    object{triceps texture{tx_fosca_cinza}}
    object{juntas texture{tx_fosca_cinza}}
    object{k translate<0,0,8> texture{tx_fosca_cinza}}
  }
#end

#macro cabeca(c1,c2,c3,c4)
  #local pescoco = cylinder {<0, 0, 1.5>, <0, 0, 6>, 0.5}
  #local sub = object{subcabeca(c3,c4)}
  #local juntas = sphere {<0, 0, 6>, 0.6}
  union {
    object{pescoco texture{tx_fosca_cinza}}
    object{sub rotate p2*y translate<0, 0, 6>}
    object{juntas texture{tx_fosca_cinza}}
  }
#end



#macro robo(c1,c2,c3,c4, b1,b2,b3,b4,d1,d2,d3,d4, e1,e2,e3,e4, p1,p2,p3,p4)
  union {
    object{corpo}
    object{perna(p1,p2,p3,p4)}
    object{perna(p1,p2,p3,p4) scale<1,-1,1>}
    object{braco(b1,b2,b3,b4)}
    object{braco(b1,b2,b3,b4) scale<1,-1,1>}
    object{cabeca(c1,c2,c3,c4)}
  }
  
#end





#include "eixos.inc"

union {
  robo(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)

}


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