// Fabio Negrello - exercicio 05
// ultima modificacao 09/11/00

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

#declare luz=1.8;

light_source {
  < 100.00, 100.00, -100.00 >
  color rgb < luz, luz, luz >
} 

light_source {
  < 100.00, 100.00, 100.00 >
  color rgb < luz/4, luz/4, luz/4 >
}

camera {
//  location  < 22.00, 23.00, 0.00 >
location  < 0.00, 40.00, 0.00 >
  look_at   < 0.00, 0.00, 0.00 >
} 

#declare bcomp = 9.5;
#declare blarg = 5;
#declare balt = 6;
#declare jlarg = (bcomp/17);
//#declare dist_centro = (3*bcomp)/4;
#declare dist_centro = (0.65*bcomp);
#declare rc = (2*dist_centro)/3; // raio do hexagono central
#declare lc = rc/cos(pi/6); // lado do hexagono

#declare Firebrick = color red 0.556863 green 0.137255 blue 0.137255;

#declare bloco =
	box {
		<0,0,0>
		<bcomp,balt,blarg>
    		texture { pigment {Firebrick} }
	}

#declare jacima =
	box {
		<0,0,0>
		<bcomp-2*jlarg,jlarg,-jlarg/5>
    		texture { pigment { color rgb<1,1,1> } } 
	}

#declare pacima =
	union {

	box {
		<-jlarg/5,0,0>
		<bcomp+(jlarg/5),balt/100,-jlarg/5>
		translate <0,0,-jlarg/5>
    		texture { pigment { color rgb<1,1,1> } } 
	}

	box {
		<-jlarg/5,0,0>
		<bcomp+(jlarg/5),balt/100,-jlarg/5>
		translate <0,0,blarg+jlarg/5>
    		texture { pigment { color rgb<1,1,1> } } 
	}

	box {
		<0,0,-jlarg/5>
		<jlarg/5,balt/100,blarg+(jlarg/5)>
		translate <-jlarg/5,0,0>
    		texture { pigment { color rgb<1,1,1> } } 
	}

	box {
		<0,0,-jlarg/5>
		<jlarg/5,balt/100,blarg+(jlarg/5)>
		translate <bcomp+jlarg/5,0,0>
    		texture { pigment { color rgb<1,1,1> } } 
	}
}


#declare janela = 
	union {
		box {
			<0,0,0>
			<jlarg/5,balt,-jlarg/5>
			texture { pigment { color rgb<1,1,1> } }
		}

		box {
			<0,0,0>
			<jlarg/5,balt,-jlarg/5>
			translate <jlarg,0,0>
			texture { pigment { color rgb<1,1,1> } }
		}

		box {
			<0,0,0>
			<jlarg,jlarg/3,-jlarg/5>
			translate <0,balt/3,0>
			texture { pigment { color rgb<1,1,1> } }
		}

		box {
			<0,0,0>
			<jlarg,jlarg/3,-jlarg/5>
			translate <0,2*(balt/3),0>
			texture { pigment { color rgb<1,1,1> } }
		}

		box {
			<0,0,0>
			<jlarg,balt,-jlarg/10>
			texture { pigment { color rgb<0,0,0> } }
		}

	}

#declare base_centro =
	prism {
    		//linear_sweep
    		//linear_spline
    		0, // sweep the following shape from here ...
    		balt, // ... up through here
    		7, // the number of points making up the shape ...
    		<rc,lc/2>, <0,lc>, <-rc,lc/2>,
		<-rc,-lc/2>, <0, -lc>, <rc,-lc/2>
		<rc,lc/2>

  	}
			
#declare base_topo =
	object {
		base_centro
		scale<1/2,1/4,1/2>
  	}

#declare calt = 9.5*balt/10;
#declare clarg = blarg/3;
#declare ccomp = (dist_centro - rc);

#declare corredor =
	union {
		box {
			<0,0,0>
			<ccomp,calt,-clarg>
			translate <rc,0,(blarg/2)-(clarg/2)>
			texture { pigment { color rgb<1,1,1> } }
		}
	}

#declare borda_topo =
	difference {
		object { base_centro
			scale<1,1/10,1>
		translate <0,balt,0>
		}
		object { base_centro
			scale<0.95,2,0.95>
		}
}

