// Last edited on 2004-01-23 15:05:40 by stolfi
#include "textures.inc"
#include "colors.inc"    // The include files contain
#include "stones.inc"    // pre-defined scene elements
#include "metals.inc"
#include "woods.inc"
#include "finish.inc"
#include "shapes.inc"
#include "skies.inc"
#include "chars.inc"
#include "stars.inc"

#declare ctr = < 2, 2.5, 0 >;
#declare camDir = < 2.5, 1, 7.5 >;
// #declare camDir = < 8, 1, 0 >;

camera {
  location   ctr + 1.00*camDir
  right      -1.00*x
  up         0.75*y
  sky        y
  look_at    ctr
}
 
light_source { 10 * < +20.0, +70.0, +50.0 > color rgb 1.2 * < 1.00, 1.00, 1.00 > } 
light_source { 10 * < +50.0, +30.0, -10.0 > color rgb 0.8 * < 1.00, 1.00, 1.00 > } 

// ======================================================================
// DESCRIÇÃO DA CENA 
sky_sphere { pigment {color rgb < 0.75, 0.80, 0.85 >} }

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

#declare sup_transp=
  texture{
     finish {
       ambient 0.1
       diffuse 0.1
       roughness 0.001
       reflection 0.25
       specular 1
     
     }
      
      pigment {color rgb <0.9,0.9,0.9> filter 1  } 
  }  
  //interior {ior 1.5}
  
#declare sup_metalica =
   texture {
      finish{
        ambient 0.05
  diffuse 0.05
  reflection color rgb <0.8,0.4,0.5>
  specular 0.20
  roughness 0.05
    }   
    
   }  
 
#declare sup_metalica2 =
   texture {
      finish{
        ambient 0.05
  diffuse 0.05
  reflection color rgb <0.8,0.8,0.7>
  specular 0.20
  roughness 0.05
    }   
    
   }      
   
#declare chao= 
  plane {
    <0,1,0>, -1
    //pigment {checker color rgb < 0.3, 0.3, 0.3 > color rgb <0.7,0.7,0.7> scale 2}
    //rotate y*30
    pigment {color <0.8,0.8,0.8>}
  } 
     
#declare cilext =
  union{
   cylinder {
     <0,0,0>
     <0,3,0>
     0.2
     //pigment {color rgb <0.9,0.2,0.3>}   
     //texture {sup_transp}
     //interior {ior 1.5}
   }  
   sphere {
     <0,3,0>
     0.3
      //pigment {color rgb <0.9,0.2,0.3>}   
   } 
   texture {sup_transp}
   interior {ior 1.5}
   scale 0.4
 }  
 
#declare cilint =
  union{
   cylinder {
     <0,0,0>
     <0,3,0>
     0.15
     //pigment {color rgb <0.9,0.2,0.3>}   
     //texture {sup_transp}
     //interior {ior 1.5}
   }  
   sphere {
     <0,3,0>
     0.25
      //pigment {color rgb <0.9,0.2,0.3>}   
   }
   texture {sup_transp}
   interior {ior 1.5} 
   scale 0.4
 }   
 
#declare cil=
   difference{
      object {cilext}
      object {cilint}
    
   } 
   
#declare pacote =
   sphere{
      <0,0,0>
      0.2
      scale 0.5
   }
   
#declare pacotes=
    union{
      #declare R1 = seed (34567);
      #declare desloc = seed(98820);
      #declare ran1=seed(234252);
      #declare ran2=seed(34533);
      #declare cont_int_1=0;
      #declare cont_int_2=0;
      #declare cont_ext=0;
      #declare dx=0.4;
      #declare dy=1.2;
      #declare posx_1=0;
      #declare posx_2=-1;
      #declare posy=0;
      #while (cont_ext<4)
        #declare posy=posy+dy*cont_ext; 
        #if ((cont_ext=0) | (cont_ext=2))
      #while (cont_int_1<2)
          object {pacote pigment { rgb <rand(R1),rand(R1),rand(R1)> } translate <(1-clock)*posx_1+clock*rand(desloc)*3,posy,0>}
    object {pacote pigment { rgb <rand(ran1),rand(ran1),rand(ran1)> } translate <(1-clock)*3*0.9-clock*rand(desloc)*0.3,posy,0>}
    #declare posx_1=posx_1+dx;
    #declare cont_int_1=cont_int_1+1;
    
            #end
      
  #else 
       #while (cont_int_2<2)
          object {pacote pigment { rgb <rand(R1),rand(R1),rand(R1)> } translate <(1-clock)*posx_2+clock*rand(R1)*2,posy,0>}
    object {pacote pigment { rgb <rand(ran2),rand(ran2),rand(ran2)> } translate <(1-clock)*2.9-clock*rand(ran1)*0.5,posy,0>}
    #declare posx_2=posx_2+0.6*dx;
    #declare cont_int_2=cont_int_2+1;
    
       #end
      
        #end
  #declare cont_int_1=0;
        #declare cont_int_2=0;
  #declare cont_ext=cont_ext+1;
  #declare posy=0;
  #declare posx_1=0;
        #declare posx_2=-1;
     #end   
    }   
 
#declare link=
  union{
      //object {cil translate x*2}
      #declare cont=0;
      #declare dy=3*0.4;
      #declare posy=0;
      #while (cont<4)
        object {cil translate <2,posy,0>}
  #declare posy=posy+dy;
  #declare cont=cont+1;
      #end 
 }
 
#declare rede =
    union{
      #declare cont=0;
      #declare dx=-1.2;
      #declare posx=2;
      #while (cont<4)
        object {link translate <posx,0,0>}
  #declare posx=posx+dx;
  #declare cont=cont+1;
      #end    
     
    } 
 
  object {rede}
  object {rede rotate z*90    translate <4.0,-0.4,0>}
  object {pacotes rotate z*90 translate <4.0, 1.0,0>}
  object {pacotes translate x*1}
  object {chao}