// Last edited on 2001-01-29 01:28:36 by stolfi
// Alterada a posição da câmera [J.Stolfi]

/*********** PROJETO DE FINAL DE MC930 - COMPUTAÇÃO GRAFICA***********
        
        PROFESSOR: STOLFI        
        AUTOR: JOAO PAULO GUIMARO BATISTELLA    RA: 970872
*/        

#include "colors.inc"
#include "textures.inc"
#include "woods.inc"  
#include "metals.inc"       
#include "stoneold.inc"    
#include "stones2.inc"




sky_sphere {
    pigment {
      gradient y
      color_map {
        [0.000 0.002 color rgb <1.0, 0.2, 0.0>
                     color rgb <1.0, 0.2, 0.0>]
        [0.002 0.200 color rgb <0.8, 0.1, 0.0>
                     color rgb <0.2, 0.2, 0.3>]
      }
      scale 2
      translate -1
    }
    pigment {
      bozo
      turbulence 0.65
      octaves 6
      omega 0.7
      lambda 2
      color_map {
          [0.0 0.1 color rgb <0.85, 0.85, 0.85>
                   color rgb <0.75, 0.75, 0.75>]
          [0.1 0.5 color rgb <0.75, 0.75, 0.75>
                   color rgbt <1, 1, 1, 1>]
          [0.5 1.0 color rgbt <1, 1, 1, 1>
                   color rgbt <1, 1, 1, 1>]
      }
      scale <0.2, 0.5, 0.2>
    }
    rotate -135*x
  }

/*sky_sphere {
    pigment {
      gradient y
      color_map {
        [ 0.5  color CornflowerBlue ]
        [ 1.0  color MidnightBlue ]
      }
      scale 2
      translate -1
    }
  }
  */
background { color Gray25 }  //to make the patch easier to see

/*  plane { <0, 0, 1>, -6
    pigment {
      checker color Red, color Blue
    }
  }*/

  plane { <0, 0, 1>, -6
    texture {T_Stone30} 
  }


light_source {
  // < 0.00, 40.00, 80.00 >            // [original]
  // color rgb < 1.00, 1.00, 1.00 >    // [original]
  100*< 0.00, 80.00, 30.00 >           // [J.Stolfi]
  color rgb 1.25*< 1.00, 0.98, 0.95 >  // [J.Stolfi]
}
    
light_source {
  // <50.0,50,20>           // [original]
  // color rgb <1,1,1>      // [original]
  100*<50.0, 20, 30>        // [J.Stolfi]
  color rgb 0.75*<1,1,1>    // [J.Stolfi]
 }

light_source {
  // <-40.0,50,0>           // [original]
  // color rgb <1,1,1>      // [original]
  100*<-50, 10, 30>         // [J.Stolfi]
  color rgb 0.50*<1,1,1>    // [J.Stolfi]
 }
 
// ======================================================================
// begin new camera
#declare centro_da_cena = <0, 20, 15>;
#declare raio_da_cena = 20;
#declare direcao_da_camera = vnormalize( < -3, 4, -0.25 > );

#declare dist_da_camera = 6.0 * raio_da_cena
#declare pos_da_camera = centro_da_cena + dist_da_camera * direcao_da_camera;
camera {
  location  pos_da_camera
  right     <  -0.64,  0.00,  0.00 >
  up        <   0.00,  0.48,  0.00 >
  sky       z
  look_at   centro_da_cena
}
// end new camera
// ======================================================================

// ======================================================================
// begin original camera
//  camera {
//    location  <  -20.00,63.0, 0.00 >
//    right    2* < -1.20, 0.00, 0.00 >
//    up       2* <  0.00, 0.00, 0.90 >
//    sky       <  0.00, 0.00, 1.00 >
//    look_at   <  0.00,0.00, 15.00 >
//  }           
// end original camera
// ======================================================================


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

#declare tinta_B = 
  texture {
    pigment { color rgb < 0.7529, 0.8078, 0.6627 > }
    finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 }
  }

#declare tex = texture { DMFWood6  }



#declare estrutura =     
difference {
box { <-13,-5,-15>, <13,13,15>
texture {tinta_A}
}           

box {<-12,-5,-15>,<12,13,-13>
 texture {tinta_B}
}    

}
      


  
  
