home *** CD-ROM | disk | FTP | other *** search
- /*
- * proto.h -- function prototypes
- */
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <math.h>
- #include <assert.h>
-
- /* miscellaneous routines */
- PUBLIC void transform_ray(struct ray *r, object *o);
- PUBLIC void close_input(void);
- PUBLIC void raytrace(char *fname);
- PUBLIC void readfile(char *fname);
- PUBLIC void set_input(char *fname);
- PUBLIC void abort_trace(int);
-
- /* device dep. code */
- PUBLIC void check_abort(void);
- PUBLIC void init_machine(void);
- PUBLIC void initialize(void);
- PUBLIC void timer_start(void);
- PUBLIC long timer_stop(void);
-
- /* errors */
- PUBLIC void internal_error(char *module, int line);
- PUBLIC void warning(char *format,...);
- PUBLIC void errormsg(char *format,...);
- PUBLIC void alloc_err(char *s);
-
- /* stats */
- PUBLIC void start_stats(void);
- PUBLIC void set_defaults(void);
- PUBLIC void print_all_shape_stats(char *format, object *p);
- PUBLIC void print_image_map(struct image_map *p);
-
- /* debug */
- PUBLIC unsigned long memory_left(void);
- PUBLIC void print_v(char *s, vector v);
- PUBLIC void print_matrix(matrix c);
- PUBLIC void print_poly(spoly *p);
- PUBLIC void print_queue(dqueue * root);
- PUBLIC void print_c(char *s, color c);
-
-
- /* colors. */
- PUBLIC void scale_color(color *c, double fact);
- PUBLIC color color_add(color a, color b);
- PUBLIC color color_mul(color a, color b);
- PUBLIC color scolorproduct(double fact, color c);
- PUBLIC color color_scaled(color *c, double fact);
- PUBLIC void copy_color(color *dst, color *src);
- PUBLIC color normcol(color col);
- PUBLIC double color_length(color c);
- PUBLIC color *get_new_color(void);
- PUBLIC void free_color(color *c);
-
- /*
- * inline vector operations and other macros
- */
- #include "macro.h"
- #include "vector.h"
-
- /* math routines */
- PUBLIC int sturm_solve_rt_poly(spoly *thepoly, double *roots, bool chkall);
- PUBLIC int solve_rt_poly(spoly *thepoly, double *roots, bool chkall);
- PUBLIC double poly_eval(register double x, int ord, double *coef);
- PUBLIC double degtorad(double deg);
- PUBLIC double radtodeg(double rad);
- PUBLIC double frand(void);
- PUBLIC double rand1(void);
- PUBLIC double Gauss_rand(void);
- PUBLIC void torotv(vector *v);
- PUBLIC bool isvnull(vector a);
- PUBLIC void copy_vector(vector *dst, vector *src);
- PUBLIC void update_min_and_max(vector *min, vector *max, vector point);
- PUBLIC void do_box_bound(vector *bmin, vector *bmax, matrix inv_trans, vector p1, vector p2);
- PUBLIC double safe_arctangent(double a, double b);
-
- /* matrices */
- PUBLIC vector transform_normal(matrix A, vector n);
- PUBLIC void split_inv_trans(matrix A, vector *trans, vector *scal, matrix rot);
- PUBLIC void copy_matrix(matrix dst, matrix src);
- PUBLIC void rotate_matrix(matrix m, vector v);
- PUBLIC void mmproduct(matrix product, matrix left, matrix right);
- PUBLIC void transpose_matrix(matrix tr, matrix org);
- PUBLIC vector mvproduct(matrix A, vector x);
- PUBLIC vector transform_direction(matrix A, vector x);
- PUBLIC void invert_trans(matrix out, matrix in);
- PUBLIC void make_rotation_matrix(matrix m, vector v);
-
- PUBLIC void null_matrix(matrix m);
- PUBLIC void unit_matrix(matrix m);
- PUBLIC void inv_rotate_matrix(matrix m, vector r);
- PUBLIC void scale_matrix(matrix m, vector s);
- PUBLIC void inv_scale_matrix(matrix m, vector s);
- PUBLIC void translate_matrix(matrix m, vector t);
- PUBLIC void inv_translate_matrix(matrix m, vector t);
-
-
- /* the real tracing stuff */
- PUBLIC color shade(struct intersect i, struct ray r, int n, double imp);
- PUBLIC color bgcolor(struct ray *r);
- PUBLIC color trace(struct ray r, int n, double imp);
- PUBLIC color trace_a_ray(struct ray r, int n);
- PUBLIC struct intersect intersect(struct ray r);
- PUBLIC struct ray sample_ray(struct ray r, double theta);
- PUBLIC bool shadow_test(struct ray r, double ldistance, object *light, int recursion);
-
- /* depth queue routines */
- PUBLIC void add_to_queue(dqueue * root, dqueue q_ent);
- PUBLIC dqueue *get_new_queue(void);
- PUBLIC void free_queue(dqueue * root);
- PUBLIC void print_queue(dqueue * root);
-
- /*
- * intersection routines; global so they can be used for special bounding
- * shapes
- */
-
- PUBLIC int intersect_rawbox(vector p1, vector p2, struct ray *r, double *params);
- PUBLIC bool intersect_object(dqueue * globalq, object *o, struct ray *r, int flags);
- PUBLIC int intersect_sphere(vector center, double rsq, struct ray *r, double *hits);
-
- /* precompute_xxx. They compute constants in the xxx_data structure */
- PUBLIC void precompute_object_list(object *o);
- PUBLIC void precompute_object(object *o);
-
- /* polygons */
- PUBLIC void add_vertex_to_polygon(object *o, vector vert);
-
- /* the get_new_xxx routines. They alloc xxx, and initialize it */
- PUBLIC double *get_new_float(void);
- PUBLIC matrix *get_new_matrix(void);
-
- /* get_new_xxx_object */
- PUBLIC object *get_new_disc_object(void);
- PUBLIC object *get_new_smooth_triangle_object(void);
- PUBLIC object *get_new_triangle_object(void);
- PUBLIC object *get_new_extrusion_object(void);
- PUBLIC object *make_cylinder_object(vector p1, vector p2, double rad);
- PUBLIC object *get_new_torus_object(void);
- PUBLIC object *get_new_object(void);
- PUBLIC object *get_new_superq_object(void);
- PUBLIC object *get_new_sphere_object(void);
- PUBLIC object *get_new_quadric_object(void);
- PUBLIC object *get_new_plane_object(void);
- PUBLIC object *get_new_light_object(void);
- PUBLIC object *get_new_box_object(void);
- PUBLIC object *get_new_CSGinter_object(void);
- PUBLIC object *get_new_CSGunion_object(void);
- PUBLIC object *get_new_algebraic_object(void);
- PUBLIC object *get_new_polygon_object(void);
-
- /* free_xxx routines. They free xxx, and xxx's sub-data */
- PUBLIC void free_float(double *f);
-
- /* vectors */
- PUBLIC void rotate_vector(vector *v, matrix rotmat);
- PUBLIC void free_vector(vector *v);
- PUBLIC vector *get_new_vector(void);
-
- /* polynomials */
- PUBLIC void poly_neg(spoly *dst, spoly *src);
- PUBLIC void poly_multiply(spoly *dest, spoly *p1, spoly *p2);
- PUBLIC void poly_power(spoly *dst, int exponent, spoly *src);
- PUBLIC void poly_copy(spoly *dst, spoly *src);
- PUBLIC void poly_clean(spoly *p);
- PUBLIC void poly_add(spoly *dst, spoly *p1, spoly *p2);
- PUBLIC void poly_scalmult(spoly *d, double fact);
- PUBLIC void poly_sub(spoly *dst, spoly *p1, spoly *p2);
-
- /* cameras */
- PUBLIC double to_fov_coeff(struct camera *c, double angle);
- PUBLIC void point_camera(struct camera *c, vector lookat);
- PUBLIC struct camera *get_new_camera(void);
- PUBLIC void free_camera(struct camera *c);
- PUBLIC void translate_camera(struct camera *c, vector t);
- PUBLIC void rotate_camera(struct camera *c, matrix rotmat);
- PUBLIC void scale_camera(struct camera *c, vector s);
- PUBLIC void copy_camera(struct camera *dst, struct camera *src);
- PUBLIC void print_camera(struct camera *c);
-
- /* objects */
- PUBLIC void print_object_list(object *o);
- PUBLIC void print_object(object *obj);
- PUBLIC void free_object(object *op);
- PUBLIC void free_object_list(object *p);
- PUBLIC void rotate_object(object *op, matrix rotmat);
- PUBLIC void translate_object(object *op, vector t);
- PUBLIC void scale_object(object *op, vector s);
- PUBLIC void rotate_object_list(object *p, matrix rotmat);
- PUBLIC void scale_object_list(object *p, vector r);
- PUBLIC void translate_object_list(object *p, vector r);
- PUBLIC void speed_object_list(object *start, vector s);
- PUBLIC void copy_object(object *dst, object *src);
-
- PUBLIC void generic_scale_object(object *o, vector s);
- PUBLIC void generic_translate_object(object *o, vector t);
- PUBLIC void generic_rotate_object(object *o, matrix m);
-
- PUBLIC void append_to_object_list(object *o, object *toadd);
- PUBLIC void add_bounds_to_clip(object *o);
-
-
- /* textures! */
- PUBLIC void fill_texture(struct texture_data *tp, struct texture_data *orgtext, struct intersect i);
- PUBLIC struct texture_data *get_new_texture(void);
- PUBLIC void free_texture(struct texture_data *t);
- PUBLIC struct texture_data *copy_texture(struct texture_data *dst, struct texture_data *src);
- PUBLIC void translate_texture(struct texture_data *t, vector v);
- PUBLIC void scale_texture(struct texture_data *t, vector s);
- PUBLIC void rotate_texture(struct texture_data *t, matrix rotmat);
- PUBLIC void print_texture(struct texture_data *tx);
-
- /* imagemaps */
- PUBLIC struct pixel_data *get_TGA_pixels(char *fn);
- PUBLIC struct pixel_data *get_GIF_pixels(char *fn);
- PUBLIC color get_image_map_color(struct image_map *p, struct intersect i);
- PUBLIC struct image_map *get_new_image_map(void);
- PUBLIC void copy_image_map(struct image_map *dst, struct image_map *src);
- PUBLIC void inverse_spheremap(double *u, double *v, vector x);
- PUBLIC void inverse_planemap(double *u, double *v, vector x);
- PUBLIC void inverse_torusmap(double *u, double *v, vector x);
- PUBLIC void inverse_cylindermap(double *u, double *v, vector x);
- PUBLIC void load_gif(struct pixel_data *image, FILE * f);
- PUBLIC void free_image_map(struct image_map *p);
-
- /* composites */
- PUBLIC object *get_new_composite_object(void);
- PUBLIC void speed_composite(object *o, vector spd);
- PUBLIC void add_to_composite(object *c, object *o);
- PUBLIC void add_to_CSG(object *c, object *o);
-
- /* lights */
- PUBLIC color light_color(struct light_data *l, vector a);
- PUBLIC void make_light_list(object *o);
- PUBLIC void print_light_list(void);
-