#include "colors.inc" #include "shapes.inc" #include "camlight.inc" #include "eixos.inc" #include "retalho-simples.inc" #declare component_color_red = texture { pigment { color rgb <0.7, 0.12, 0.12> } finish { diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #declare component_color_green = texture { pigment { color rgb <0.7, 0.7, 0.12> } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } #macro retalhos_base(rows, columns) #local ret = array[rows][columns]; #for (i, 0, rows-1, 1) #for (j, 0, columns-1, 1) #declare ret[i][j] = array[4][4]; #for (ii, 0, 4-1, 1) #for (jj, 0, 4-1, 1) #declare ret[i][j][ii][jj] = ; #end #end #end #end ret #end #macro set(m, retalho, coord, trns) #declare m[retalho.x][retalho.y][coord.x][coord.y] = m[retalho.x][retalho.y][coord.x][coord.y] + trns; #end #macro emenda_retalhos(r, r0, r1) //mesma coluna -> emenda lateral #if (r0.y = r1.y) #declare r[r0.x][r0.y][3][0] = (r[r0.x][r0.y][2][0] + r[r1.x][r1.y][1][0]) / 2; #declare r[r0.x][r0.y][3][1] = (r[r0.x][r0.y][2][1] + r[r1.x][r1.y][1][1]) / 2; #declare r[r0.x][r0.y][3][2] = (r[r0.x][r0.y][2][2] + r[r1.x][r1.y][1][2]) / 2; #declare r[r0.x][r0.y][3][3] = (r[r0.x][r0.y][2][3] + r[r1.x][r1.y][1][3]) / 2; #declare r[r1.x][r1.y][0][0] = r[r0.x][r0.y][3][0]; #declare r[r1.x][r1.y][0][1] = r[r0.x][r0.y][3][1]; #declare r[r1.x][r1.y][0][2] = r[r0.x][r0.y][3][2]; #declare r[r1.x][r1.y][0][3] = r[r0.x][r0.y][3][3]; #end //mesma linha -> emenda frontal #if (r0.x = r1.x) #declare r[r0.x][r0.y][0][3] = (r[r0.x][r0.y][0][2] + r[r1.x][r1.y][0][1]) / 2; #declare r[r0.x][r0.y][1][3] = (r[r0.x][r0.y][1][2] + r[r1.x][r1.y][1][1]) / 2; #declare r[r0.x][r0.y][2][3] = (r[r0.x][r0.y][2][2] + r[r1.x][r1.y][2][1]) / 2; #declare r[r0.x][r0.y][3][3] = (r[r0.x][r0.y][3][2] + r[r1.x][r1.y][3][1]) / 2; #declare r[r1.x][r1.y][0][0] = r[r0.x][r0.y][0][3]; #declare r[r1.x][r1.y][1][0] = r[r0.x][r0.y][1][3]; #declare r[r1.x][r1.y][2][0] = r[r0.x][r0.y][2][3]; #declare r[r1.x][r1.y][3][0] = r[r0.x][r0.y][3][3]; #end #end #macro emenda_suave_todos_retalhos(r) //laterais #for (i, 0, NL-1-1, 1) #for (j, 0, NC-1, 1) emenda_retalhos(r, , ) #end #end //frontais #for (j, 0, NC-1-1, 1) #for (i, 0, NL-1, 1) emenda_retalhos(r, , ) #end #end #end #macro carroceria() #declare NL = 4; #declare NC = 6; #declare retalhos = retalhos_base(NL, NC); //modifica retalhos-base set(retalhos, <0, 0>, <2, 0>, <0, 0, 2>); set(retalhos, <1, 0>, <1, 0>, <0, 0, 2>); set(retalhos, <0, 0>, <2, 1>, <2, 1, 2>); set(retalhos, <1, 2>, <1, 2>, <3, 3, 3>); set(retalhos, <3, 4>, <2, 2>, <1, 2, 3>); set(retalhos, <2, 2>, <1, 1>, <1, 3, 4>); set(retalhos, <1, 1>, <2, 2>, <0, 2, 4>); set(retalhos, <2, 5>, <2, 1>, <2, 1, 6>); set(retalhos, <1, 3>, <1, 2>, <1, 4, 2>); set(retalhos, <1, 4>, <2, 1>, <1, 4, 2>); set(retalhos, <3, 2>, <2, 1>, <2, 5, 2>); set(retalhos, <1, 3>, <1, 1>, <1, 2, 1>); set(retalhos, <0, 5>, <2, 1>, <0, 2, 3>); set(retalhos, <1, 2>, <2, 2>, <0, 0, 3>); set(retalhos, <1, 2>, <2, 1>, <0, 0, 3>); emenda_suave_todos_retalhos(retalhos) union { #for (i, 0, NL-1, 1) #for (j, 0, NC-1, 1) #local bw = mod(i+j, 2); object { retalho( retalhos[i][j], -1, component_color_green, texture { pigment { color rgb } finish{ diffuse 0.8 ambient 0.1 specular 0.4 roughness 0.5 } } ) } #end #end } #end // SCENE #declare center = <5.00, 10.00, 0.00>; #declare scene_radius = 20.0; #declare camera_direction = <-5, -5, 5>; #declare camera_distance = 5 * scene_radius; #declare light_intensity = 0.1; camlight( center, scene_radius, camera_direction, camera_distance, z, light_intensity ) background { color rgb <0.4, 0.4, 0.4> } light_source { <0,0,4> 0.5 } object { carroceria() }