#declare LimeGreen = color red 0.196078 green 0.8 blue 0.196078;

#declare gramado =
	box {
		<-200,-1,-200>
		<200,0,200>
		texture { pigment { LimeGreen } }
	}
		
#declare h=blarg/2;
#declare b=blarg*cos(pi/6);
//#declare b=0;
//#declare h=0;
#declare cdist = dist_centro+bcomp;
#declare calcada =
	difference {
	prism {
    		//linear_sweep
    		//linear_spline
    		-1, // sweep the following shape from here ...
    		0.1, // ... up through here
    		13, // the number of points making up the shape ...
		<cdist,blarg/2>,
		<(cdist/2)+b, (cdist*cos(pi/6))-h>,
		<(cdist/2)-b, (cdist*cos(pi/6))+h>,
		<-(cdist/2)+b, (cdist*cos(pi/6))+h>,
		<-(cdist/2)-b, (cdist*cos(pi/6))-h>,
		<-cdist,blarg/2>,<-cdist,-blarg/2>,
		<-(cdist/2)-b, -(cdist*cos(pi/6))+h>,
		<-(cdist/2)+b, -(cdist*cos(pi/6))-h>,
		<(cdist/2)-b, -(cdist*cos(pi/6))-h>,
		<(cdist/2)+b, -(cdist*cos(pi/6))+h>,
		<cdist,-blarg/2>,
		<cdist,blarg/2>
		texture { pigment { color rgb<1,1,1> } }
  	}
	#declare cdist=cdist-1;
	prism {
    		//linear_sweep
    		//linear_spline
    		-2, // sweep the following shape from here ...
    		0.5, // ... up through here
    		13, // the number of points making up the shape ...
		<cdist,blarg/2>,
		<(cdist/2)+b, (cdist*cos(pi/6))-h>,
		<(cdist/2)-b, (cdist*cos(pi/6))+h>,
		<-(cdist/2)+b, (cdist*cos(pi/6))+h>,
		<-(cdist/2)-b, (cdist*cos(pi/6))-h>,
		<-cdist,blarg/2>,<-cdist,-blarg/2>,
		<-(cdist/2)-b, -(cdist*cos(pi/6))+h>,
		<-(cdist/2)+b, -(cdist*cos(pi/6))-h>,
		<(cdist/2)-b, -(cdist*cos(pi/6))-h>,
		<(cdist/2)+b, -(cdist*cos(pi/6))+h>,
		<cdist,-blarg/2>,
		<cdist,blarg/2>
		texture { pigment { color rgb<1,1,1> } }
  	}
}

#declare calc_f =
	box {
		<dist_centro+bcomp + 1,-1,-blarg/2>,
		<dist_centro+bcomp + 2,0,blarg/2>
		texture { pigment { color rgb<1,1,1> } }
	}

#declare nblocos = 6;
#declare nb = 0;
#while (nb<nblocos)
union {
object {calc_f}
//object {calcada}
object {gramado}
object {bloco}

#declare njanelas = 8;
#declare nj=0;
#while (nj < njanelas)
	object {janela
		translate<(nj *2*jlarg)+jlarg,0,-jlarg/5>
	}
	#declare nj = nj + 1;
#end

object{ jacima 
	translate <jlarg,balt-jlarg,-jlarg/5> 
	}

#declare nj=0;
#while (nj < njanelas)
	object {janela
		translate<(nj *2*jlarg)+jlarg,0,jlarg/5+blarg>
	}
	#declare nj = nj + 1;
#end

object{ jacima 
	translate <jlarg,balt-jlarg,jlarg/5+blarg> 
	}

object {
	pacima
	translate <0,balt,0>
}


translate <dist_centro,0,-blarg/2>
rotate <0,nb*(360/nblocos),0>
}

object {corredor
	translate <0,0,-clarg/2>
	rotate <0,nb*(360/nblocos),0>
}

#declare nb = nb + 1;
#end

object { base_centro 
    	pigment {Firebrick}
}
object { base_topo 
	translate <0,balt,0>
    	pigment { color rgb<1,1,1>}

}
object { borda_topo
    	pigment { color rgb<1,1,1>}
}