4 #include "gmath/gmath.h"
10 float dist; //< parametric distance along the ray
11 Vec3 pos; //< position of intersection (orig + dir * dist)
12 Vec3 normal; //< normal at the point of intersection
13 const void *obj; //< pointer to the intersected object
14 const SceneNode *node;
20 virtual ~GeomObject();
22 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
23 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
25 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
28 class Sphere : public GeomObject {
34 Sphere(const Vec3 ¢er, float radius);
36 void set_union(const GeomObject *obj1, const GeomObject *obj2);
37 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
39 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
42 class AABox : public GeomObject {
47 AABox(const Vec3 &min, const Vec3 &max);
49 void set_union(const GeomObject *obj1, const GeomObject *obj2);
50 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
52 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
55 class Plane : public GeomObject {
60 Plane(const Vec3 &pt, const Vec3 &normal);
61 Plane(const Vec3 &p1, const Vec3 &p2, const Vec3 &p3);
62 Plane(const Vec3 &normal, float dist);
64 void set_union(const GeomObject *obj1, const GeomObject *obj2);
65 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
67 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
70 float sphere_distance(const Vec3 ¢, float rad, const Vec3 &pt);
71 float capsule_distance(const Vec3 &a, float ra, const Vec3 &b, float rb, const Vec3 &pt);