// Aluno: Roberto Barboza Braz     RA 035711

// ======================================================================
// C�ERA 


camera {
  location  <  15.00, 35.00, 10.00 >  // Posi�o do observador. 6,5,6 original
  right     0.8*x                // Largura RELATIVA da imagem.
  up        -0.6*y                 // Altura RELATIVA da imagem.      
  sky       z                      // Qual dire�o �"para cima"?
  look_at   <  15.00, 15.00, 0.00 >  // Para onde a c�era est�apontando.
} 

/*
camera {
  location  <  6.00, 0.00, 6.00 >  // Posi�o do observador.
 // right     -0.75*x                // Largura RELATIVA da imagem.
 // up        1.00*y                 // Altura RELATIVA da imagem.      
  sky       z                      // Qual dire�o �"para cima"?
  look_at   <  0.00, 0.00, 0.00 >  // Para onde a c�era est�apontando.
} 

*/
// Nota: os par�etros "right" e "up" devem ter a mesma propor�o
// que os par�etros ${WIDTH} e ${HEIGHT} no Makefile.

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

light_source {
  10 * < +50.0, +30.0, +50.0 >              // Posi�o da l�pada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  10 * < +50.0, -10.0, +10.0 >             // Posi�o da l�pada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

// ======================================================================
// DESCRI�O DA CENA 

background{ color rgb < 0.55, 0.60, 0.85 > }

#declare raio = 2.000;
#declare roleta = seed(47535);

#declare tinta_vermelho = 
  texture {
    pigment { color rgb < 1.00, 0.15, 0.00 >
 }
    finish { reflection 0.35 phong 1 }
  }

#declare tinta_azul = 
  texture {
    pigment { color rgb < 0.00, 0.15, 1.00 > 
}
    finish { reflection 0.35 phong 1  }
  }   
  
#declare tinta_preto = 
  texture {
    pigment { color rgb < 0.00, 0.00, 0.00 > }
    //finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare peao =
   union {
   sphere { <0,0,1.5>,0.2 }
   cone { <0,0,1>,0.4,<0,0,1.5>,0 }
   }

// Aqui est�a cena, finalmente:

#declare i=0;
#declare j=0;
#while(j<30)
 #while(i<30)
  box { <i,j,0>,
        <i+1,j+1,1>
#if(mod(j,2)=0)
  #if(mod(i,2)=0)
   pigment { color rgb <1.00,1.00,1.00> }
   #else
   pigment { color rgb <0.00,0.00,0.00> }
   #end
  #else
  #if(mod(i,2)=0)
   pigment { color rgb <0.00,0.00,0.00> }
   #else
   pigment { color rgb <1.00,1.00,1.00> }
   #end	
#end
}
#declare i=i+1;
 #end
  #declare j=j+1;
  #declare i=0;
#end

#declare tor = 0; 
#while (tor < 15) 
#declare tor_x = (int (rand(roleta)*30)) + 0.5; 
#declare tor_y = (int (rand(roleta)*30)) + 0.5; 
union {
box {
<tor_x+0.3,tor_y+0.3,1.2>,<tor_x-0.3,tor_y-0.3,1> 
texture {tinta_vermelho} }
cylinder { 
<tor_x, tor_y, 1.2>, 
<tor_x, tor_y, 2>, 0.25 
texture {tinta_azul} 
} 
box {
<tor_x+0.3,tor_y+0.3,2>,<tor_x-0.3,tor_y-0.3,2.2> 
texture {tinta_vermelho }
}
}
#declare tor = tor + 1; 
#end

#declare tor = 0; 
#while (tor < 15) 
#declare tor_x = (int (rand(roleta)*30)) + 0.5; 
#declare tor_y = (int (rand(roleta)*30)) + 0.5; 
union {
box {
<tor_x+0.3,tor_y+0.3,1.2>,<tor_x-0.3,tor_y-0.3,1> 
texture {tinta_azul} }
cylinder { 
<tor_x, tor_y, 1.2>, 
<tor_x, tor_y, 2>, 0.25 
texture {tinta_vermelho} 
} 
box {
<tor_x+0.3,tor_y+0.3,2>,<tor_x-0.3,tor_y-0.3,2.2> 
texture {tinta_azul }
}
}
#declare tor = tor + 1; 
#end

#declare pea = 0; 
#while (pea < 45) 
#declare pea_x = (int (rand(roleta)*30)) + 0.5; 
#declare pea_y = (int (rand(roleta)*30)) + 0.5; 
union {
sphere {
<pea_x,pea_y,2.25>,0.25
texture {tinta_azul} }
cone { 
<pea_x, pea_y, 1>, 0.3, 
<pea_x, pea_y, 2>, 0 
texture {tinta_vermelho} 
} 
}
#declare pea = pea + 1; 
#end

#declare pea = 0; 
#while (pea < 45) 
#declare pea_x = (int (rand(roleta)*30)) + 0.5; 
#declare pea_y = (int (rand(roleta)*30)) + 0.5; 
union {
sphere {
<pea_x,pea_y,2.25>,0.25
texture {tinta_vermelho} }
cone { 
<pea_x, pea_y, 1>, 0.3, 
<pea_x, pea_y, 2>, 0 
texture {tinta_azul} 
} 
}
#declare pea = pea + 1; 
#end

#declare rei_x = (int (rand(roleta)*30)) + 0.5; 
#declare rei_y = (int (rand(roleta)*30)) + 0.5; 
union {
box {
<rei_x+0.2,rei_y+0.2,2.7>,<rei_x-0.2,rei_y-0.2,2.5> 
texture {tinta_azul} }
sphere {
<rei_x,rei_y,2.95>,0.25
texture {tinta_vermelho} }
cone { 
<rei_x, rei_y, 1>, 0.3, 
<rei_x, rei_y, 2.5>, 0 
texture {tinta_preto} 
} 
}

#declare rei_x = (int (rand(roleta)*30)) + 0.5; 
#declare rei_y = (int (rand(roleta)*30)) + 0.5; 
union {
box {
<rei_x+0.2,rei_y+0.2,2.7>,<rei_x-0.2,rei_y-0.2,2.5> 
texture {tinta_vermelho} }
sphere {
<rei_x,rei_y,2.95>,0.25
texture {tinta_azul} }
cone { 
<rei_x, rei_y, 1>, 0.3, 
<rei_x, rei_y, 2.5>, 0 
pigment { color rgb <1.00,1.00,1.00> }
} 
}