#include #include float v[128][3]; float vn[128][3]; float f[128][3]; /** Subtracts a from b and stores the result in c. */ void subtract(float a[3], float b[3], float c[3]) { //Fill this in } /** Computes the cross product of a and b, storing the result in c. */ void cross(float a[3], float b[3], float c[3]) { c[0] = a[1]*b[2]-a[2]*b[1]; c[1] = a[2]*b[0]-a[0]*b[2]; c[2] = a[0]*b[1]-a[1]*b[0]; } /** Sets the length of a vector to 1.0. */ void normalize(float a[3]) { float length = sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]); a[0] /= length; a[1] /= length; a[2] /= length; } /** Computes the normal of a triangle specified by vertices v1, v2, and v3, storing the normalized result in normal. */ void computeNormal(float v1[3], float v2[3], float v3[3], float normal[3]) { //Fill this in } int main() { //Read the vertices from input.obj into v and write them to output.obj //Read the faces from input.obj into f //For each face f compute its normal and store it in vn //Write vn to output.obj //Write f to output.obj return 0; }