// LAB 03 - O Templo da Computação

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

camera {
  location  <  30.00, -30.00, 16.00 >  // Posição do observador.
  right     -1.00*x                // Largura RELATIVA da imagem.
  up        0.75*y                 // Altura RELATIVA da imagem.      
  sky       z                      // Qual direção é "para cima"?
  look_at   <  10.00, 10.00, 8.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 corda 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 corda luz.
} 

light_source {
  10 *< 10.0, 30.0, 5.00 >             // Posição da lâmpada.
  color rgb 5 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
}

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

background{ color rgb < 0.8, 0.85, 0.9 > }

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

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

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

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


//#declare sala =
//  box {
//    < 0.00, 0.00, 0.00 >,
//    < 3.00, 3.00, 3.00 >
//    texture { tinta_Azul }
//    }

//#declare buraco_sala =
//  box {
//    < 0.50, 0.50, 0.50 >,
//    < 2.50, 2.50, 2.50 >
//    texture { tinta_AzulClaro }
//    }

//#declare janela =
//  box {
//    < 0.75, 0.75, 0.50 >,
//    < 2.25, 2.25, 3.50 >
//    texture { tinta_AzulClaro }
//   }


//difference {
//  difference {
//    object { sala }
//    object { buraco_sala }
//  }
//  object { janela }
//}

#declare j=0;
#declare g = seed(123456);
difference {
union {
  #while ( j<4 )
  difference {
    difference {
    //andar
      box {
        //< 0.00, 0.00, 0.00 >,
        //< 19.00, 19.00, 4.00 >
	< 0.00, 0.00, 4*j >,
	< 19.00, 19.00, 4*j+4 >
	#if (j=1 | j=3)
          texture { tinta_Azul }
	#else
	  texture { tinta_Verde }
	#end
      }
      //buraco do andar
      box {
        //< 0.50, 0.50, 0.50 >, 
        //< 18.50, 18.50, 3.50 >
	< 0.50, 0.50, 4*j+0.50 >, 
        < 18.50, 18.50, 4*j+3.50 >
	#if (j=1 | j=3)
          texture { tinta_Azul }
	#else
	  texture { tinta_Verde }
	#end
      }
    }
    #declare i=0;
    //#declare g = seed(123456);
    #while ( i<6 )
    //janelas no x
      //#declare g = seed(123456 * (i+1) );
      #if ( rand(g) < 0.5 )
      box {
        //< 1+3*i, -0.50, 1.00 >,
        //< 3+3*i, 19.50, 3.00 >
        < 1+3*i, -0.50, 4*j+1.00 >,
        < 3+3*i, 19.50, 4*j+3.00 >
        #if (j=1 | j=3)
          texture { tinta_AzulClaro }
	#else
	  texture { tinta_VerdeClaro }
	#end
      }
      #else
      //janela cilindro
      cylinder {
        < 3*i+2, -0.5, 4*j+2.00 >,
	<3*i+2, 19.5, 4*j+2.00 >,
	1
	#if (j=1 | j=3)
          texture { tinta_AzulClaro }
	#else
	  texture { tinta_VerdeClaro }
	#end
      }
      #end
      #declare i=i+1;
    #end
    #declare i=0;
    #while ( i<6 )
    //janelas no y
      //#declare g = seed(123456 * (i+1) );
      #if ( rand(g) < 0.5 )
      box {
        //< 1+3*i, -0.50, 1.00 >,
        //< 3+3*i, 19.50, 3.00 >
        < -0.50, 1+3*i, 4*j+1.00 >,
        < 19.50, 3+3*i, 4*j+3.00 >
        #if (j=1 | j=3)
          texture { tinta_AzulClaro }
	#else
	  texture { tinta_VerdeClaro }
	#end
      }
      #else
      cylinder {
        < -0.5, 3*i+2, 4*j+2.00 >,
	<19.50, 3*i+2, 4*j+2.00 >,
	1
	#if (j=1 | j=3)
          texture { tinta_AzulClaro }
	#else
	  texture { tinta_VerdeClaro }
	#end
      }
      #end
      #declare i=i+1;
    #end
  }
  #declare j=j+1;
  #end

}
box {
  < 7.00, -0.1, 3.00 > 
  < 12.00, 0.7, 0.00 >
}
}


cylinder {
  <3.00, 3.00, 16.00 >,
  <3.00, 3.00, 18.00>,
  1
  texture { tinta_Vermelha }
}
cylinder {
  <16.00, 3.00, 16.00 >,
  <16.00, 3.00, 18.00>,
  1
  texture { tinta_Vermelha }
}
cylinder {
  <3.00, 16.00, 16.00 >,
  <3.00, 16.00, 18.00>,
  1
  texture { tinta_Vermelha }
}
cylinder {
  <16.00, 16.00, 16.00 >,
  <16.00, 16.00, 18.00>,
  1
  texture { tinta_Vermelha }
}
box {
  < 0, 0, 18 >
  < 19, 19, 19 >
  texture { tinta_Vermelha }
}

plane { z, 0
  texture {
    pigment { granite }
    finish { ambient 0.1 diffuse 0.9 }
    scale 3.0
    }
}