| ||
400x400; AR=1 | 400x400; AR=2 | 400x200; AR=2 |
triangles <r> <g> <b> <texture-name_s> <kd> <ks> <n_i> <kr> <gl> <kt> <n1> <tr> <radius> <number of vertices, n> <number of faces, m> x1 y1 z1 x2 y2 z2 ... xn yn zn v11 v12 v13 v21 v22 v23 ... vm1 vm2 vm3See the sample tetrahedron, cone, and cuboid
make lab5 input.txt convert output.ppm output.jpg display
Read in the triangle command and, besides recording radius, color, and the illumination parameters, make the following lists:
vertex_list[face_list[i*3]] vertex_list[face_list[i*3+1]] vertex_list[face_list[i*3+2]]
For each vertex, i vertex_normal[i] = (0,0,0) For each face, j For each vertex k of face j vertex_normal[k] += face_normal[j] For each vertex, i normalize vertex_normal[i]
a = 0.5*|(P-V1)x(V2-V1)| b = 0.5*|(P-V2)x(V3-V2)| c = 0.5*|(P-V3)x(V1-V3)|
object_space_normal = (a*NV3 + b*NV1 + c*NV2)/(a+b+c)