// MC930 - POV-Ray, Exercicio 7
// Last edited on 2003-05-29 00:31:01 by stolfi
// Fabio de Souza Azevedo - RA 952215
// Aula de 24/04/2003


#include "colors.inc"

background { color rgb < 0.07, 0.30, 0.30 > }

// Para ver meio em perspectiva
camera {
  location  < -5.0, 0.0, -3.5 >
  right x up y
  look_at   < 0.0,-1.0, 0.00 >
}

// Para ver de frente
// camera {
//   location  0.7*< 0.0, 0.0, -9.0 > // z = -25.0
//   right x up y
//   look_at   < 0.0, -1.0, 0.0 >
// }

light_source {
  < 25.00, 7.00, -10.00 >
  color rgb 0.7*< 1.00, 1.00, 1.00 >
} 

light_source {
  < -25.00, 12.00, -10.00 >
  color rgb 1.2*< 1.00, 1.00, 1.00 >
} 

light_source {
  < -5.00, 32.00, -10.00 >
  color rgb 0.8*< 1.00, 1.00, 1.00 >
} 

#declare plano =
  plane { <0,1,0>, 0 pigment { checker rgb < 0.75, 0.75, 1.0 >, rgb < 1.0, 0.8, 0.6 > } }


#declare olho =
  union {
    sphere {<0.0, 0.0,  0.0>, 0.2 pigment {White} }
    sphere {<0.0,-0.05,-0.2>, 0.07 pigment {Black} }
  }

#declare labio =
  torus {
    0.25, 0.15
    pigment {Red}
  }

#declare boca =
  union {
    object { labio }
    object { labio translate <0.0, -0.1, 0.0> }
  }

#declare corpo_cabeca =
  union {
    
    // "cefalotorax":
    union {
      blob {
        threshold .35
        sphere { <0.0, 0.0, 0.0>, 1.2, 1.5 pigment {Brown} }
        sphere { <0.0, 1.2, 0.0>, 0.7, 1.3 pigment {Brown} }
        finish { phong 1 }
      }
      // olhos
      object { olho translate <-0.12, 1.15, -0.3> }
      object { olho translate < 0.12, 1.15, -0.3> }

      // boca
      object { boca translate <0.0, 0.85, -0.2> }
    }
    
    // barriga:
    sphere { <0.0, -0.05,-0.2>, 0.7 pigment {Red} }
  }

#declare blob_braco =
  blob {
    threshold .35
    sphere {<-0.8, 0, 0>, 0.3, 1 pigment {Brown} }
    cylinder { <-0.8, 0, 0>, <-1.3, -1.4, 0>, 0.3, 1 }
    pigment {Brown}    
    finish { phong 1 }
  }

#declare coxa =
  blob {
    threshold .35
    sphere {<0, 0, 0>, 0.4, 1 pigment {Brown} }
    cylinder { <0, 0, 0>, <0, -1.0, 0>, 0.4, 1 }
    pigment {Brown}    
    finish { phong 1 }
  }

#declare canela =
  blob {
    threshold .35
    sphere {<0, 0, 0>, 0.3, 1 pigment {Brown} }
    cylinder { <0, 0, 0>, <0, -1.0, 0>, 0.3, 1 }
    pigment {Brown}    
    finish { phong 1 }
  }

#declare garra =
  difference {
    intersection {
      sphere { <0.0, 0.15, 0.0>, 0.35 pigment {Red} } // x= -1.45
      sphere { <0.0, -0.15, 0.0>, 0.35 pigment {Red} }
    }
    sphere { <0.0, -0.2, 0.0>, 0.35 pigment {Red} }
  }

// perna = canela + garra (pe)
#declare perna =
  union {
    object { canela }
    object { garra translate <0, -1.3, 0> }
  }

// pode = coxa + perna ("pode", de artroPODE, biPEDE, quadruPEDE...)
#declare pode =
  union {
    object { coxa }
    object { perna translate <0, -1.3, 0> }
  }

// Aqui está a cena, finalmente:

// *** SO' *** faltou:
// 1) terminar a bendita cena...
// 2) e anima'-la...

object { corpo_cabeca }
object { pode translate <-0.5, -0.75, 0.0> }
object { pode translate < 0.5, -0.75, 0.0> }
object { plano translate -3.7*y }