#declare estrutura =  
difference {
        difference {   
        prism {
        linear_sweep
        linear_spline
        0, // sweep the following shape from here ...
        40, // ... up through here
        6, // the number of points making up the shape ...
        <-14,-5>, <-14,13>, <0,17>,<14,13>,<14,-5>,<-14,-5>
        pigment { color rgb <1,1,0.6> }
        }         
  
        prism {
        linear_sweep
        linear_spline
        39.5, // sweep the following shape from here ...
        40.2, // ... up through here
        6, // the number of points making up the shape ...
        <-13,-5>, <-13.0,12.0>, <0,15.8>,<13.0,12>,<13,-5>,<-13,-5>
        pigment { color rgb <1,1,0.6> }
        }         
        }//difference  
        
        prism {
        linear_sweep
        linear_spline
        39, // sweep the following shape from here ...
        40.2, // ... up through here
        6, // the number of points making up the shape ...
        <-12.5,-5>, <-12.5,11.5>, <0,15.3>,<12.5,11.5>,<12.5,-5>,<-12.5,-5>
        pigment { color rgb <1,1,0.6> }
        }

        prism {
        linear_sweep
        linear_spline
        36.5, // sweep the following shape from here ...
        39.7, // ... up through here
        6, // the number of points making up the shape ...
        <-4,1>, <-4,13.5>, <0,14.7>,<4,13.5>,<4,1>,<-4,1>
       // pigment { color rgb <1,1,0.6> }
        }

}   
       

       
#declare porta =   
union {
        prism {
        linear_sweep
        linear_spline
        38.5, // sweep the following shape from here ...
        39.2, // ... up through here
        5, // the number of points making up the shape ...
        <-2.3,-2>, <0,-2>, <-0,2>,<-2.3,2>,<-2.3,-2>
        
        texture {P_WoodGrain11A }

        }        
        
        prism {
        linear_sweep
        linear_spline
        38.5, // sweep the following shape from here ...
        39.2, // ... up through here
        5, // the number of points making up the shape ...
        <2.3,-2>, <0,-2>, <0,2>,<2.3,2>,<2.3,-2>
        
        texture {P_WoodGrain11A }

        }    
        
        //entre as duas portas...
        prism {
        linear_sweep
        linear_spline
        38.5, // sweep the following shape from here ...
        39.25, // ... up through here
        5, // the number of points making up the shape ...
        <-0.05,-2>, <0.05,-2>, <0.05,2>,<-0.05,2>,<-0.05,-2>
        
        pigment {color Black}
        }
           
                
              
}

#declare buraco = //buracos do detalhe cilindrico
box{
        <-0.40,-1,-0.15>,
        <0.40,1,0.15>


}

#declare detalhe_cilindrico =
cylinder {
        <0,40,-5>,
        <0,40,0.5>,
        3
        pigment { color rgb <1,1,0.6> }
        }

#declare estrutura =
union{
object{estrutura}
object{porta
        translate <-7,0,-3>}
object{porta
        translate <7,0,-3>}
       }


//subtraindo os buracos do detalhe cilindrico


//buraco 1
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,20> translate <0.5,43.5,0>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,20> translate <0.5,43.5,-1>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,20> translate <0.5,43.5,-2>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,20> translate <0.5,43.5,-3>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,20> translate <0.5,43.5,-4>}

         }



//buraco 2
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,30> translate <1.7,43,0>}

         }

#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,30> translate <1.7,43,-1>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,30> translate <1.7,43,-2>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,30> translate <1.7,43,-3>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,30> translate <1.7,43,-4>}
          }

//buraco 3
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-20> translate <-0.5,43.5,0>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-20> translate <-0.5,43.5,-1>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-20> translate <-0.5,43.5,-2>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-20> translate <-0.5,43.5,-3>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-20> translate <-0.5,43.5,-4>}

         }

//buraco 4
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-30> translate <-1.7,43,0>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-30> translate <-1.7,43,-1>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-30> translate <-1.7,43,-2>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-30> translate <-1.7,43,-3>}

         }
#declare  detalhe_cilindrico =
difference{
        object{detalhe_cilindrico}
        object{buraco rotate<0,0,-30> translate <-1.7,43,-4>}

         }


#declare janela =
box{
        <-0.45,-0.3,-0.7>,
        <0.45,0.3,0.7>
       texture {Vicks_Bottle_Glass  }

}

