struct erb_surf;
struct erb_ray;
struct erb_hit;
+struct erb_aabb;
typedef int (*erb_intersect_func)(struct erb_surf *surf, struct erb_ray *ray, struct erb_hit *hit);
typedef void (*erb_sample_func)(struct erb_surf *surf, cgm_vec3 *pos);
+typedef void (*erb_bbox_func)(struct erb_surf *surf, struct erb_aabb *bb);
+
+struct erb_aabb {
+ cgm_vec3 pos, sz;
+};
struct erb_node {
struct erb_node *par; /* parent node */
struct erb_surf {
struct erb_node *node; /* transformation node for this surface */
+ struct erb_aabb bbox; /* local space bounding box */
+ int bbox_valid;
+
erb_intersect_func isect; /* intersection routine */
erb_sample_func sample; /* random sample generation */
+ erb_bbox_func calc_bbox; /* bounds calculation */
+
+ long data[1]; /* type chosen to match worst case alignment req. */
};
struct erb_ray {
int erb_init(void);
void erb_cleanup(void);
+/* transformation nodes */
+struct erb_node *erb_node(void);
+void erb_free_node(struct erb_node *n);
+int erb_node_addchild(struct erb_node *n, struct erb_node *c);
+int erb_node_rmchild(struct erb_node *n, struct erb_node *c);
+int erb_node_addsurf(struct erb_node *n, struct erb_surf *s);
+int erb_node_rmsurf(struct erb_node *n, struct erb_surf *s);
+
+void erb_node_setxform(struct erb_node *n, float *mat);
+void erb_node_mulxform(struct erb_node *n, float *mat);
+void erb_node_translate(struct erb_node *n, float x, float y, float z);
+/* TODO ... more ... */
+
+/* surfaces */
+struct erb_surf *erb_surface(int datasz);
+void erb_free_surface(struct erb_surf *surf);
+struct erb_surf *erb_surf_sphere(float rad);
+struct erb_surf *erb_surf_box(float xsz, float ysz, float zsz);
+
+/* utility functions */
+void erb_xform_ray(struct erb_ray *ray, float *mat);
+
#endif /* RENDLIB_H_ */