// Last edited on 2024-05-01 20:02:37 by stolfi #macro retalho_barra(p,q,r,txg) // Cria uma barra de {p} para {q} com raio {r}; omite se {p} muito perto de {q}. #if ((r > 0) & (vlength(p - q) > 0.01*r)) cylinder{p,q,r texture{txg}} #end #end #macro retalho (p, rad, txr) // Cria um retalho de Bezier com pontos de controle {p[0..3,0..3]} // com textura{tx} dada. Se {rad} é positivo, // o retalho também mostra a grade de pontos de controle, // com barras de raio {rad} e textura branca. Se {rad} é zero ou negativo, // a grade não aparece. // O retalho será subdividio em {nsub} sub-retalhos em cada eixo. // Valores razoáveis de {nsub} são 3 a 5. #local nsub = 5; #local txg = texture{ pigment{ color rgb < 1.000, 0.900, 0.500 > } finish{ diffuse 0.5 ambient 0.5 } } union{ #local r = rad; // Raio das varetas. #local R = 2*r; // Raio das bolas. // O retalho propriamente dito: bicubic_patch{ type 1 u_steps nsub v_steps nsub p[3][0],p[3][1],p[3][2],p[3][3], p[2][0],p[2][1],p[2][2],p[2][3], p[1][0],p[1][1],p[1][2],p[1][3], p[0][0],p[0][1],p[0][2],p[0][3] texture {txr} } #if (rad > 0) // Bolas da grade de controle sphere{p[0][0],R texture{txg}} sphere{p[0][1],R texture{txg}} sphere{p[0][2],R texture{txg}} sphere{p[0][3],R texture{txg}} sphere{p[1][0],R texture{txg}} sphere{p[1][1],R texture{txg}} sphere{p[1][2],R texture{txg}} sphere{p[1][3],R texture{txg}} sphere{p[2][0],R texture{txg}} sphere{p[2][1],R texture{txg}} sphere{p[2][2],R texture{txg}} sphere{p[2][3],R texture{txg}} sphere{p[3][0],R texture{txg}} sphere{p[3][1],R texture{txg}} sphere{p[3][2],R texture{txg}} sphere{p[3][3],R texture{txg}} // Barras da grade de controle retalho_barra(p[0][0],p[0][1],r,txg) retalho_barra(p[0][1],p[0][2],r,txg) retalho_barra(p[0][2],p[0][3],r,txg) retalho_barra(p[0][0],p[1][0],r,txg) retalho_barra(p[0][1],p[1][1],r,txg) retalho_barra(p[0][2],p[1][2],r,txg) retalho_barra(p[0][3],p[1][3],r,txg) retalho_barra(p[1][0],p[1][1],r,txg) retalho_barra(p[1][1],p[1][2],r,txg) retalho_barra(p[1][2],p[1][3],r,txg) retalho_barra(p[1][0],p[2][0],r,txg) retalho_barra(p[1][1],p[2][1],r,txg) retalho_barra(p[1][2],p[2][2],r,txg) retalho_barra(p[1][3],p[2][3],r,txg) retalho_barra(p[2][0],p[2][1],r,txg) retalho_barra(p[2][1],p[2][2],r,txg) retalho_barra(p[2][2],p[2][3],r,txg) retalho_barra(p[2][0],p[3][0],r,txg) retalho_barra(p[2][1],p[3][1],r,txg) retalho_barra(p[2][2],p[3][2],r,txg) retalho_barra(p[2][3],p[3][3],r,txg) retalho_barra(p[3][0],p[3][1],r,txg) retalho_barra(p[3][1],p[3][2],r,txg) retalho_barra(p[3][2],p[3][3],r,txg) #else sphere{ p[0][0], 0 texture{ txg } } #end } #end