// Last edited on 2003-12-14 20:21:10 by stolfi
// TP09 - 11/11/03
#include "colors.inc"
#include "skies.inc"


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

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

camera {
  location   ctr + 1.00*camDir
  right      -1.00*x
  up         1.00*y
  sky        y
  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 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 * < +0.0, 0.0, +1000.0 >             // Posição da lâmpada.
  color rgb 0.8 * < 1.00, 1.00, 1.00 >   // Intensidade e corda luz.
}

#declare cam = < 1.5, 1.05, 3243.3 >;
#declare ctr = < 0.0,-0.35, 0.00 >;

light_source {
  100*(vrotate(cam, <0,-25,0>) + < 0.5, 2.0, -0.5 >)
  color rgb 1.2*< 1.00, 1.00, 1.00 >
}

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

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

#declare cor_cristal= <1,0.5,0.5>;
#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 = rgb <0.55, 0.55, 0.55>;
#declare tx_espelho =
  texture {
    pigment { cor_espelho }
    finish {
      ambient 0.05 diffuse 0.05
      reflection cor_espelho
      specular 0.20 roughness 0.05
    }
  }
  
#declare L =
  union {
    box {
      <1,0,0.9>,
      <3,1,-0.9>
    }
    box {
      <0,0,0.9>,
      <1,5,-0.9>
    }
  }

#declare I =
  box {
    <0,0,0.9>,
    <1,5,-0.9>
  }

#declare V =
  difference {
    merge {
      box {
        <0,-1,0.9>,
        <1,6,-0.9>
        rotate 20*z
      }
      box {
        <0,-1,0.9>,
        <1,6,-0.9>
        rotate -20*z
      }
    }
    box {
      <-1,0,2>,
      <2,-2,-2>
    }
    box {
      <-5,5,2>,
      <5,7,-2>
    }
  }

#declare LIV =
  union {
    object { L }
    object { I translate <5,0,0> }
    object { V translate <9,0,0> }
    texture { tx_cristal } interior { ior 1.0 }
  }

#declare raio = 6;
#declare base =
  difference {
    sphere {
      <0,0,0>, raio
    }
    box {
      <-(raio+1),-(raio+1),0.5>,
      <raio+1,raio+1,raio+1>
    }
    box {
      <-(raio+1),-(raio+1),-0.5>,
      <raio+1,raio+1,-(raio+1)>
    }
    texture { tx_espelho }
  }

#declare chao =
  plane { y,-5
    texture {
      pigment{ color rgb < 0.7, 0.7, 1 > }
      finish { reflection .35 specular 1 }
      normal { ripples .35 turbulence .5 scale .25 }
    }
  }

// Aqui está a cena:
union {
  object { base scale <2,0.8,1> }
  object { LIV translate <-5,-2,0.3> }
  object { chao }
}