// MC930: Projeto Final - 14/12/2000

#include "textures.inc"
#include "colors.inc"
#include "finish.inc"
#include "stones.inc"
#include "stones1.inc"
#include "stones2.inc"

background { color rgb < 1.00, 1.00, 0.80 > }

//plano que da a impressao do ceu
plane { y, 500
  texture {
    pigment { color rgb <0.22, 0.3, 0.82> }
    finish { ambient 1 diffuse 0}
  }
  texture {
    pigment {
      bozo
      turbulence .5
      color_map {
        [0 color rgb <1, 1, 1>]
        [1 color rgb <1, 1, 1> filter 1]
      }
    }
    finish { ambient 1 diffuse 0 }
    scale <1000, 250, 250>
    rotate <5, 45, 0>
    }
}

light_source {
  < 0.00, 10.00, 100.00 >
  color rgb 2* < 1.00, 1.00, 1.00 >
} 

//light_source {
//    <50.00, 30.00, 200.00>
//    color rgb 2* < 1.00, 1.00, 1.00 >
//    spotlight
//    radius 10
//    falloff 15
//    tightness 10
//    point_at <-10.00, 0.00, 20.00> }

camera {
  location  < 20.00, 30.00, 50.00 >
  right     < 2.40, 0.00, 0.00 >
  up        < 0.00, 0.00, 1.80 >
  sky       < 0.00, 1.00, 0.00 >
  look_at   < 10.00, 30.00, 30.00 >
} 

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

