// Last edited on 2004-01-22 23:11:55 by stolfi
#include "colors.inc"
#include "textures.inc"

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

#declare ctr = < 0.00, 0.00, 0.00 >;
#declare camDir = < 30.00, 0.00, 50.00 >;

camera {
  location   ctr + 1.00*camDir
  right      0.80*x
  up         0.60*y
  sky        z
  look_at    ctr
}
 

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

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

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


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

background{ color < 0.80, 0.90, 1.00 > }

#declare raio = 2.000;

  
#declare tx_cristal =
  texture {
    pigment{color White filter 1}
    finish {
      specular 1
      roughness 0.001
      ambient 0.1
      diffuse 0.1
      reflection 0.25      
    }
  }     
  
#declare tx_espelho =
  texture {
    pigment { color Gray20 }
    finish {
      specular 0.20
      roughness 0.05
      ambient 0.05
      diffuse 0.05
      reflection Gray20
    }
  }     

#declare tx_gold =
  texture {
    pigment { color Gold }
    finish {
      specular 0.20
      roughness 0.55
      ambient 0.05
      diffuse 0.05
      reflection Gold
    }
  }   
   


#declare no1 =
  union{
    sphere{<0,0,2>, 2
      texture{tx_gold}
      //hollow
      interior{ior 1.3}
    }
    box{<-2,-2,0>,<2,2,2>
      texture{tx_gold}
      interior{ior 0.8}
    }
    translate<0,0,-0.5>  
  }

#declare no2 =
  torus{1, 1
    rotate<90,0,0>
    texture{tx_espelho}
  } 
  
#declare no3 =
  cylinder{<0,0,0>,<0,0,2>,2
  translate<0,0,-0.4>
  pigment{checker color Red color Green}
  }

#declare no4 =
  union{
    cylinder {<0,0,0>,<0,0,2>,2 texture{White_Wood}}
    box {<-1.7,-1.7,0><1.7,1.7,2> texture{White_Wood} }
  }    

#declare no5 =
  lathe {
    bezier_spline
    4,
    <8,-15>, <1,-5>, <10,0>, <1, 5>
    texture { tx_gold }
    scale<0.3,0.3,0.3>
    rotate<90,0,0>
    translate<0,0,4>
  }      
  
#declare liaison =
  cylinder{<2,0,0.5>,<10,0,0.5>,0.5
  texture{tx_cristal}
  interior{ior 1.3}
  }  
        
plane {
  z,
  -0.5
  //texture{tx_espelho}
  pigment { checker color < 0.40, 0.50, 0.30 > color < 0.90, 0.95, 1.00 > scale 5 }
  finish{ambient 0.7 diffuse 0.7}
} 


      
// exibiçao
#declare i=0;
#declare semente = seed(10);
#while (i < 4)
  #declare j=0;
  #while (j<4)
    #declare choix = floor(5*rand(semente));
    #switch(choix)
      #case (0)
       object{no1 translate <10*i-18, 8*j-12, 0>}
      #break
      #case (1)
       object{no2 translate <10*i-18, 8*j-12, 0>}
      #break
      #case (2)
       object{no3 translate <10*i-18, 8*j-12, 0>}
      #break
      #case (3)
       object{no4 translate <10*i-18, 8*j-12, 0>}
      #break
      #case (4)
       object{no5 translate <10*i-18, 8*j-12, 0>}
      #break
    #end    
    #if (i<3) 
      object{liaison translate<10*i-18, 8*j-12, 0>}
      #declare packet = floor(5*rand(semente));
      #declare k=0;
      #while (k<3)
        #switch (packet)
    #case (0)
            object{no1 scale<0.2,0.2,0.2> translate<10*i-15+2*k, 8*j-12, 0.5>} 
    #break
    #case (1)
            object{no2 scale<0.2,0.2,0.2> translate<10*i-15+2*k, 8*j-12, 0.5>} 
    #break
    #case (2)
            object{no3 scale<0.2,0.2,0.2> translate<10*i-15+2*k, 8*j-12, 0.5>} 
    #break
    #case (3)
            object{no4 scale<0.2,0.2,0.2> translate<10*i-15+2*k, 8*j-12, 0.5>} 
    #break
    #case (4)
            object{no5 scale<0.2,0.2,0.2> translate<10*i-15+2*k, 8*j-12, 0.5>} 
    #break
  #end
  #declare k=k+1;
      #end    
    #end
    #if (j<3)
      object{liaison rotate<0,0,90> translate<10*i-18, 8*j-12, 0>}
      #declare packet = floor(5*rand(semente));
      #declare k=0;
      #while (k<3)
        object{no1 scale<0.2,0.2,0.2> translate<10*i-18, 8*j-10+2*k, 0.5>} 
  #declare k=k+1;
      #end   
    #end
    #declare j=j+1;
  #end
  #declare i=i+1;
#end