// Last edited on 2004-01-23 12:15:21 by stolfi
// Exemplo de arquivo de descricao de cena para POV-ray

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

#include "colors.inc"
#include "skies.inc"

#declare espaco = 2;
#declare limx = 20;
#declare limy = 20;

#declare ctr = espaco*< (limx-1)/2, (limy-1)/2, 0.00 >;
#declare camDir = < -20.00, -20.00, 3.00 >;

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

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

light_source { 10 * < -50.0, -20.0, +50.0 > color rgb 1.2 * < 1.00, 1.00, 1.00 > }
light_source { 10 * < +50.0, -10.0, +40.0 > color rgb 0.8 * < 1.00, 1.00, 1.00 > } 

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

#declare cor_cristal = <0.80, 0.80, 0.90>;
#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}
}

background{ color rgb < 1, 1, 1 > }

plane { <0, 0, 1>, -0.1
   pigment {rgb <0.3,0.6,1>}
}

sky_sphere {S_Cloud3}

#declare Xinicial = 0;
#declare Yinicial = 0;

#declare i = 0;

#declare gerador = seed(12382);

//Pontos

#while (i < limx)
   #declare j = 0;
   #while (j < limy)
      sphere {
         <Xinicial+i*espaco , Yinicial+j*espaco, 0>,
   0.1
   pigment { Yellow }
      }

  #if (i<limx-1)
  cylinder{
     <0,0,0>,
     <0,0,2>,
     0.1
     texture {tx_cristal}
     rotate 90*y
     translate<Xinicial+i*espaco,Yinicial+j*espaco,0>
  }
  #end
  
  #if (j<limy-1)
  cylinder{
     <0,0,0>,
     <0,0,2>,
     0.1
     texture {tx_cristal}
     rotate -90*x
     translate<Xinicial+i*espaco,Yinicial+j*espaco,0>
  }
  #end  

      #declare rand1 = rand(gerador);
      #declare R = rand(gerador);           // Tom do vermelho
      #declare G = rand(gerador);           // Tom do verde
      #declare B = rand(gerador);           // Tom do azul 
      
      #declare desx = (1-clock)*<Xinicial+i*espaco,Yinicial+j*espaco,0> + clock*<Xinicial+(i+1)*espaco,Yinicial+j*espaco,0>;
      #declare desy = (1-clock)*<Xinicial+i*espaco,Yinicial+j*espaco,0> + clock*<Xinicial+i*espaco,Yinicial+(j+1)*espaco,0>;

      #if (i < limx-1 | j < limy-1)
      box{
   <-0.05,-0.05,-0.05>,
   <0.05, 0.05, 0.05>
   pigment {color rgb <R,G,B>}
   #if (rand1 > 0.5 & i < limx-1) //Pacote pula na dir. X
      translate desx
   #else
      #if (j < limy-1)
      translate desy
      #end
   #end
         }
      #end
      #declare j = j+1;
   #end
   #declare i = i+1;
#end