#declare janela_trapezio =
prism {
        linear_sweep
        linear_spline
        -0.3, // sweep the following shape from here ...
        0.3, // ... up through here
        5, // the number of points making up the shape ...
        <-0.45,-0.7>, <-0.45,1.2>, <0.45,0.7>,<0.45,-0.7>,<-0.45,-0.7>

        texture {  Vicks_Bottle_Glass  }
        }

//colocando as janelas do lado esquerdo
#declare estrutura =
union {
        object{estrutura}
        //1. fileira
        object{janela translate <8.9,38.75,2>}
        object{janela translate <7.6,38.75,2>}
        object{janela translate <6.3,38.75,2>}
        object{janela translate <5.0,38.75,2>}
        //2. fileira
        object{janela translate <8.9,38.75,3.8>}
        object{janela translate <7.6,38.75,3.8>}
        object{janela translate <6.3,38.75,3.8>}
        object{janela translate <5.0,38.75,3.8>}

        //3. fileira
        object{janela translate <8.9,38.75,5.6>}
        object{janela translate <7.6,38.75,5.6>}
        object{janela translate <6.3,38.75,5.6>}
        object{janela translate <5.0,38.75,5.6>}

        //4. fileira
        object{janela translate <8.9,38.75,7.4>}
        object{janela translate <7.6,38.75,7.4>}
        object{janela translate <6.3,38.75,7.4>}
        object{janela translate <5.0,38.75,7.4>}

        //5. fileira - janela trapezio
        object{janela_trapezio scale <1,1,1> translate <8.9,38.75,9.2> }
        object{janela_trapezio scale <1,1,1.25> translate <7.6,38.75,9.3> }
        object{janela_trapezio scale <1,1,1.5> translate <6.3,38.75,9.6>}
        object{janela_trapezio scale <1,1,1.75> translate <5.0,38.75,9.8>}

}

//colocando as janelas do lado direito
#declare estrutura =
union {
        object{estrutura}
        //1. fileira
        object{janela translate <-8.9,38.75,2>}
        object{janela translate <-7.6,38.75,2>}
        object{janela translate <-6.3,38.75,2>}
        object{janela translate <-5.0,38.75,2>}
        //2. fileira
        object{janela translate <-8.9,38.75,3.8>}
        object{janela translate <-7.6,38.75,3.8>}
        object{janela translate <-6.3,38.75,3.8>}
        object{janela translate <-5.0,38.75,3.8>}

        //3. fileira
        object{janela translate <-8.9,38.75,5.6>}
        object{janela translate <-7.6,38.75,5.6>}
        object{janela translate <-6.3,38.75,5.6>}
        object{janela translate <-5.0,38.75,5.6>}

        //4. fileira
        object{janela translate <-8.9,38.75,7.4>}
        object{janela translate <-7.6,38.75,7.4>}
        object{janela translate <-6.3,38.75,7.4>}
        object{janela translate <-5.0,38.75,7.4>}

        //5. fileira - janela trapezio
        object{janela_trapezio scale <1,1,1> rotate <0,0,180> translate <-8.9,38.75,9.2> }
        object{janela_trapezio scale <1,1,1.25> rotate <0,0,180> translate <-7.6,38.75,9.3> }
        object{janela_trapezio scale <1,1,1.5> rotate <0,0,180> translate <-6.3,38.75,9.6>}
        object{janela_trapezio scale <1,1,1.75> rotate <0,0,180> translate <-5.0,38.75,9.8>}

}

#declare detalhe_central =
union {
difference {
cylinder{
	<0,0,0>,
	<0,0.1,0>,
	0.3	
        pigment { color rgb <1,1,0.6> }
}
cylinder{
	<0,-0.1,0>,
	<0,0.15,0>,
	0.2
        pigment { color rgb <1,1,0.6> }
}
}

difference {
cylinder{
	<0,0,0.5>,
	<0,0.1,0.5>,
	0.3	
        pigment { color rgb <1,1,0.6> }
}
cylinder{
	<0,-0.1,0.5>,
	<0,0.15,0.5>,
	0.2
        pigment { color rgb <1,1,0.6> }
}
}

difference {
cylinder{
	<0,0,1>,
	<0,0.1,1>,
	0.3	
        pigment { color rgb <1,1,0.6> }
}
cylinder{
	<0,-0.1,1>,
	<0,0.15,1>,
	0.2
        pigment { color rgb <1,1,0.6> }
}
} 

prism {
        linear_sweep
        linear_spline
        0, // sweep the following shape from here ...
        0.1, // ... up through here
        5, // the number of points making up the shape ...
        <0.1,1.3>, <0.1,1.6>, <-0.1,1.6>,<-0.1,1.3>,<0.1,1.3>
        pigment { color rgb <1,1,0.6> }
        }
               
prism {
        linear_sweep
        linear_spline
        0, // sweep the following shape from here ...
        0.1, // ... up through here
        5, // the number of points making up the shape ...
        <0.1,-0.3>, <0.1,-0.6>, <-0.1,-0.6>,<-0.1,-0.3>,<0.1,-0.3>
        pigment { color rgb <1,1,0.6> }                        
        }               

}


