background{ color rgb < 0.75, 0.80, 0.85 > }
 
#include "eixos.inc"

#declare tx =
  texture{
    pigment{ color rgb < 0.5, 0, 0 > }
    finish{ diffuse 0.9 ambient 0.1 }
  }

#macro tronco()
  union{ 
    cylinder{
      < 0, 0, 0 >,
      < 0, 0, 5 >,
      2
      texture{ tx }
    }
  }
#end

#macro membro_ponta()
  #local mp =
    cylinder{
      < 0, 0, 0 >,
      < 0, 0.7, 0 >,
      0.7
      texture{ tx }
    }

  union {
    object { mp }
  }
#end

#macro sub_membro_pequeno(b9)
  #local smp =
    cylinder{
      < 0, 0, 0 >,
      < 0, 0, 3 >,
      0.3
      texture{ tx }
    }

  #local mp = membro_ponta();

  union {
    object { smp }
    object { mp rotate b9*x translate <0,-0.3,3>}
  }
#end

#macro membro(b8, b9)
  #local sub_membro_grande =
    cylinder{
      < 0, 0, 0 >,
      < 0, 0, 4 >,
      0.3
      texture{ tx }
    }

  #local smp = sub_membro_pequeno(b9);

  union {
    object { sub_membro_grande }
    object { smp rotate b8*x translate <0,0,4>}
  }
#end

#macro cabeca()
  #local cab =
    sphere{
      < 0, 0, 0>,
      1.5
      texture{ tx }
    }

  union {
    object { cab }
  }
#end

#macro sub_pescoco(b1)
  #local pescoco =
    cylinder{
      < 0, 0, 0 >,
      < 0, 0, 1.5 >,
      0.6
      texture{ tx }
    }

  #local cab = cabeca();

  union {
    object { pescoco }
    object { cab rotate b1*x translate <0,0,3>}
  }
#end

#macro cab_pes(b1, b2)
  #local pescoco =
    cylinder{
      < 0, 0, 0 >,
      < 0, 0, 2 >,
      0.6
      texture{ tx }
    }

  #local sp = sub_pescoco(b1);

  union {
    object { pescoco }
    object { sp rotate b2*x translate <0,0,2>}
  }
#end

#macro bicho_preguica(b1, b2, b3, b4, a4, b5, b6, b7, a7, b8, b9, b10, b11, b12, b13, a13, b14, b15)
  #local perna_1 = membro(b8, b9)
  #local perna_2 = membro(b11, b12)

  #local braco_1 = membro(b5, b6)
  #local braco_2 = membro(b14, b15)

  #local pescoco_e_cabeca = cab_pes(b1, b2)

  union{
    object { tronco() }
    object { perna_1 rotate b7*y rotate a7*x translate <0,2,0.5>}
    object { perna_2 rotate b10*y rotate a10*x scale <-1, -1, 1> translate <0,-2,0.5> }

    object { braco_1 rotate b4*y rotate a4*x translate <0,2,4.5>}
    object { braco_2 rotate b13*y rotate a13*x scale <-1, -1, 1> translate <0,-2,4.5>}

    object { pescoco_e_cabeca rotate b3*y translate <0,0,5>}    
  }
#end

#declare b1 = -90;
#declare b2 = -25;
#declare b3 = 15;
#declare b4 = 0;
#declare a4 = -90;
#declare b5 = 45;
#declare b6 = 45;
#declare b7 = 10;
#declare a7 = -100;
#declare b8 = 25;
#declare b9 = 90;
#declare b10 = 0;
#declare a10 = -125;
#declare b11 = -25;
#declare b12 = 45;
#declare b13 = 0;
#declare a13 = -90;
#declare b14 = -45;
#declare b15 = 45;

bicho_preguica(b1, b2, b3, b4, a4, b5, b6, b7, a7, b8, b9, b10, b11, b12, b13, a13, b14, b15)

#include "camlight.inc"
#declare centro_cena = < 0.00, 1.00, 1.00 >;
#declare raio_cena = 20.0;
#declare dir_camera = < 35.00, 20.00, 10.00 >;
#declare dist_camera = 50*raio_cena;
#declare intens_luz = 1.20;
camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)