// ====================================================================== // CORES E TEXTURAS background{ color rgb < 0.75, 0.2, 0.85 > } #declare tx_plastico = texture{ pigment{ color rgb < 0.90, 0.20, 0.20 > } finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } #declare tx_transparente = texture{ pigment{ color rgb < 0.10, 0.80, 1.00 > transmit 0.8} finish{ diffuse 0.8 ambient 0.1 specular 0.5 roughness 0.005 } } // ====================================================================== // DESCRI��O DA CENA #declare raio_nivel = 3; #declare tomate_base = sphere{ < 0.00, 0.00, 0.00 >, 0.5 texture{ tx_plastico } } #declare tomate_folha = box { <-0.5, -0.5, 0.5>, <0.5, 0.5, 0.65> // near lower left corner, far upper right corner texture{ tx_plastico } } #declare garrafa_agua_base = cylinder{ < +0.00, -0.00, -0.00 >, < +0.00, +0.00, +0.5 >, 0.2 texture{ tx_plastico } } #declare garrafa_agua_tampa = cone{ < 0, 0, 0.5 >, 0.2 < 0, 0, 0.8 >, 0.01 texture{ tx_plastico } } #declare garrafa_ketchup_base = box { <-0.5, -0.5, 0>, <0.5, 0.5, 1.2> texture{ tx_plastico } } #declare garrafa_ketchup_tampa = cylinder{ < +0.00, -0.00, 1.2 >, < +0.00, +0.00, 1.4 >, 0.4 texture{ tx_plastico } } #declare toco = cylinder{ < +0.00, -0.00, -0.00 >, < +0.00, +0.3, +0.0 >, 0.05 texture{ tx_plastico } } #macro gerar_garrafa_agua(pos_x,pos_y) union{ object{garrafa_agua_base} object{garrafa_agua_tampa} gerar_tocos(0.1, 0.65) translate } #end #macro gerar_tomate(pos_x,pos_y) union{ object{tomate_base} object{tomate_folha} gerar_tocos(0.5, 0.58) translate } #end #macro gerar_garrafa_ketchup(pos_x,pos_y) union{ object{garrafa_ketchup_base} object{garrafa_ketchup_tampa} gerar_tocos(0.3, 1.3) translate } #end #macro gerar_posicoes_pontas_tocos(raio, altura, pos_x, pos_y) #local posicoes_tocos = array[4]; #local comprimento_toco = 0.3; #local offset_toco = raio + comprimento_toco; #declare posicoes_tocos[0] = ; #declare posicoes_tocos[1] = ; #declare posicoes_tocos[2] = ; #declare posicoes_tocos[3] = ; posicoes_tocos #end #macro gerar_tocos(raio, altura) #local contador_rotacao = 0; union{ #while (contador_rotacao < 4) object{ toco translate <0,raio,altura> rotate (90 * contador_rotacao)*z } #declare contador_rotacao = contador_rotacao +1; #end } #end #macro interpola_reta(desired_t,t0,v0,t1,v1) #local ss = (desired_t-t0)/(t1-t0); #local vv = (1-ss)*v0+ss*v1; vv #end #macro testa_interpola_reta(p0, p1, n_bolas) #local contador_interpolacao = 0; union{ #while (contador_interpolacao < n_bolas) object{ sphere{ < 0.00, 0.00, 0.00 >, 0.2 texture{ tx_plastico } translate interpola_reta(contador_interpolacao, 0, p0, n_bolas,p1) } } #declare contador_interpolacao = contador_interpolacao+1; #end } #end #macro interpola_bezier(desired_t,ta,tb,v0,v1,v2,v3) #local v01 = interpola_reta(desired_t, ta, v0, tb, v1); #local v12 = interpola_reta(desired_t, ta, v1, tb, v2); #local v23 = interpola_reta(desired_t, ta, v2, tb, v3); #local v012 = interpola_reta(desired_t, ta, v01, tb, v12); #local v123 = interpola_reta(desired_t, ta, v12, tb, v23); #local v0123 = interpola_reta(desired_t, ta, v012, tb, v123); v0123 #end #macro testa_interpola_bezier(v0, v1, v2, v3, n_bolas) #local contador_interpolacao = 0; union{ #while (contador_interpolacao < n_bolas) object{ sphere{ < 0.00, 0.00, 0.00 >, 0.05 texture{ tx_plastico } translate interpola_bezier(contador_interpolacao, 0, n_bolas, v0, v1, v2, v3) } } #declare contador_interpolacao = contador_interpolacao+1; #end } #end // Aqui est� a cena, finalmente: //testa_interpola_reta(<0,0>, <0,5>, 6) gerar_tomate(0,-2) gerar_garrafa_ketchup(0,1) gerar_garrafa_agua(0,4) #declare toco_ketchup_teste1 = <0,1-0.3,1.3>; #declare toco_tomate_teste1 = <0,0.5+0.3-2,0.8>; #declare posicoes_pontas_tocos_tomate = gerar_posicoes_pontas_tocos(0.5, 0.58, 0, -2); #declare posicoes_pontas_tocos_ketchup = gerar_posicoes_pontas_tocos(0.3, 1.3, 0, 1); testa_interpola_bezier(posicoes_pontas_tocos_tomate[0], <1.5,0.3+0.3,1.3>, <-1.5,0.5+0.3-2,1.3>, posicoes_pontas_tocos_ketchup[1], 20) #include "camlight.inc" #declare centro_cena = < 0.00, 0.00, 0.00 >; #declare raio_cena = 6.0; #declare dir_camera = < 14.00, 7.00, 5.00 >; #declare dist_camera = 4*raio_cena; #declare intens_luz = 2.20; camlight(centro_cena, raio_cena, dir_camera, dist_camera , z, intens_luz)