#include "colors.inc" #include "shapes.inc" #include "camlight.inc" #include "eixos.inc" #include "retalho-simples.inc" #declare center = <0.00, 0.00, 0.00>; #declare scene_radius = 10; #declare camera_direction = <1, 0, 1>; #declare camera_distance = 5 * scene_radius; #declare light_intensity = 0.2; camlight( center, scene_radius, camera_direction, camera_distance, z, light_intensity ) background { color rgb <0.7, 0.7, 0.7> } #declare txr_green = texture { pigment { color Green } finish { specular 0.4 roughness 0.3 } } #declare txr_blue = texture { pigment { color Blue } finish { specular 0.4 roughness 0.3 } } #declare txr_red = texture { pigment { color Red } } #declare die = seed(1153); #macro patch(x0, y0) #local points = array[4][4]; #for (i, 0, 3, 1) #for (j, 0, 3, 1) #local zz = int(-2 + 4 * rand(die)); #declare points[i][j] = ; #end #end points #end #declare patch0 = patch(-4, -2); #declare patch1 = patch(-1, -2) #declare patch2 = patch(2, -2); #declare patch3 = patch(-4, 1); #declare patch4 = patch(-1, 1); #declare patch5 = patch(2, 1); #declare patches = array[2][3] { {patch0, patch1, patch2}, {patch3, patch4, patch5} } #macro join_patches1(points, row0, col0, row1, col1) #for (i, 0, 3, 1) #declare points[row0][col0][i][3] = (points[row0][col0][i][2] + points[row1][col1][i][1])/2; #declare points[row1][col1][i][0] = (points[row0][col0][i][2] + points[row1][col1][i][1])/2; #end #end #macro join_patches2(points, row0, col0, row1, col1) #for (i, 0, 3, 1) #declare points[row0][col0][3][i] = (points[row0][col0][2][i] + points[row1][col1][1][i])/2; #declare points[row1][col1][0][i] = (points[row0][col0][2][i] + points[row1][col1][1][i])/2; #end #end #macro bodywork(points, lines, columns) ///* #for (i, 0, lines - 1, 1) #for (j, 0, columns - 1, 1) #if (j < columns - 1) join_patches1(points, i, j + 1, i, j) #end #end #end //*/ ///* #for (j, 0, columns - 1, 1) #for (i, 0, lines - 1, 1) #if (i < lines - 1) join_patches2(points, i + 1, j, i, j) #end #end #end //*/ #for (i, 0, lines - 1, 1) #for (j, 0, columns - 1, 1) #if (mod(i, 2) = 0) #if (mod(j, 2) = 0) object { retalho(points[i][j], 0.0, txr_red, txr_green) } #else object { retalho(points[i][j], 0.0, txr_red, txr_blue) } #end #else #if (mod(j, 2) = 1) object { retalho(points[i][j], 0.0, txr_red, txr_green) } #else object { retalho(points[i][j], 0.0, txr_red, txr_blue) } #end #end #end #end #end bodywork(patches, 2, 3) light_source { <0, 0, 5>, 0.5 }