// Exemplo de arquivo de descricao de cena para POV-ray
// Last edited on 2003-07-31 12:50:37 by stolfi

// ======================================================================
// CÂMERA 

camera {
  location  <  6.00, 8.00, 2.5 >  // Posição do observador.
  right     < 0.60, 0.00, 0.00 >                 // Largura RELATIVA da imagem.
  up        <  0.00, 0.00, 0.80 >                 // Altura RELATIVA da imagem.      
  sky       <  0.00, 0.00, 1.00 >                 // Qual direção é "para cima"?
  look_at   <  3.00, 0.00, 0.00 >  // Para onde a câmera está apontando.
} 
// Nota: os parâmetros "right" e "up" devem ter a mesma proporção
// que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile.

// ======================================================================
// 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 cor da luz.
} 

light_source {
  10 * < +50.0, -10.0, +10.0 >             // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e cor da luz.
} 

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

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

#declare raio = 2.000;

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

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

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

#declare cor_cristal = < 0.00, 0.50, 1.00 >;

#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_espelho = <0.30, 0.30, 0.30 >;

#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 dentro = interior { ior 1.5 }

#declare piso = 
  plane { <0, 0, 1>, 0
    texture { tx_espelho }
    interior { ior 1.5 }    
  }

#declare predio1 =
  cylinder {
    <2.00, 1.00, 0.00>,
    <2.00, 1.00, 1.00>
    2.00
    texture { tx_cristal }
  }

#declare predio2 =
  cylinder {
    <0.00, -0.50, 0.00>,
    <0.00, -0.50, 2.00>
    0.50
    texture { tinta_B }
  }

#declare predio3 =
  cylinder {
    <1.00, -1.50, 0.00>,
    <1.00, -1.50, 3.00>
    1.00
    texture { tinta_A }
  }


#declare topo =
  torus {
    1.0, 0.5              // major and minor radius
    rotate -90*x      // so we can see it from the top
    pigment { rgb <0.00, 1.00, 0.00> }
    translate <0.70, -1.80, 3.50>
  }

#declare eixoX =
  cylinder {
	<0.00, 0.00, 0.00>,
	<10.00, 0.00, 0.00>
	0.03
	texture { 
	  pigment { color rgb <1.00, 0.00, 0.00> } 
	}
  }

#declare eixoY =
  cylinder {
	<0.00, 0.00, 0.00>,
	<0.00, 10.00, 0.00>
	0.03
	texture { 
	  pigment { color rgb <0.00, 1.00, 0.00> }
	}
  }

#declare eixoZ =
  cylinder {
	<0.00, 0.00, 0.00>,
	<0.00, 0.00, 10.00>
	0.03
	texture {
	  pigment { color rgb <0.00, 0.00, 1.00> }
	}	
  }

#declare noBase =
  sphere
  {
	<0.00, 0.00, 0.00>, 0.10
	texture { tinta_A }
  }

#declare i=0;
#declare fonte = seed(314159);
#declare posX = array[9]{rand(fonte), rand(fonte), rand(fonte), rand(fonte), rand(fonte), rand(fonte), rand(fonte), rand(fonte), rand(fonte)};
#declare posZ = array[9]{0, 0, 0, 1, 1, 1, 2, 2, 2};

#declare nos =
  union{
#declare fonte = seed(314159);
#declare i=0;
#while (i<9)
  	object{
		noBase
		translate 5*posX[i]*x
		translate posZ[i]*z
  	}
#declare i=i+1;
#end
  }

#declare canais1 =
  union{
#declare i=0;
	#while (i<6)
	object{
		cylinder {
			<5*posX[i], 0.00, posZ[i]>,
			<5*posX[i+3], 0.00, posZ[i+3]>
			0.02
			texture{ tinta_B }
		}
	}
		#declare i=i+1;
		#end
}

#declare canais2 =
  union{
#declare i=0;
	#while (i<8)
		#if (i=2)
			#declare i=3;
		#else
			#if (i=5)
				#declare i=6;
			#end
		#end
	object{
		cylinder {
			<5*posX[i], 0.00, posZ[i]>,
			<5*posX[i+1], 0.00, posZ[i+1]>
			0.02
			texture{ tinta_B }
		}
	}
      		#declare i=i+1;
    		#end
}

#declare pacote1=
  sphere
  {

//	<5*(1/10)*(7*posX[0]+3*posX[3]), 0.00, (1/10)*(7*posZ[0]+3*posZ[3])>, 0.20
	<5*posX[3], 0.00, posZ[3]>, 0.10
	texture { tinta_C }
	translate <(clock*posX[0]+(1-clock)*posX[3])*clock, 0.00, (clock*posZ[0]+(1-clock)*posZ[0])*clock>
  }	


// Aqui está a cena, finalmente:
union {
//  object { piso }
//  object { predio1 }
//  object { predio2 }
//  object { predio3 }
//  object { topo }
  object { eixoX }
  object { eixoY }
  object { eixoZ }
//  object { noBase }
  object { pacote1 }
  object { nos }
  object { canais1 }
  object { canais2 }
}