// Last edited on 2003-12-07 14:55:49 by stolfi
// Exemplo de arquivo de descricao de cena para POV-ray

#include "colors.inc"


// ======================================================================

#declare ctr = < 7.00, -3.00, 0.00 >;
#declare camDir = < 45.00, 35.00, 35.00 >;

camera {
  location   ctr + 0.50*camDir
  right      -1.00*x
  up         0.75*y
  sky        y
  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 {
  10 * < +50.0, 20.0, +10.0 >             // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

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

background{ color rgb < 0.75, 0.80, 0.85 > }

#declare raio = 2.000;

#declare cor_cristal = <1.00, 0.0, 0.0>;
#declare tx_cristal=
 texture{
   finish{
      ambient 0.1 diffuse 0.1 reflection 0.25  specular 1 roughness 0.001
   }
   pigment { color cor_cristal filter 1}
 }
 
 #declare cor_cristal2 = <0.10, 0.90, 1.00>;
#declare tx_cristal2=
 texture{
   finish{
      ambient 0.1 diffuse 0.1 reflection 0.25  specular 1 roughness 0.001
   }
   pigment { color cor_cristal2 filter 1}
 }
 
 #declare cor_espelho = <1.00, 0.80, 0.10>;
 #declare tx_espelho =
  texture{
   pigment{ rgb cor_espelho }
   finish{
    ambient 0.05 diffuse 0.05 reflection cor_espelho  specular 0.20 roughness 0.05
   }
  }
  
  #declare cor_espelho2 = <0.10, 0.80, 1.00>;
 #declare tx_espelho2 =
  texture{
   pigment{ rgb cor_espelho2 }
   finish{
    ambient 0.05 diffuse 0.05 reflection cor_espelho2  specular 0.20 roughness 0.05
   }
  }
 

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

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

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

#declare verde = 
  texture {
    pigment { color rgb < 0.00, 1.00, 0.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }
    
#declare s_pos1 = seed(2355);
#declare s_pos2 = seed(34235);
#declare s_pos3 = seed(5464554);
#declare s_pos1b = seed(67867);
#declare s_pos2b = seed(2135);
#declare s_pos3b = seed(21435);



sphere {
    < -6, 0.00, 0>, 3.0 
    texture { vermelho }
    scale <1,0.6,0.5>
  }

  difference{
  sphere {
    < 6*3, 0.00, 0>, 3.0 
    texture { vermelho }
    scale <1,0.6,0.5>
  }
  sphere {
    < 21, 0.00, 0>, 3.0 
    texture { vermelho }
    scale <1,1,0.3>
  }
  }

#declare i = 0;
  
#while (i<3)
#declare j = 0; 
 #declare h = 1;
#declare posx = i*6;
 sphere {
    < posx, 0.00, 0>, 3.0 
    texture { verde }
    scale <1,0.6,0.5>
  }
 
 #while (j<4) 

  #declare pos1 = rand(s_pos1);
  #declare pos2 = rand(s_pos2);
  #declare pos3 = rand(s_pos3);
  #declare pos4 = rand(s_pos1b);
  #declare pos1b = rand(s_pos2b);
  #declare pos3b = rand(s_pos3b);
 

  #declare bola =
    sphere {
      <0,0,0>
      0.5
      texture {vermelho}
    }
  
 
  #declare parte4 = 
  union{
    cylinder {
      < 0.00, 0.00, 0.00 >,
      < 2.00, 0.00, 0.00 >,
      0.5
      texture { tx_espelho }
    }
  object { bola }
  } 
 
  
#declare ang3 = -70-30*pos3; 
#declare parte3 = 
union{
  cylinder {
    < 0.00, 0.00,0.00 >,
    < 2.50, 0.00, 0.00 >,
    0.5
    texture { tx_espelho2 }
   }
  object { parte4
    rotate ang3*y
    translate <2.5,0,0>
  }
  object { bola 
    translate <2.5,0,0>
  }
}


#declare ang2 = 10+30*pos2;
#declare parte2 =
union{ 
  cylinder {
    < 0.00, 0.00, 0.00 >,
    < 3.00, 0.00, 0.00 >,
    0.5
    texture { tx_espelho }
  }
  object { parte3
    rotate ang2*y
    translate <3,0,0>
  } 
  object { bola 
    translate <3,0,0>
  }
}  
 

#declare ang1 = 80+20*pos1;  
#declare parte1 = 
union{
  cylinder {
    < 0.00, 0.00, 0.00 >,
    < 3.00, 0.00, 0.00 >,
    0.5
    texture { tx_espelho2 }
  }
  object {parte2
    rotate  90*y
    translate <3,0,0>
  }
  object { bola 
    translate <3,0,0>
  }
}

#if (j=0)
  #declare p = -1;
#end
#if (j=1)
  #declare p = -1;
#end
#if (j=2)
  #declare p = 1;
#end
#if (j=3)
  #declare p = 1;
#end

#declare ang1 = -70-30*pos1; 
#declare ang1b = 10+30*pos1b;
object{ parte1
    rotate ang1*x
    rotate h*90*y
    translate <p+posx,0,-2.5*h>
  }
#declare h = -h;
#declare j = j+1;

#end
#declare i = i+1;
#end
  
  



// Aqui está a cena, finalmente: