4 #include <cgmath/cgmath.h>
12 typedef int (*erb_intersect_func)(struct erb_surf *surf, struct erb_ray *ray, struct erb_hit *hit);
13 typedef void (*erb_sample_func)(struct erb_surf *surf, cgm_vec3 *pos);
14 typedef void (*erb_bbox_func)(struct erb_surf *surf, struct erb_aabb *bb);
21 struct erb_node *par; /* parent node */
22 struct erb_node *clist; /* child nodes */
23 struct erb_surf *surflist; /* surfaces in this node */
24 float xform[16], inv_xform[16]; /* global transformation */
25 float node_xform[16], inv_node_xform[16]; /* local transformation */
29 struct erb_node *node; /* transformation node for this surface */
31 struct erb_aabb bbox; /* local space bounding box */
34 erb_intersect_func isect; /* intersection routine */
35 erb_sample_func sample; /* random sample generation */
36 erb_bbox_func calc_bbox; /* bounds calculation */
38 long data[1]; /* type chosen to match worst case alignment req. */
42 cgm_vec3 o, d; /* origin and direction */
43 float tmin, tmax; /* segment bounds */
44 float ior; /* IOR of the medium through which this ray travels */
45 float total_dist; /* travel distance accumulator */
50 struct erb_surf *surf;
54 void erb_cleanup(void);
56 /* transformation nodes */
57 struct erb_node *erb_node(void);
58 void erb_free_node(struct erb_node *n);
59 int erb_node_addchild(struct erb_node *n, struct erb_node *c);
60 int erb_node_rmchild(struct erb_node *n, struct erb_node *c);
61 int erb_node_addsurf(struct erb_node *n, struct erb_surf *s);
62 int erb_node_rmsurf(struct erb_node *n, struct erb_surf *s);
64 void erb_node_setxform(struct erb_node *n, float *mat);
65 void erb_node_mulxform(struct erb_node *n, float *mat);
66 void erb_node_translate(struct erb_node *n, float x, float y, float z);
67 /* TODO ... more ... */
70 struct erb_surf *erb_surface(int datasz);
71 void erb_free_surface(struct erb_surf *surf);
72 struct erb_surf *erb_surf_sphere(float rad);
73 struct erb_surf *erb_surf_box(float xsz, float ysz, float zsz);
75 /* utility functions */
76 void erb_xform_ray(struct erb_ray *ray, float *mat);
78 #endif /* RENDLIB_H_ */