#declare barras_verticais =
prism {
        linear_sweep
        linear_spline
        39.1, // sweep the following shape from here ...
        39, // ... up through here
        5, // the number of points making up the shape ...
        <-0.15,0>, <-0.15,13.5>, <0.15,13.5>,<0.15,0>,<-0.15,0>
        pigment { color rgb <1,1,0.6> }
        }


#declare barras_horizontais =
prism {
        linear_sweep
        linear_spline
        39 // sweep the following shape from here ...
        39.1, // ... up through here
        5, // the number of points making up the shape ...
        <0,0>, <0,0.06>, <8,0.06>,<8,0>,<0,0>
        pigment { color rgb <1,1,0.6> }
        }	


#declare lado_torre =
union {
difference {
box {   <-1.5,-0.01,-20>,
	<1.5,0.01,20>
 pigment { color rgb <1,1,0.6>}
}
box { <-1,-0.05,-15> <1,0.06,-10> }
box { <-1,-0.05,-8> <1,0.06,-3> }
box { <-1,-0.05,-1> <1,0.06,4> }
box { <-1,-0.05,6> <1,0.06,11> }
box { <-1,-0.05,13> <1,0.06,18> }
//box { <-1,-0.05,20> <1,0.06,25> }
} //difference



#declare i=-30
#while (i<37)
 object {detalhe_central translate <0,0,i> scale <0.5,0.5,0.5> }
#declare i=i+2;
#end


#declare i=-30
#while (i<37)
 object {detalhe_central translate <-1,0,i> scale <0.5,0.5,0.5> }
#declare i=i+2;
#end

#declare i=-30
#while (i<37)
 object {detalhe_central translate <1,0,i> scale <0.5,0.5,0.5> }
#declare i=i+2;
#end



}//union


#declare relogio=
union {
difference {
box { <-1.5,-1.5,-1.5>,
	<1.5,1.5,1.5>
 pigment { color rgb <1,1,0.6>}
}

cylinder {
	<0,1.4,0>,
	<0,1.52,0>,
	1 pigment {color rgb <1,1,1>}}

}//difference
box { <0,1.5,0>, <0.8,1.6,0.1>
pigment { color rgb <0,0,0>}
rotate <0,30,0>
}

box { <0,1.5,0>, <0.65,1.6,0.1>
pigment { color rgb <0,0,0>}
rotate <0,-40,0>
}

}//union

declare torre =
union { 
        
        object {lado_torre translate <0,0,10>}	      
	object {lado_torre rotate <0,0,90> translate <1.5,-1.5,10>}
       	object {lado_torre rotate <0,0,-90> translate <-1.5,-1.5,10>}
	object {lado_torre rotate <0,0,180> translate <0,-3,10>}
	object {relogio translate <0,-1.5,30.9> }

       }




//colocando os vitrais laterais
#declare estrutura=
union{
        object{estrutura}     
        //lado direito
        #declare i=1               
        #while (i<39)
        object{janela rotate <0,0,90> translate <-14,i,3> } 
        object{janela rotate <0,0,90> translate <-14,i,6> } 
        object{janela rotate <0,0,90> translate <-14,i,9> }                 
        #declare i=i+3;
        #end  
        
        //lado esquerdo
        #declare i=1               
        #while (i<39)
        object{janela rotate <0,0,90> translate <14,i,3>} 
        object{janela rotate <0,0,90> translate <14,i,6> } 
        object{janela rotate <0,0,90> translate <14,i,9> }                 
        #declare i=i+3;
        #end
        
}        

