// MC930 - Exercicio 5 - Animacao do Trem da Alegria // 26/10/2004 // Pablo Augusto Verissimo - RA 002266 #include "colors.inc" #include "metals.inc" #include "stones.inc" #include "textures.inc" #include "skies.inc" // ====================================================================== // CÂMERA camera { location < 35,30,20 > // Posição do observador. right -1.00*x // Largura RELATIVA da imagem. up 0.75*y // Altura RELATIVA da imagem. sky z // Qual direção é "para cima"? look_at < 0.00, 0.00, 0.00 > // Para onde a câmera está apontando. } // Nota: os parâmetros "right" e "up" devem ter a mesma proporção // que os parâmetros ${WIDTH} e ${HEIGHT} no Makefile. // ====================================================================== // FONTES DE LUZ light_source { 10 * < +50.0, +30.0, +50.0 > // Posição da lâmpada. color rgb 1.2 * < 1.00, 1.00, 1.00 > // Intensidade e corda luz. } light_source { 10 * < +50.0, -10.0, +10.0 > // Posição da lâmpada. color rgb 0.8 * < 0.90, 0.70, 0.80 > // Intensidade e corda luz. } // ====================================================================== // DESCRIÇÃO DA CENA background{ color rgb < 0.9, 0.9, 0.9 > } #declare raio = 2.000; //vermelho #declare tinta_A = texture { pigment { color rgb < 1, 0, 0 > } finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 } } //meio amarelo #declare tinta_B = texture { pigment { color rgb < 1, 0.9, 0 > } finish { diffuse 0.5 specular 0.5 roughness 0.005 ambient 0.1 } } //azul transparente #declare cor_cristal = <0.5, 0.5, 0.75 >; #declare tx_cristal = texture { finish { ambient 0.1 diffuse 0.1 reflection 0.30 specular 1 roughness 0.001 } pigment { color cor_cristal filter 1 } } #declare cor_espelho = <0.4, 0.4, 0.4 >; #declare tx_espelho = texture { pigment { rgb cor_espelho } finish { ambient 0.05 diffuse 0.05 reflection cor_espelho specular 0.20 roughness 0.05 } } #declare cor_ouro = <1, 0.9, 0>; #declare tx_ouro = texture { pigment { rgb cor_ouro } finish { ambient 0.05 diffuse 0.05 reflection cor_ouro specular 0.20 roughness 0.05 } } #declare cor_ourot = < 1, 0.9, 0 >; #declare tx_ourot = texture { finish { ambient 0.1 diffuse 0.1 reflection 0.25 specular 1 roughness 0.001 } pigment { color cor_ourot filter 1 } } //predio cilindrico //#declare predio = //union { //#declare i2 = 0; //#while (i2 < 4) //#declare i1 = 0; //difference { //cylinder { //<0,0,3*i2>,<0,0,3*i2+3>,5 //translate <0,0,-3> //#if ( mod(i2,2) = 0) //texture { tinta_A } //#else //texture { tinta_B } //#end //} //#declare i = 0; //#declare j = seed(i2*12345); //#declare r = 0.6; //#while (i1 < 20) //#declare janela = //#if (rand(j) < 0.5) //box { <-r,-r,-r>, } //object { janela translate <0, 4.8, 3*i2-1.2> rotate i*18*z texture {tx_cristal} } //#declare i = i+1; //#else //sphere { <0,0,0>,r } //object { janela translate <0, 4.8, 3*i2-1.2> rotate i*18*z texture {tx_cristal} } //#declare i = i+1; //#end //#declare i1 = i1+1; //#end //#declare i2 = i2+1; //} //#end //} #declare vigas = union { #declare i = 0; #while (i < 90) #declare r = 0.1; #declare umaviga = box { <-30*r,-r,-r>,<5*r,r,r> } object { umaviga translate <14, 0, 0.6> rotate 4*i*z } #declare i = i+1; #end texture {Dark_Wood} } #declare trilho = union { lathe { 4,<11.6,0>,<11.6,0.6>,<11.8,0.6>,<11.8,0> texture {tx_espelho} } lathe { 4,<13.8,0>,<13.8,0.6>,<14,0.6>,<14,0> texture {tx_espelho} } } #declare locomotiva = union { #declare i = 0; #while (i < 4) //rodas cylinder { <-1.6,0,0>,<1.6,0,0>,0.5 translate <12.5,2+i,1.1> texture {tinta_B} } #declare i = i+1; #end cylinder { <0,-1,1>,<0,2,1>,1 translate <12.5,0,1.2> texture {tinta_A} } //chamineh box { <0,-0.5,0.5>,<0.5,0,4> translate <12.5,0,1.2> texture {tinta_A} } box { <-1.5,1,0>,<1.5,6,2> translate <12.5,0,1.2> texture {tinta_A} } //ligacao box { <-0.3,0.3,0>,<0.3,5,0.4> translate <12.5,4,1.3> rotate 5*z texture {tinta_A} } difference { box { <-1.5,3.5,0>,<1.5,6,4> translate <12.5,0,1.2> texture {tinta_A} } box { <-1.2,-3,2.4>,<1.2,8,3.7> translate <12.5,0,1.2> texture {tinta_A} } //janelas #declare i4 = 0; #while (i4 < 2) box { <-2,3.5,2.5>,<2,4.2,3.5> translate <12.5,0.4+i4,1.2> texture {tx_cristal} } #declare i4 = i4+1; #end } } #declare vagoes = union { #declare i1 = 0; #while (i1 < 8) #declare umvagao = union { #declare i2 = 0; #while (i2 < 4) //rodas cylinder { <-1.6,0,0>,<1.6,0,0>,0.5 translate <12.5,-1.4+i2,1.1> texture {tinta_B} } #declare i2 = i2+1; #end //vagao difference { box { <-1.5,-2.5,0>,<1.5,2.5,3> translate <12.5,0,1.2> texture {tinta_A} } //janelas #declare i3 = 0; //#declare i4 = seed(i3*555); #while (i3 < 4) //#declare j = seed(i3*12345*i4); //#if (rand(j) < 0.5) box { <-2,-2,1.6>,<2,-1.5,2.5> translate <12.5,0.4+i3,1.2> texture {tx_cristal} } //#else //cylinder { //<0,0,-3>,<0,0,3>,0.4 //rotate 90*y translate <12.5,0.4+i3,1.2> //texture {tx_cristal} //} //#end #declare i3 = i3+1; #end } //ligacao dos vagoes #if (i1 != 7) box { <-0.3,0.3,0>,<0.3,5,0.4> translate <12.5,0,1.3> texture {tinta_A} } #end } object { umvagao rotate 60*z rotate 30*i1*z } #declare i1 = i1+1; #end texture {tinta_B} } //plane { z,0 //texture { //pigment { brick <1,1,1>,<0,0,0> } //finish { ambient 0.2 diffuse 0.9 } //scale 0.2 //} //} #declare pilar = cylinder { <0,0,0.2>,<0,0,5.8>,0.6 pigment { Silver } } #declare estacao = union { difference { box { <-6,0,0>,<6,6,6> rotate 90*z pigment { Gray } } box { <-7,-1,1.5>,<7,7,5> rotate 90*z pigment { Gray } } } box { <-6.4,0,6>,<6,6,6.1> rotate 90*z pigment { Red } } object {pilar translate <-1,-3.5,0.2>} object {pilar translate <-1,3.5,0.2>} translate <20,0,0> } plane { z,0 texture {T_Grnt24} } //fazendo a animacao da cena atraves da variavel clock // variavel clock varia de 0 ateh 1 //saindo devagar da estacao #if (clock < 0.20) #declare posicao = 750*clock*clock; #else //um pouco mais rapido ateh clock = 0.8 #if (clock < 0.80) #declare posicao = -70+500*clock; //devagar de novo ao chegar na estacao #else #declare posicao = 360-750*(1-clock)*(1-clock); #end #end //**************************** //Aqui está a cena, finalmente: //**************************** object {trilho rotate 90*x translate <0,0,0.15>} object {vigas} union { object {vagoes} object {locomotiva translate <0,-3,0> rotate 30*z} rotate -posicao*z } object {estacao}