/* == main.c == */ /* == model.c == */ int dump_material( FILE *out, obj_t *obj); int dump_model( FILE *out, view_t *v, list_t *lst); int load_model( FILE *in, view_t *v, list_t *lst); int load_material( FILE *in, obj_t *obj); /* == sphere.c == */ /* dump_sphere.c */ int dump_sphere( FILE *out, obj_t *obj); /* Determine if a vector projected from location *base */ /* in direction *dir hits the sphere.. If so the return */ /* value is the distance from the base to the point of */ /* contact. */ double hits_sphere( double *base, double *dir, /* MUST be unit vector */ obj_t *obj); void norm_sphere( obj_t *obj); int load_sphere( FILE *in, list_t *lst, int objtype); /* == light.c == */ double hits_spot( double *base, double *dir, /* MUST be unit vector */ obj_t *obj); int load_light( FILE *in, list_t *lst, int objtype); /* == plane.c == */ int dump_plane( FILE *out, obj_t *obj); /* Return diffuse reflectivity */ int diffuse_plane( obj_t *obj, double diffuse[3]); /* Determine if a vector projected from location *base */ /* in direction *dir hits the plane.. If so the return */ /* value is the distance from the base to the point of */ /* contact. */ double hits_plane( double *base, double *dir, obj_t *obj); void norm_plane( obj_t *obj); int load_plane( FILE *in, list_t *lst, int objtype); /* == cyl.c == */ /* dump_cyl.c */ int dump_cyl( FILE *out, obj_t *obj); /* Determine if a vector projected from location *base */ /* in direction *dir hits the cyl.. If so the return */ /* value is the distance from the base to the point of */ /* contact. */ double hits_cyl( double *base, double *dir, obj_t *obj); void norm_cyl( obj_t *obj); int load_cyl( FILE *in, list_t *lst, int objtype); /* == ellipse.c == */ /* dump_ellipse.c */ int dump_ellipse( FILE *out, obj_t *obj); /* Determine if a vector projected from location *base */ /* in direction *dir hits the ellipse.. If so the return */ /* value is the distance from the base to the point of */ /* contact. */ double hits_ellipse( double *base, double *dir, obj_t *obj); void norm_ellipse( obj_t *obj); int load_ellipse( FILE *in, list_t *lst, int objtype); /* == raytrace.c == */ /* Given an [x,y] coordinate in pixel space find the */ /* world coordinate of the location at which it hits */ /* the virtual screen */ void map_pix_to_world( view_t *v, int x, int y, double *world); int light_visible( list_t *lst, /* List of all objects */ obj_t *hitobj, /* The object hit by the ray */ obj_t *lobj, /* a candidate light source */ double dist); void comp_diffuse( list_t *lst, obj_t *hitobj, double intensity[3]); /* This function traces a single ray and returns the composite */ /* intensity of the light it encounters */ void ray_trace( list_t *lst, double base[3], /* location of viewer or previous hit */ double dir[3], /* unit vector in direction of object */ double intensity[3], double total_dist, /* distance ray has traveled so far */ obj_t *last_hit); /* This function is the driver for the raytracing procedure */ void mk_image( view_t *view, list_t *lst); /* == veclib3d.c == */ void vl_idmat3( double mtx[3][3]); /* Scale a 3d vector */ void vl_scale3( double fact, double *v1, double *v2); void vl_reverse3( double *v1, double *v2); void vl_copy3( double *vin, double *vout); /* Find the inner product of two input vectors */ double vl_dot3( double *v1, /* Left input vector */ double *v2); /* Find the componentwise product of two vectors */ void vl_mult3( double *v1, /* Left input vector */ double *v2, /* Right input vector */ double *v3); /* Return length of a 3d vector */ double vl_length3( double *v1); /* Compute the difference of two vectors */ /* v3 = v2 - v1 */ void vl_diff3( double *v1, /* subtrahend */ double *v2, /* minuend */ double *v3); /* Compute the sum of two vectors */ void vl_sum3( double *v1, /* Left input vector */ double *v2, /* Right input vector */ double *v3); /* Construct a unit length vector in the required direction */ void vl_unitvec3( double *v1, /* Input vector */ double *v2); /* Compute the outer product of two input vectors */ void vl_cross3( double *v1, /* Left input vector */ double *v2, /* Right input vector */ double *v3); /* 3 x 3 matrix multiplier */ void vl_matmul3( double x[3][3], /* Left input matrix */ double y[3][3], /* Right input matrix */ double z[3][3]); /* n x n matrix transpose */ void vl_xpose3( double x[3][3], /* Left input matrix */ double z[3][3]); /* Print the contents of a transform matrix */ void vl_matprn3( char *label, double mat[3][3]); /* Print the contents of a vector */ void vl_vecprn3( char *label, double vec[3]); /* Create a matrix to rotate a vector around the y axis */ void vl_xzrot3( double matrix[3][3], /* Matrix to be filled in */ double theta); /* Create a matrix to rotate a vector around the x axis */ void vl_yzrot3( double matrix[3][3], /* Matrix to be filled in */ double theta); /* Create a matrix to rotate a vector around the z axis */ void vl_xyrot3( double matrix[3][3], /* Matrix to be filled in */ double theta); /* Perform a linear transform in four dimensional space */ /* By applying a 3 x 3 matrix to a 3 x 1 column vector */ void vl_xform3d( double y[3][3], /* Xform matrix */ double x[3], /* Input vector */ double z[3]); /* Perform a linear transform in four dimensional space */ /* By applying a 3 x 3 matrix to a 3 x 1 column vector */ void vl_xfnadd3( double y[3][3], /* Xform matrix */ double x[3], /* Input vector */ double z[3]); void vl_reflect3( double *in, double *norm, double *out);