#include "colors.inc"

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

light_source {
  < 10.00, 5.00, 10.00 >
  color rgb < 1.00, 1.00, 1.00 >
} 

light_source {
  < 5.00, 5.00, 20.00 >
  color rgb < 1.20, 1.20, 1.20 >
} 

light_source {
  < -10.00, -5.00, 10.00 >
  color rgb < 1.00, 1.00, 1.00 >
} 

camera {
  location  <  10.00, 20.00, 15.00 >
  right     <  2.40, 0.00, 0.00 >
  up        <  0.00, 0.00, 1.80 >
  sky       <  0.00, 0.00, 1.00 >
  look_at   <  5.00, 0.00, 5.00 >
  rotate    <  0.00, 0.00, 0.00 >
} 

#declare textura_1 = 
  texture {
    scale 0.03
    pigment { Gray50 }
    finish {
      ambient .2
      diffuse .6
      specular .75
      roughness .001
    }
}

#declare textura_2 = 
  texture {
    scale 0.03
    pigment { Gray50 }
    finish {
      ambient .2
      diffuse .6
      specular .75
      roughness .001
      reflection 0.5
    }
}

#declare i = 1;
#declare n = 6; // andares
#declare r = 7; // janelas por andar na fachada
#declare s = 4; // janelas por andar na lateral
#declare tn = n;
#declare tr = r;
#declare ts = s;
#declare janela =
  box {
    <0.5, 0.5, 0.5>,
    <-0.5, -0.5, -0.5>
}

#declare predio1 = 
  box {
   < (1.5*(tr)/2+1), (1.5*(ts)/2+0.5), (1.5*(tn+2) -0.5) >,
   < (-1.5*(tr)/2-1), (-1.5*(ts)/2-0.5), 0>
   texture { textura_1 }
}
#declare porta =
  box {
    <1,0.5,0>,
    <-1,0,1.5>
    texture { textura_2 }
}

#declare janelas = 
union {
  #declare n = tn
  #while ( n >0 )
    #declare r = tr;
    #while ( r > 0) 
      #if (n > 0)
	object {janela translate < (1.5*(r-1)-tr/2-0.5),((1.5*ts)/2)+0.02, ((n+1)*1.5) > }
      #end
      #declare r = r-1;
    #end
    #declare s = ts;
    #while ( s>0 )
      object { janela translate < (1.5*(tr/2)+0.52), (1.5*(s-1)-ts/2), ((n+1)*1.5) > }
      object { janela translate < (-1.5*(tr/2)-0.52), (1.5*(s-1)-ts/2), ((n+1)*1.5) > }
      #declare s = s-1;
    #end
    #declare n = n-1;
  #end
  object { porta translate <0, ((1.5*ts)/2+0.02), 0> }
}	



plane {z,0
    texture {
      pigment {
        color <.85, .5, .15>
      }
      finish {
        ambient .25
        diffuse .6
        crand .5
      }
      normal {
        ripples .35
        turbulence .25
        frequency 5
      }
      scale 10
      translate 50*x
    }
  }
union{ 
  object { predio1 }
  object { janelas }
  object { predio1 translate <15,0,0>}
  object { janelas translate <15,0,0>}


}