// MC930 - Trabalho final
// Luis Arthur Micai Nunes   RA: 971106
// Inicio em 14/12/2000
// Fim em 17/01/2001


//  Instituto de Economia - UNICAMP

#include "colors.inc"
#include "textures.inc"
#include "skies.inc"
#include "glass.inc" 

// CAMERA

camera {
    location <8,13,-35>            // z = -50
    look_at <19,6,0>
     }

//CEU

sky_sphere {
    pigment {
        gradient y
        pigment_map {
            [0.00 rgb <0.847, 0.749, 0.847> ] // horizonte
            [0.10 SkyBlue ]                   // horizonte
            [0.20 P_Cloud4 ]
        }
    }
}



//FUNDO

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

#declare Branco = texture { pigment { color Gray50} 
                           finish {  roughness 0.7  specular 0.9 }
                          
}

//ILUMINACAO

light_source { <10, 30.00, -50.00 >
    color rgb <3.00, 3.00, 3.00>
}

light_source { <50,10,-5>
   color rgb<2,2,2>
}



// ESTRUTURA DO PREDIO

#declare altura = 9;
#declare prof = 30;
#declare comp = 40;

#declare estrutura = 
 box {
     <0,0,0>,
     <comp,altura,prof>
     texture { Branco }
     }
    

//CHAO

plane {
        y, 0
        pigment { Green }
       }

//PLATAFORMA

#declare plataforma=
      box{
         <-2,0,-2>,
         <comp+2,2,prof+2>
         texture{ Branco }    
   }

//SACADA

#declare sacada =
   box{
      <0,6,-2>,
      <comp+2,7,2>
      texture {Branco}
    }

// PLACAS

#declare alt = 3;
#declare hipotenusa = 1.41*alt;


#declare placa =
union{
   box {
        <0,0,0>,
        <hipotenusa,0.2,prof+4>
        pigment {Brown}
        rotate<0,0,-45>        
        translate<0,1,0>
     }
   box {
        <0,0,0>,
        <0.2,alt,prof+4>
        pigment {Brown}
        translate<0,-1.55,0>
       }
}

//GRADE

#declare ext_grade = 0;

#declare grade  =
union{
 #while (ext_grade < 80)
  #switch(ext_grade)
     #range(35,57)
      #break
      #else
  
      object {
          cylinder {
              <0,0,0>,
              <0,altura/3,0>,
              0.1
              pigment {DarkGreen}
           translate<0.5*ext_grade,2,-2>     
           }
    
        }
      #end

  #declare ext_grade = ext_grade +1;
 #end

#declare alt_grade = 0;

#while(alt_grade < 5)

union {
  object { cylinder {
                 <0,3,-2>,
                 <17,3,-2>
                 0.1
                 texture {pigment  { DarkGreen } }
                 translate<0,0.5*alt_grade,0>
                  }  }
   object {cylinder {
                    <29, 3, -2>,
                    <40,3,-2>
                    0.1
                    texture { pigment {DarkGreen } }
                    translate <0,0.5*alt_grade,0>
                  }  }
 
  }
    #declare alt_grade = alt_grade + 1;
    #end
}




//BLOCO FRONTAL

#declare bloco_frontal =

  box {
      <0,0,0>,
      <comp/5, 1+altura/2, -prof/6>
      pigment { color rgb <0.1,0.1,0.3>}
      }




//RAMPA

#declare rampa = 
     prism { 
        linear_sweep 
        linear_spline 
        0, 
        altura/3, 
        4 
        <0,0>, <altura/4,0>, <altura/4,-(altura/4)>,<0,0> 
        rotate<-90,90,0>         
        rotate<-90,0,0>
        translate <20,3.5,-4> 
        texture { Branco } 
     } 

//TERRACO

#declare terraco =
   box { <-1,0,0>
         <5,3.3,2>
         texture{  Branco }
         translate <18,0,-5.5>
       }


// TELHADO

#declare tx = 0;

#declare telhado =
union {

    #while (tx<13) 
    object{placa
            translate<tx*alt,altura+4,-2>
            }
    #declare tx = tx + 1;
    #end

} // union

//CORRIMAO

#declare esp = 0;

#declare corrimao =

union{
 difference {
   cylinder{
       <0,8,-2.0>,
       <comp+2,8,-2.0>
       0.1
       texture {pigment {color DarkGreen } }
    }
   box{ <20,7,1>
        <24,9,-4>
        texture {Branco }
      }
}

#while (esp<11)
    cylinder{
       <0,7,-2.0>,
       <0,8,-2.0>
       0.1
       texture { pigment {color DarkGreen } }
       translate<4*esp,0,0>
   }
#declare esp = esp +1;
#end

}

//JANELA, PORTA E AR CONDICIONADO

#declare janela_porta=

union{
   box{
       <1,0,-0.1>,
       <2,2.3,0.1>
       pigment { Black }
      }
   box{
       <2.5,0,-0.1>,
       <3.5,2.3,0.1>
       texture {
       pigment { color rgbf <0.98, 1.0, 0.5, 0.75> }
       finish { F_Glass4 } }

       interior{ I_Glass}
      }
    box {
        <2.5, 2.4, -1>,
        <3.5, 2.9, 0.1>
        texture {
               pigment {color rgb <0.2,0.2,0.2> } }
        }
      
}

#declare i = 0;

#declare janelas_e_portas = 

union{

     #while(i<10)
         #declare j=0;
         #while (j<2)
         object {janela_porta
         translate <i*4,j*5,0>
            }
         #declare j = j + 1;
         #end
     #declare j = 1;
     #declare i = i + 1;
  #end

}



union {
object{estrutura
       translate<0,2,0>}
object{janelas_e_portas
       translate<0,2.1,0>}
object{plataforma}
object{sacada}
object{telhado
       translate<0.5,0,0>}
object{rampa}
object{rampa
       rotate<0,185,0>      
       translate<40,2.0,-7.0>
       }
object{terraco}
object{bloco_frontal}
object{grade}
object{corrimao}
}