#include "colors.inc"
#include "stones.inc" 
#include "golds.inc"
#include "textures.inc"
#include "skies.inc"

#declare cor_metal_fosco= color rgb <0.3,0.3,0.3>;  
#declare metal_fosco= 
texture{
pigment {rgb cor_metal_fosco}
finish{
ambient 0.001 diffuse 0.5
reflection cor_metal_fosco
specular 0.050 roughness 0.1 
}
}
#declare tinta_D = 
  texture {
    pigment { color rgb < 1.00, 0.00, 0.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.1 ambient 0.1 }
  }

#declare cor_vidro = color rgb <0.9,0.9,0.9>;
#declare vidro= 
texture{
 finish{
  ambient 0.1 diffuse 0.1
  reflection 0.25
  specular 1 roughness 0.01
  }
 pigment { cor_vidro filter 1}
 
 } 

camera{
location <-30,50,-47>
//right <-1.6, 0.00, 0.00>
//up <0.00,0.00,1.2>
sky <0.00,1.00,0.00>
look_at <-5,30,0>
}

light_source { 
  1* < 0.0, 65.0, -30 >               // Posição da lâmpada.
  color rgb 1.4 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
  /*photons{  
     refraction on
     reflection on
     }*/
}

light_source { 
  1* < 20.0, 85.0, 50 >               // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
  /*photons{  
     refraction on
     reflection on
     }*/
}


#declare tuboext=
cylinder{
<0,0,0>,
<0,20.5,0>,
1
texture{vidro} interior{ior 1.1}
}
#declare tuboint=
cylinder{
<0,-1,0>,
<0,21,0>,
0.9
texture{vidro} interior{ior 1.1}
}
#declare tubo=
difference{
object{tuboext}
object{tuboint}
}

#declare tuboext_orto=
object{tuboext
rotate z*90
translate<5,5,0>
}
#declare tubo_conectado=
	union{
		object{tuboext}
		object{tuboext_orto}
	}
#declare esfera=
	sphere{
		<0,0,0>,2
		texture{vidro} interior{ior 1.1}
		translate<0,5,0>
	}

#declare noh=
	difference{
		object{esfera}
		object{tubo_conectado}
		translate<0,-5,0>
	}

#declare pacote=
box{
<1,0,0.5>
<-1,1,-0.5>

}


/*while simples*/ 

#declare fonte=seed(296632);
#declare fonte2=seed(12312);
#declare fonte3=seed(12123);
#declare fonte4=seed(66654);
#declare i=0;
#declare fator=1;
#while(i<=9)
	#if(i<=5)
	object{pacote texture{pigment {color rgb <rand(fonte),rand(fonte),rand(fonte)>}} translate<0,29.5,0> translate<fator*23*rand(fonte),0,0> }
	object{pacote texture{pigment {color rgb <rand(fonte2),rand(fonte2),rand(fonte2)>}} rotate 90*z translate<-23.5,29.5,0> 
	translate<0,fator*23*rand(fonte2),0> }
	object{pacote texture{pigment {color rgb <rand(fonte4),rand(fonte4),rand(fonte4)>}} translate<0,5.5,0> translate<fator*23*rand(fonte4),0,0> }
	#end
	#if(i<8)
	object{pacote texture{pigment {color rgb <rand(fonte4),rand(fonte4),rand(fonte4)>}} translate<0,24+29.5,0> translate<i*5-23,0,0> }
	#end
	object{pacote texture{pigment {color rgb <rand(fonte3),rand(fonte3),rand(fonte3)>}} rotate 90*z translate<0.5,29.5,0> 
	translate<0,i*5-23,0> }
	object{pacote texture{pigment {color rgb <rand(fonte3),rand(fonte3),rand(fonte3)>}} rotate 90*z translate<23.5,29.5,0> 
	translate<0,i*5-23,0> }
	#declare i=i+1;
	#declare fator=fator*-1;
#end 

/*while's aninhados, 2 malhas*/
	
#declare i=0;
#declare maxim=3;
#while(i<maxim)
	#declare j=0;
	#while(j<maxim)
		object{noh translate<24*(j-1),24*(1-i)+30,0>}
		#if(j!=maxim-1) 
			object{tubo rotate 90*z translate<24*(j)-2,24*(1-i)+30,0>} 
		#end
		#if(i!=maxim-1) 
			object{tubo translate<24*(j-1),24*(i)+30-2-20,0>} 
		#end
		#declare j=j+1;
	#end
	#declare i=i+1;
#end
	
	
#declare noh1=
	object{noh
		translate<0,12,0>
		rotate 90*y
	}
 
light_source { 
  1* < 0.0, 6.0, 0.0 >               // Posição da lâmpada.
  color rgb 5 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
  }
sky_sphere{S_Cloud1/*pigment{ color rgb <0.75,0.76,0.82>}*/}
plane{y,0
  texture{T_Stone1
    //pigment{ /*color rgb<0,1,0>*/checker color White, color Black scale 2 rotate y*30
   // }
  } 
}