// Last edited on 2003-12-07 20:38:05 by stolfi

// LAB-08 -- 28/Out/2003

#declare ctr = < 0.00, 0.00, 0.00 >;
#declare camDir = < 16.00, 15.00, 6.0 >;

camera {
  location   ctr + 0.65*camDir
  right      -1.00*x
  up         0.75*y
  sky        z
  look_at    ctr
}

// ======================================================================
// FONTES DE LUZ
// ======================================================================

light_source {
  10 * < +50.0, +30.0, +50.0 >             // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >     // Intensidade e corda luz.
} 

light_source {
  100 * < -5.0, +3.0, +1.5 >             // Posição da lâmpada.
  color rgb 0.7 * < 1.00, 1.00, 1.00 >     // Intensidade e corda luz.
} 


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

background{ color rgb < 0.50, 0.50, 1.0 > }

#declare raio = 2.000;
#include "colors.inc"
// #include "dados.inc"

// ======================================================================
// CORES USADAS
// ======================================================================
 
#declare bgcolor =
  texture {
    pigment { color rgb < 0.75, 0.80, 0.85 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare branco = 
  texture {
    pigment { color rgb < 1.00, 1.00, 1.00 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare azul = 
  texture {
    pigment { color rgb < 0.00, 0.00, 1.00 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare preto = 
  texture {
    pigment { color rgb < 0.00, 0.00, 0.00 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare cinza = 
  texture {
    pigment { color rgb < 0.40, 0.40, 0.40 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare laranja = 
  texture {
    pigment { color rgb < 1.00, 0.70, 0.00 > }
    finish { diffuse 0.9 specular 0.5 roughness 0.005 ambient 0.1 }
  }
  

// ======================================================================
// Cristais e Espelhos
// ======================================================================

#declare cor_cristal =  < 0.10, 0.10, 1.0 >;
#declare tx_cristal =
  texture {
    finish { ambient 0.1 diffuse 0.1 reflection 0.25 specular 1.0 roughness 0.001 }
    pigment { color cor_cristal filter 1 }
  }

#declare cor_cristal2 =  < 1.00, 0.80, 0.20 >;
#declare tx_cristal2 =
  texture {
    finish { ambient 0.1 diffuse 0.1 reflection 0.25 specular 1.0 roughness 0.001 }
    pigment { color cor_cristal2 filter 1 }
  }

#declare cor_espelho = < 0.5, 0.5, 0.5 >;
#declare tx_espelho = 
  texture {
    pigment { rgb cor_espelho }
    finish { ambient 0.05 diffuse 0.05 reflection cor_espelho specular 0.20 roughness 0.05  }
  }



// ======================================================================
// FORMAS USADAS
// ======================================================================

#declare S1 = seed (7);
#declare S2 = seed (77);

#declare chao = 
  plane { <0, 0, 1>, -0.01
         texture {laranja}
  }

#declare chao2 = 
  plane { <0, 0, 1>, -0.54
         texture {tx_cristal}
  }




// ======================================================================
// LAB08 - Itens Especificos
// ======================================================================

#declare i=-10;



// Pontos de intereseccao (e tamanho) e uniao entre partes
#declare L4=1;
#declare L3=0.5;
#declare L2=1;
#declare L1=1.5;
#declare L0=1;

#declare CORPOX = 2.5;
#declare CORPOY = 5.5;

#declare box_teste = 
  box {<1,1,0>, <1,2,5>
       texture {azul}
      }


#declare corpo =
  box {<CORPOX,-CORPOY,0>, <-CORPOX,+CORPOY,L0>
       texture {cinza}
      } 




// ======================================================================
// CENA!
// ======================================================================

object {chao}

object {corpo}

#declare junta = 
  sphere {<0,0,0>, 0.2
          texture {laranja}
         }


#declare parte4 =
  cylinder {<0,0,0>, <0,0,L4>, 0.1
      texture {azul} 
           }


#declare k=4;      // Numero de sequencias de 2 pernas
#declare aux=1;
#declare pata = (CORPOY*2)/(k+1);

#while (aux <= k)


#declare parte3 =
  union {
  cylinder {<0,0,0>, <0,L3,0>, 0.1
      texture {azul}
           }
  object {parte4
    rotate (rand(S1)*-45)*x
    rotate (rand(S2)*30)*y
    translate <0,L3,0>
         }
  object {junta
    translate <0,L3,0>
         }
  }


#declare parte2 =
  union {
  cylinder {<0,0,0>, <L2,0,0>, 0.1
      texture {azul}
           }
  object {parte3
    rotate -(rand(S1)*30)*x
    rotate (rand(S2)*-90)*y
    translate <L2,0,0>
         }
  object {junta
    translate <L2,0,0>
         }
  }

#declare parte1 =
  union {
  cylinder {<0,0,0>, <0,0,L1>, 0.1
      texture {azul}
           }
  object {parte2
    rotate -(rand(S1)*45)*x
    translate <0,0,L1>
         }
  object {junta
    translate <0,0,L1>
         }
  }

#declare perna =
  union {object {parte1
    rotate (rand(S2)*30)*x
    translate <0,0,L0>
         }
  object {junta
    translate <0,0,L0>
         }
  }


  
  object {perna translate <CORPOX-0.5, -CORPOY+(pata*aux), 0>} 
  object {perna scale <-1, 1, 1> translate <-CORPOX+0.5, -CORPOY+(pata*aux), 0>}

  
  #declare aux = aux +1;
  
#end