#include "colors.inc" #include "textures.inc" #declare texturaPorta = texture { pigment { White filter 0.5} } #declare texturaJanelaAcesa = texture { pigment { Yellow } } #declare texturaJanelaApagada = texture { pigment { Black } } #declare texturaPredio = texture { pigment { Orange } } #declare texturaRua = texture { pigment { White } } #declare r = 6; #declare s = 4; #declare n = 6; #declare p = 6; #declare q = 8; #declare g = seed(pi*8) camera { location <80,30,-160> look_at <100,30,40> angle 60 } light_source { <80,100,-80> White } light_source { <180,20,-30> White } // janela 2x2 com cantos em (0,0,0) e (2,2,-0.2) #declare janela = box { <0,0,-0.2> <2,2,0> } // porta 4x3 com cantos em <0,0,0> e <4,3,-0.2> #declare porta = box { <0,0,-0.2> <4,3,2> texture { texturaPorta } } // andar sem janelas ou portas #declare bloco = difference { box { <0,0,0> <4*r,4,4*s> } box { <0.2,0.1,-0.2> <4*r-0.2,3.9,-4*s+0.2> } texture { texturaPredio } } // terreo #declare terreo = union { difference { object { bloco } box { // buraco para porta <2*r-2,0,0> <2*r+2,3,-0.3> } } object { porta translate <2*r-2,0,0> } } // andar -- com base no plano XZ #declare andar = union { difference { object { bloco } // uniao de todos os buracos para janelas union { #declare i = 1; #while (i <= r) box { <1+4*(i-1), 1, -0.3> <3+4*(i-1), 3, 0 > } #declare i = i + 1; #end #declare i = 1; #while (i <= s) box { < 0, 1, 1+2*(i-1)> <0.3, 3, 3+2*(i-1)> } box { <4*r , 1, 1+2*(i-1)> <4*r-0.3, 3, 3+2*(i-1)> } #declare i = i + 1; #end } } // acrescentar janelas #declare i = 1; #while (i <= r) object { janela #if (rand(g) < 0.75) texture { texturaJanelaAcesa } #else texture { texturaJanelaApagada } #end translate <1+4*(i-1),1,0> } #declare i = i + 1; #end #declare i = 1; #while (i <= s) object { janela rotate <0,90,0> translate <0.2, 1, 1+2*(i-1)> } object { janela rotate <0,90,0> translate <4*r-0.2,1,1+2*(i-1)> } #declare i = i + 1; #end } // predio #declare predio = union { object { terreo } #declare i = 1; #while (i <= n) object { andar translate <0,4*i,0> } #declare i = i + 1; #end } // cidade // por enquanto os predios sao todos iguais #declare cidade = union { // ruas plane { y, 0 texture { texturaRua } } //fundo plane { z, 1000 texture { Starfield } } // predios #declare i = 1; #while (i <= p) #declare j = 1; #while (j <= q) object { union { object { terreo } #declare a = 1; #declare n = int(rand(g)*10+3); // numero de andares aleatorio #while (a <= n) object { andar translate <0,4*a,0> } #declare a = a + 1; #end } translate <5*r*(i-1),0,5*r*(j-1)> } #declare j = j + 1; #end #declare i = i + 1; #end } object { cidade } sphere { <180,80,500> 10 pigment { Yellow } } light_source { <180,80,500> White*30 }