/************************************************* * *** MC930 - COMPUTAÇÃO GRÁFICA *** * * Laboratório 5: O Trem da Alegria Animado * Este projeto consiste no aperfeiçoamento do * projeto 4, fazendo um trem da alegria para * as eleições animado. * * Autor: Volnei dos Santos (RA 010075) * 26/Out/2004 ************************************************/ // ====================================================================== // CÂMERA camera { location 2.5*<20.00, 20.00, 10.00> // Posição do observador. right -1.50*x // Largura RELATIVA da imagem. up 1.00*y // Altura RELATIVA da imagem. sky z // O céu fica no eixo z. look_at <00.00, 00.00, 00.00> // Câmera aponta para origem. } // ====================================================================== // FONTES DE LUZ light_source { < 00.0, 50.0, 50.0> // Posição da lâmpada. color rgb 10*<1.00,1.00,1.00> // Intensidade e cor da luz. } light_source { <-20.0,20.0, 50.0> // Posição da lâmpada. color rgb 10*<1.00,1.00,1.00> // Intensidade e corda luz. } // ====================================================================== // DESCRIÇÃO DA CENA // Textura de ouro #declare ouro = texture { pigment { rgb < 1.00, 1.00, 0.60> } finish { ambient 0.05 diffuse 0.05 reflection < 1.00, 1.00, 0.60> specular 0.2 roughness 0.05 } } // Textura do aco do vagao #declare aco = texture { pigment { rgb < 1.0, 0.60, 0.60> } finish { diffuse 0.05 } } // Textura do branco de brasilia #declare bras = texture { pigment { rgb < 0.90, 0.90, 0.90> } finish { diffuse 0.05 } } // Textura dos vagoes coloridos #declare aco_1 = texture { pigment { rgb < 1.0, 0.0, 0.0> } finish { diffuse 0.05 } } #declare aco_2 = texture { pigment { rgb < 1.0, 1.00, 0.0> } finish { diffuse 0.05 } } // ====================================================================== // Vagao do trem #declare vagao = difference { // Corpo do vagao union { box { <3, -1, 0>, // Near lower left corner <-3, 1, 3> // Far upper right corner } cylinder { <3, 0, 3>, // Center of one end <-3, 0, 3>, // Center of other end 1.0 // Radius } // Colocará as rodas #declare i = 0; #while(i < 4) cylinder { <2 - 1.25*i, -1, -0.4>, // Center of one end <2 - 1.25*i, 1, -0.4>, // Center of other end 0.40 // Radius } #declare i = i + 1; #end } // Tira o vao entre as rodas box { <3, -0.8, -1>, // Near lower left corner <-3, 0.8, 0> // Far upper right corner } // Colocará as janelas #declare i = 0; #while(i < 4) box { <2.9 - i*1.5, -1.1, 1.5>, // Near lower left corner <1.6 - i*1.5, 1.1, 2.9> // Far upper right corner } #declare i = i + 1; #end // Interior do vagao box { <2.9, -0.9, 0.1>, // Near lower left corner <-2.9, 0.9, 3> // Far upper right corner } cylinder { <2.9, 0, 3>, // Center of one end <-2.9, 0, 3>, // Center of other end 0.90 // Radius } } // ====================================================================== // Locomotiva do trem #declare locomotiva = union { difference { object { vagao } box { <3.1, -1.1, 1>, // Near lower left corner <0, 1.1, 5> // Far upper right corner } } // Parte da frente cylinder { <3, 0, 1>, // Center of one end <0, 0, 1>, // Center of other end 1.0 // Radius } // Saida da fumaca cone { <2.5, 0, 1>, 0.0 // Center and radius of one end <2.5, 0, 3>, 0.4 // Center and radius of other end } // A fumaca #declare gerador = seed(12345); #declare i = 0; #while(i < 200) sphere { <2.5 + 0.04*i*0.4*rand(gerador), 0 + 0.04*i*0.4*rand(gerador), 3 + 2.5*rand(gerador)>, 0.05 texture { ouro } } #declare i = i + 1; #end } // ====================================================================== // Trilhos do Trem #declare raio = 30; #declare trilhos = difference { difference { cylinder { <0, raio, -1>, // Center of one end <0, raio, -0.9>, // Center of other end raio + 1 // Radius } cylinder { <0, raio, -1.1>, // Center of one end <0, raio, -0.8>, // Center of other end raio - 1 // Radius } } difference { cylinder { <0, raio, -1.1>, // Center of one end <0, raio, -0.8>, // Center of other end raio + 0.8 // Radius } cylinder { <0, raio, -1.1>, // Center of one end <0, raio, -0.8>, // Center of other end raio - 0.8 // Radius } } } // ====================================================================== // Estacao de Trem #declare estacao = union { box { <0.5, -0.5, -1>, // Near lower left corner <-0.5, 0.5, 10> // Far upper right corner texture { bras } translate -1*y } box { <0.5, -0.5, -1>, // Near lower left corner <-0.5, 0.5, 10> // Far upper right corner texture { bras } translate 1*y } difference { sphere { <5, 0, 10>, 10 texture { aco } } box { <100, -100, 0.5>, // Near lower left corner <-100, 100, 100> // Far upper right corner texture { bras } } } difference { sphere { <-7, 0, -10.3 >, 10 texture { bras } } } } // ====================================================================== // Desenho da cena, utilizando as figuras definidas // Fundo da cena background{ color rgb <0.75, 0.80, 1.0> } // Objetos union { object { trilhos } object { estacao translate -10*y } // Os vagoes #declare gerador = seed(12345); #declare i = 0; #declare qtd = 5 + 3*rand(gerador); #while(i < qtd) object { // Escolhe se será locomotiva ou vagão #if(i=0) locomotiva texture { aco } #else vagao #if(rand(gerador) < 0.5) texture { aco_1 } #else texture { aco_2 } #end #end // Calcula o quanto ele rotacionara (depende do vagao e do tempo) #declare rotacao = -(360 + 6.5)/raio; #if(clock < 0.2) // Até 45 graus, aceleracao positiva (S = at²/2) #declare mov = (2*45/(0.2*0.2))*(clock*clock)/2; #else #if(clock < 0.8) // Ate 315 graus, aceleracao 0 (S = 45 + vt) #declare mov = 45 + (270/0.6)*(clock - 0.2); #else // Ate 360 graus, aceleracao negativa (S = 315 + v0*t - at²/2) #declare mov = 315 + (270/0.6)*(clock - 0.8); #declare mov = mov + (-2*45/(0.2*0.2))*((clock - 0.8)*(clock - 0.8))/2; #end #end // Faz a rotacao (andar no trilho) translate raio*(-y) rotate (rotacao*i + mov)*z translate raio*y} #declare i = i + 1; #end } // Colocando um chão na cena plane { z, -0.9 pigment { rgb < 0.20, 0.50, 0.20> } finish { ambient 0.05 diffuse 0.2 specular 0.02 roughness 0.5 } }