4 #include <gmath/gmath.h>
16 float dist; // parametric distance along the ray
17 Vec3 pos; // position of intersection (orig + dir * dist)
18 Vec3 normal; // normal at the point of intersection
20 const GeomObject *obj; // pointer to the intersected geom-object
21 void *data; // place to hang extra data
26 virtual ~GeomObject();
27 virtual GeomObjectType get_type() const = 0;
29 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
30 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
32 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
33 virtual bool contains(const Vec3 &pt) const = 0;
35 virtual float distance(const Vec3 &v) const = 0;
38 class Sphere : public GeomObject {
44 Sphere(const Vec3 ¢er, float radius);
46 GeomObjectType get_type() const;
48 void set_union(const GeomObject *obj1, const GeomObject *obj2);
49 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
51 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
52 bool contains(const Vec3 &pt) const;
54 float distance(const Vec3 &v) const;
57 class AABox : public GeomObject {
62 AABox(const Vec3 &min, const Vec3 &max);
64 GeomObjectType get_type() const;
66 void set_union(const GeomObject *obj1, const GeomObject *obj2);
67 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
69 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
70 bool contains(const Vec3 &pt) const;
72 float distance(const Vec3 &v) const;
75 class Plane : public GeomObject {
80 Plane(const Vec3 &pt, const Vec3 &normal);
81 Plane(const Vec3 &p1, const Vec3 &p2, const Vec3 &p3);
82 Plane(const Vec3 &normal, float dist);
84 GeomObjectType get_type() const;
86 void set_union(const GeomObject *obj1, const GeomObject *obj2);
87 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
89 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
90 bool contains(const Vec3 &pt) const;
92 float distance(const Vec3 &v) const;