#declare tinta_AZUL = 
  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_VERD = 
  texture {
    pigment { color rgb < 0.00, 0.50, 0.00 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tinta_MARR = 
  texture { T_Stone1 }
//    pigment { color rgb < 0.30, 0.25, 0.05 > }
//    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
//  }

#declare tinta_MARR2 =
  texture {
    pigment { color rgb < 0.10, 0.10, 0.05 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

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

#declare tinta_BEGE = 
  texture {
    pigment { color Brass }
    normal { bumps 0.7 scale 0.001 }
  }

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

#declare tinta_VIDR = 
  texture {
    Glass
    normal { bumps 0.05 scale 0.001 }
  }

#declare chao =
  plane {
    y,
    0
    pigment {color rgb <0.90, 0.90, 0.90>}
    }

#declare terreo =
  union {

// terreo

    box {
      < -11.5,   9.75, -11.5>,
      <  11.5,  10.50,  11.5>
      texture { tinta_MARR }
      }

// primeira laje

    box {
      < -12,  10, -12>,
      <  12,  11,  12>
      texture { tinta_MARR }
      }
    }

#declare i = 1;

#declare g = seed(pi);

#declare andares =

  union {

    #declare n_and = rand(g) * 30;

    #while (i < n_and + 1)

         box {
           < -10.25, 5.35 + 5*i, -10.25>,
           <  10.25, 5.65 + 5*i,  10.25>
           texture { tinta_MARR }
           }

         box {
           < -10.25, 7.95 + 5*i, -10.25>,
           <  10.25, 8.25 + 5*i,  10.25>
           texture { tinta_MARR }
           }

// paredes de frente

       box {
         < -11.5,  5 + 5*i, 10.2>,
         < -10.5, 10 + 5*i, 11.0>
         texture { tinta_MARR }
         }
       box {
         < -5.5,  5 + 5*i, 10.2>,
         < -4.5, 10 + 5*i, 11.0>
         texture { tinta_MARR }
         }
       box {
         < -0.5,  5 + 5*i, 10.2>,
         <  0.5, 10 + 5*i, 11.0>
         texture { tinta_MARR }
         }
       box {
         < 4.5,  5 + 5*i, 10.2>,
         < 5.5, 10 + 5*i, 11.0>
         texture { tinta_MARR }
         }
       box {
         < 10.5,  5 + 5*i, 10.2>,
         < 11.5, 10 + 5*i, 11.0>
         texture { tinta_MARR }
         }

// janelas de frente

       box {
         < -10.5,  5 + 5*i,  9.5>,
         <  -5.5, 10 + 5*i, 10.5>
         texture { tinta_VIDR }
         }
       box {
         < -4.5,  5 + 5*i,  9.5>,
         < -0.5, 10 + 5*i, 10.5>
         texture { tinta_VIDR }
         }
       box {
         < 0.5,  5 + 5*i,  9.5>,
         < 4.5, 10 + 5*i, 10.5>
         texture { tinta_VIDR }
         }
       box {
         <  5.5,  5 + 5*i,  9.5>,
         < 10.5, 10 + 5*i, 10.5>
         texture { tinta_VIDR }
         }

// paredes de fundo

       box {
         < -11.5,  5 + 5*i, -10.2>,
         < -10.5, 10 + 5*i, -11.0>
         texture { tinta_MARR }
         }
       box {
         < -5.5,  5 + 5*i, -10.2>,
         < -4.5, 10 + 5*i, -11.0>
         texture { tinta_MARR }
         }
       box {
         < -0.5,  5 + 5*i, -10.2>,
         <  0.5, 10 + 5*i, -11.0>
         texture { tinta_MARR }
         }
       box {
         < 4.5,  5 + 5*i, -10.2>,
         < 5.5, 10 + 5*i, -11.0>
         texture { tinta_MARR }
         }
       box {
         < 10.5,  5 + 5*i, -10.2>,
         < 11.5, 10 + 5*i, -11.0>
         texture { tinta_MARR }
         }

// janelas de fundo

       box {
         < -10.5,  5 + 5*i,  -9.5>,
         <  -5.5, 10 + 5*i, -10.5>
         texture { tinta_VIDR }
         }
       box {
         < -4.5,  5 + 5*i,  -9.5>,
         < -0.5, 10 + 5*i, -10.5>
         texture { tinta_VIDR }
         }
       box {
         < 0.5,  5 + 5*i,  -9.5>,
         < 4.5, 10 + 5*i, -10.5>
         texture { tinta_VIDR }
         }
       box {
         <  5.5,  5 + 5*i,  -9.5>,
         < 10.5, 10 + 5*i, -10.5>
         texture { tinta_VIDR }
         }

       #declare i = i + 1;
       #end
       #declare i = 1;
   }

// janelas direitas

       box {
         < 10.5, 10,  10.5>,
         < 11.5, 56, -11.5>
         texture { tinta_MARR }
         }

// janelas esquerdas

       box {
         < -10.5, 10,  10.5>,
         < -11.5, 56, -11.5>
         texture { tinta_MARR }
         }

// miolo do predio

    box {
      < -10,  16.5, -10>,
      <  10,  62.0,  10>
      texture { tinta_MARR2 }
      }

// laje da cobertura

    box {
      < -11.5,  56, -11.5>,
      <  11.5,  57,  11.5>
      texture { tinta_MARR }
      }

// cobertura

    box {
      < -11.5,  59, -11.5>,
      <  11.5,  60,  11.5>
      texture { tinta_MARR }
      }

    box {
      < -11.5, 50, 10.2>,
      < -10.5, 60.5, 11.0>
      texture { tinta_MARR }
      }

    box {
      < -5.5, 50, 10.2>,
      < -4.5, 60.5, 11.0>
      texture { tinta_MARR }
      }

    box {
      < -0.5, 50, 10.2>,
      <  0.5, 60.5, 11.0>
      texture { tinta_MARR }
      }

    box {
      < 4.5, 50, 10.2>,
      < 5.5, 60.5, 11.0>
      texture { tinta_MARR }
      }

    box {
      < 10.5, 50, 10.2>,
      < 11.5, 60.5, 11.0>
      texture { tinta_MARR }
      }

    box {
      < -11.5, 50, -10.2>,
      < -10.5, 60.5, -11.0>
      texture { tinta_MARR }
      }

    box {
      < -5.5, 50, -10.2>,
      < -4.5, 60.5, -11.0>
      texture { tinta_MARR }
      }

    box {
      < -0.5, 50, -10.2>,
      <  0.5, 60.5, -11.0>
      texture { tinta_MARR }
      }

    box {
      < 4.5, 50, -10.2>,
      < 5.5, 60.5, -11.0>
      texture { tinta_MARR }
      }

#declare cupula =

    prism {
      linear_sweep
      linear_spline
      37, // sweep the following shape from here ...
      60,   // ... up through here
      3,    // the number of points making up the shape ...
      <-11.5,11.5>, <0,6>, <11.5,11.5>
      texture { tinta_MARR }
      }

#declare cupula2 =

    prism {
      linear_sweep
      linear_spline
      37, // sweep the following shape from here ...
      60,   // ... up through here
      3,    // the number of points making up the shape ...
      <-8.75,9>, <0,4.5>, <8.75,9>
      texture { tinta_MARR }
      }

#declare cupula3 =

    prism {
      linear_sweep
      linear_spline
      38, // sweep the following shape from here ...
      61,   // ... up through here
      3,    // the number of points making up the shape ...
      <-4.75,8>, <0,6>, <4.75,8>
      texture { tinta_MARR }
      }

#declare cupula4 =

    prism {
      linear_sweep
      linear_spline
      36, // sweep the following shape from here ...
      59,   // ... up through here
      3,    // the number of points making up the shape ...
      <-4.75,8>, <0,6>, <4.75,8>
      texture { tinta_BRAN }
      }

#declare cupula5 =

    prism {
      linear_sweep
      linear_spline
      39, // sweep the following shape from here ...
      62,   // ... up through here
      4,    // the number of points making up the shape ...
      <0,5>, <-1.5,7>, <0,8>, <1.5,7>
      texture { tinta_BRAN }
      }

#declare cupula6 =
  difference {
    union {
      difference {
        object { cupula2 }
        object { cupula3 }
      }
      object { cupula4 }
    }
    object { cupula5}
  }

#declare furo =

    cylinder {
      < 0, 56.7, -12>,
      < 0, 56.7,  12>,
      1.5
      texture { tinta_VIDR }
      }

#declare frontal =

       box {
         < -11.75, -6, 11>,
         < -10.5, 10, 11.75>
         texture { tinta_MARR }
         }
       box {
         < -9.5,  0, 11>,
         < -8.5, 16, 11.75>
         texture { tinta_MARR }
         }
       box {
         < -5.5,  0, 11>,
         < -4.5, 16, 11.75>
         texture { tinta_MARR }
         }
       box {
         < -2.5,  0, 11>,
         < -1.5, 11, 11.75>
         texture { tinta_MARR }
         }
       box {
         < 7.5,  0, 11>,
         < 8.5, 11, 11.75>
         texture { tinta_MARR }
         }
       box {
         < 10.5,  0, 11>,
         < 11.75, 16, 11.75>
         texture { tinta_MARR }
         }
       box {
         < -12, 6.5, 10.0>,
         <  12,  16, 11.5>
         texture { tinta_VIDR }
         }
       box {
         < -12,   0, 10.0>,
         <  -1, 5.5, 11.5>
         texture { tinta_VIDR }
         }
       box {
         <  8,   0, 10.0>,
         < 12, 5.5, 11.5>
         texture { tinta_VIDR }
         }
        box {
         < -12,  0,  -12>,
         <  12, 16,  10>
         texture { tinta_MARR }
         }
       box {
         < -11.5, 5.5, -11.5>,
         <  11.5, 6.5,  11.5>
         texture { tinta_BRAN }
         }
       box {
         < -11.5, 0, -11.5>,
         <  -1.5, 5.5,  11.5>
         texture { tinta_VIDR }
         }
       box {
         <  8.5, 0, -11.5>,
         < 11.5, 5.5,  11.5>
         texture { tinta_VIDR }
         }
       box {
         < -1, 0,  -10.5>,
         <  8, 5.5, 10.0>
         texture { tinta_MARR2 }
         }

#declare predio =
  union {
    object { terreo }
    object { andares }
  }

#declare vazio =
  box  {
    < -7.5, 0,   -7.5>,
    <  7.5, 0.5,  7.5>
    texture { tinta_VERD }
    }

#declare terreno =
  box {
    < -15, 0,   -15>,
    <  15, 0.5,  15>
    texture { tinta_VERD }
    }

#declare final =
  union {
    object { predio }
    difference {
      object { cupula translate <0,-60,-11.5>
             rotate <90,0,0> translate <0,54.5,11.5>}
      object { furo }}
    object { cupula6 translate <0,-60,-11.75>
             rotate <90,0,0> translate <3,2.75,11.75>}
    object { frontal }
  }

// Cena Final
  object { chao }
  object { terreno }
  object { final translate <0,6,0>}