// MC930 A, S2 2003
// Last edited on 2003-10-21 23:19:30 by stolfi
// Autor: Leonel Aguilar Gayard
// RA 009103
// Data 04/09/2003
// Tema: Palacio de Cristal

global_settings { max_trace_level 10 }

#include "colors.inc"

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

#declare ctr = < 1, 0, 2>;
#declare camdir = < 10 , 20, 10 >;

camera {
  location  ctr + 0.75*camdir  // Posição do observador.
  right     -1.0*x                 // Largura RELATIVA da imagem.
  up        0.75*y                 // Altura RELATIVA da imagem.      
  sky       z                      // Qual direção é "para cima"?
  look_at   ctr  // 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 {
  100 * < +30.0, +5.0, +50.0 >                // Posição da lâmpada.
  color rgb 1.2 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
} 

light_source {
  100 * < +10.0, +30.0, +40.0 >                // Posição da lâmpada.
  color rgb 0.6 * < 1.00, 1.00, 1.00 >   // Intensidade e corda 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.10, 0.80, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }
#declare tinta_B = 
  texture {
    pigment { color rgb < 0.10, 0.80, 1.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_AZUL = 
  texture {
    pigment { color rgb < 0.00, 0.0, 1.00 > }
  }

#declare tinta_VERDE = 
  texture {
    pigment { color rgb < 0.00, 1.0, 0.00 > }
  }

#declare tinta_VERMELHA = 
  texture {
    pigment { color rgb < 1.00, 0.0, 0.00 > }
  }

#declare tinta_AMARELA = 
  texture {
    pigment { color rgb <1, 1, 0> }
  }
  
// ---------------------------------------------------------------------------------
// AQUI TERMINA O ARQUIVO DO PROFESSOR E COMECA O MEU EXERCICIO

  plane { <0, 0, 1>, 0
    pigment {
      checker color rgb <0.95,1.00,0.95>, color rgb <0.55, 0.60, 0.65 >
      scale 2
    }
  }

  #declare cor_cristal_azul = <0.3, 0.4, 1>;
  #declare tx_cristal_azul = 
    texture {
      finish {
        ambient 0.1 diffuse 0.1
        reflection 0.25
        specular 1 roughness 0.001
      }
      pigment { color cor_cristal_azul filter 1 }
    }
  #declare cor_cristal_verde = <0.2,0.9,0.2>;
  #declare tx_cristal_verde = 
    texture {
      finish {
        ambient 0.1 diffuse 0.1
        reflection 0.70
        specular 1 roughness 0.010
      }
      pigment { color cor_cristal_verde filter 1 }
    }
  #declare cor_metal_ouro = <1,1,0>;
  #declare tx_metal_ouro = 
    texture {
      finish {
        ambient 0.05 diffuse 0.05
        reflection cor_metal_ouro
        specular 0.20 roughness 0.05
      }
      pigment { color cor_metal_ouro }
    }

  #declare predio =
     difference { 
        box { /* A caixa do predio */
           <0, 0, 0>
           <2.5, 2.5, 5>
           texture { tx_cristal_azul }
           interior { ior 1.1 }
        }
        box {
           <0.5, -0.01, -0.01>
           <2.0, 2.51, 2>
        }
        box {
           <-0.01, 0.5, -0.01>
           <2.51, 2.0, 2>
        } 
     }

  #declare ALTURA_CONE = 2;
  #declare meu_cone = 
    cone {
      <0, 0, 0>, (1.5 / 2)
      <0, 0, ALTURA_CONE>, 0
      texture { tx_cristal_verde }
      interior { ior 1.3 }
    }
/*
 #declare Half_Torus = difference {
    torus { 4, 1
      rotate -90*x  // so we can see it from the top
    }
    box { <-5, -5, -1>, <5, 0, 1> }
    pigment { tinta_AMARELA }
  }
*/
  #declare meio_toroide =
     difference {
       torus {
         1.5, 1
       }
       box {
         <-4.01, -1, 0>
         <4, 1, 5>
         texture { tx_metal_ouro }
       }
     }
  object { meio_toroide texture { tx_metal_ouro } translate <6,1.125,2> }
  object { meio_toroide texture { tx_metal_ouro } rotate y*180 translate <-6, 1.125, 0> }

  union {
    union {
      object { predio }
      object { meu_cone rotate y*180 translate <1.125, 1.125, 5 + ALTURA_CONE> }
      translate <-3, 0, 0>
    }
    union {
      object { predio }
      object { meu_cone translate <1.125, 1.125, 5> }
      translate <0.5, 0, 0>
    }
  }