// Last edited on 2004-01-22 23:30:54 by stolfi
// Exemplo de arquivo de descricao de cena para POV-ray

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

#declare ctr = < 0.00, 0.00, 0.00 >;
#declare camDir = < 10.00, 5.00, 2.5 >;

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

// ======================================================================
// 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 nos =
  union{
#declare fonte = seed(314159);
#declare i=0;
#while (i<9)
    object{
    noBase
#if (i<3)
    translate 2*i*rand(fonte)*x
#else
#if (i<6)
    translate 2*(i-3)*rand(fonte)*x
    translate 1*z
#else
    translate 2*(i-6)*rand(fonte)*x
    translate (2)*z
#end
#end
    }
#declare i=i+1;
#end
  }

#declare canais1 =
  union{
#declare fonte = seed(314159);
#declare i=1;
#declare posA = 2*0*rand(fonte);
#while (i<10)
#if (i<=3)
#declare posB = 2*i*rand(fonte);
#declare posZ = 0;
#else
#if (i<=6)
#declare posB = 2*(i-3)*rand(fonte);
#declare posZ = 1;
#else
#declare posB = 2*(i-6)*rand(fonte);
#declare posZ = 2;
#end
#end 
  object{
    cylinder {
      <posA, 0.00, posZ>,
      <posB, 0.00, posZ>
      0.05
      texture{ tinta_B }
    }
  }
#declare i=i+1;
#end
}

#declare canais2 =
  union{
    #declare i=0;
    #while (i<6)
    #declare fonte = seed(314159);
      #if (i<3)
        #declare j=0;
        #while (j<=i)
          #declare posA=2*j*rand(fonte);
    #declare j=j+1;
  #end
  #declare j=0;
        #while (j<=4)
          #declare posB=2*(j-3)*rand(fonte);
          #declare j=j+1;
        #end
  #declare posZ=0;
      #else
  #declare j=0;
        #while (j<3)
          #declare posB=2*(i-3)*rand(fonte);
          #declare j=j+1;
        #end
        #declare j=0;
        #declare posA=2*(i-3)*rand(fonte);
        #while (j<4)
          #declare posB=2*(j-3)*rand(fonte);
          #declare j=j+1;
        #end
  #declare posZ=1;
      #end  
  object{
    cylinder {
      <posA, 0.00, posZ>,
      <posB, 0.00, posZ+1>
      0.05
      texture{ tinta_B }
    }
  }
      #declare i=i+1;
    #end
}


// 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 { nos }
  object { canais1 }
  object { canais2 }
}