#declare barra=
box {<-0.5,-0.01,2>, <0.5,0.01,2.06> texture{T_Chrome_3A    }}    
    
#declare grade=
union {
        cylinder {<0,0,-2.5>, <0,0,2.5> 0.1 texture{T_Chrome_3A    } }
        cone { <0,0,2.5>, 0.15
                <0,0,2.9>, 0.01    texture{T_Chrome_3A    }}
        object {barra translate <0,0,-0.2>}
        object {barra translate <0,0,-2.6>}
        object {barra translate <0,0,-3>}
}                


#declare cerca =
union {
        object{grade}
        box {<-0.5,-0.2,-3>, <0.5,0.2,-2> texture {T_Stone42 }}
        }//union



//cercando a igreja... 

#declare cercadao =
union {

//parte da frente
#declare i=-24
#while (i<-5)
object {cerca translate <i,50,-2> }    
#declare i=i+1;
#end

//portao
#declare i=-5
#while (i<6)
object {grade translate <i,50,-2> }   
#declare i=i+1;
#end

#declare i=6
#while (i<26)
object {cerca translate <i,50,-2> }    
#declare i=i+1;
#end             

//lateral direita

#declare i=49.5
#while (i>-5)
object {cerca rotate<0,0,90> translate <-24.5,i,-2> }    
#declare i=i-1;
#end 

//atras
#declare i=-24
#while (i<26)
object {cerca  translate <i,-5,-2> }    
#declare i=i+1;
#end 
 
//lateral esquerda
#declare i=-4.5
#while (i<50.5)
object {cerca rotate<0,0,90> translate <25.5,i,-2> }    
#declare i=i+1;
#end  

}//union do cercadao



//TORRE

object {cercadao translate <0,0,-1>}

object {torre translate <-19,38,0> }


object {estrutura }        
object {detalhe_cilindrico  }
object {detalhe_central translate <0,38.9,1.3>  }
object {detalhe_central translate <0,38.9,3.3>  }
object {detalhe_central translate <0,38.9,5.3>  }
object {detalhe_central translate <0,38.9,7.3>  }
object {detalhe_central translate <0,38.9,9.3>  }
object {detalhe_central translate <0,38.9,11.3>  }
object {detalhe_central translate <0,38.9,13.3>  }

object {detalhe_central translate <-1.6,38.9,1.3>  }
object {detalhe_central translate <-1.6,38.9,3.3>  }
object {detalhe_central translate <-1.6,38.9,5.3>  }
object {detalhe_central translate <-1.6,38.9,7.3>  }
object {detalhe_central translate <-1.6,38.9,9.3>  }
object {detalhe_central translate <-1.6,38.9,11.3>  }
object {detalhe_central translate <-1.6,38.9,13.3>  }

object {detalhe_central translate <-3.3,38.9,1.3>  }
object {detalhe_central translate <-3.3,38.9,3.3>  }
object {detalhe_central translate <-3.3,38.9,5.3>  }
object {detalhe_central translate <-3.3,38.9,7.3>  }
object {detalhe_central translate <-3.3,38.9,9.3>  }
object {detalhe_central translate <-3.3,38.9,11.3>  }
object {detalhe_central translate <-3.3,38.9,13.3>  }

                                                     
object {detalhe_central translate <1.6,38.9,1.3>  }
object {detalhe_central translate <1.6,38.9,3.3>  }
object {detalhe_central translate <1.6,38.9,5.3>  }
object {detalhe_central translate <1.6,38.9,7.3>  }
object {detalhe_central translate <1.6,38.9,9.3>  }
object {detalhe_central translate <1.6,38.9,11.3>  }
object {detalhe_central translate <1.6,38.9,13.3>  }
                                   
object {detalhe_central translate <3.3,38.9,1.3>  }
object {detalhe_central translate <3.3,38.9,3.3>  }
object {detalhe_central translate <3.3,38.9,5.3>  }
object {detalhe_central translate <3.3,38.9,7.3>  }
object {detalhe_central translate <3.3,38.9,9.3>  }
object {detalhe_central translate <3.3,38.9,11.3>  }
object {detalhe_central translate <3.3,38.9,13.3>  }


object {barras_verticais translate <0.8,0,1>  }
object {barras_verticais translate <2.5,0,1>}

object {barras_verticais translate <-0.8,0,1>}
object {barras_verticais translate <-2.5,0,1>}