rev |
line source |
nuclear@0
|
1 #ifndef GEOMOBJ_H_
|
nuclear@0
|
2 #define GEOMOBJ_H_
|
nuclear@0
|
3
|
nuclear@0
|
4 #include "vmath/vmath.h"
|
nuclear@0
|
5
|
nuclear@15
|
6 namespace goatgfx {
|
nuclear@15
|
7
|
nuclear@0
|
8 class GeomObject;
|
nuclear@0
|
9
|
nuclear@0
|
10 struct HitPoint {
|
nuclear@0
|
11 float dist; //< parametric distance along the ray
|
nuclear@0
|
12 Vector3 pos; //< position of intersection (orig + dir * dist)
|
nuclear@0
|
13 Vector3 normal; //< normal at the point of intersection
|
nuclear@0
|
14 const void *obj; //< pointer to the intersected object
|
nuclear@0
|
15 };
|
nuclear@0
|
16
|
nuclear@0
|
17 class GeomObject {
|
nuclear@0
|
18 public:
|
nuclear@0
|
19 virtual ~GeomObject();
|
nuclear@0
|
20
|
nuclear@0
|
21 virtual void set_union(const GeomObject *obj1, const GeomObject *obj2) = 0;
|
nuclear@0
|
22 virtual void set_intersection(const GeomObject *obj1, const GeomObject *obj2) = 0;
|
nuclear@0
|
23
|
nuclear@23
|
24 virtual bool contains(const Vector3 &pt) const = 0;
|
nuclear@0
|
25 virtual bool intersect(const Ray &ray, HitPoint *hit = 0) const = 0;
|
nuclear@0
|
26 };
|
nuclear@0
|
27
|
nuclear@0
|
28 class Sphere : public GeomObject {
|
nuclear@0
|
29 public:
|
nuclear@0
|
30 Vector3 center;
|
nuclear@0
|
31 float radius;
|
nuclear@0
|
32
|
nuclear@0
|
33 Sphere();
|
nuclear@0
|
34 Sphere(const Vector3 ¢er, float radius);
|
nuclear@0
|
35
|
nuclear@0
|
36 void set_union(const GeomObject *obj1, const GeomObject *obj2);
|
nuclear@0
|
37 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
|
nuclear@0
|
38
|
nuclear@23
|
39 bool contains(const Vector3 &pt) const;
|
nuclear@0
|
40 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
|
nuclear@0
|
41 };
|
nuclear@0
|
42
|
nuclear@0
|
43 class AABox : public GeomObject {
|
nuclear@0
|
44 public:
|
nuclear@0
|
45 Vector3 min, max;
|
nuclear@0
|
46
|
nuclear@0
|
47 AABox();
|
nuclear@0
|
48 AABox(const Vector3 &min, const Vector3 &max);
|
nuclear@0
|
49
|
nuclear@0
|
50 void set_union(const GeomObject *obj1, const GeomObject *obj2);
|
nuclear@0
|
51 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
|
nuclear@0
|
52
|
nuclear@23
|
53 bool contains(const Vector3 &pt) const;
|
nuclear@0
|
54 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
|
nuclear@0
|
55 };
|
nuclear@0
|
56
|
nuclear@0
|
57 class Plane : public GeomObject {
|
nuclear@0
|
58 public:
|
nuclear@0
|
59 Vector3 pt, normal;
|
nuclear@0
|
60
|
nuclear@0
|
61 Plane();
|
nuclear@0
|
62 Plane(const Vector3 &pt, const Vector3 &normal);
|
nuclear@0
|
63 Plane(const Vector3 &p1, const Vector3 &p2, const Vector3 &p3);
|
nuclear@0
|
64 Plane(const Vector3 &normal, float dist);
|
nuclear@0
|
65
|
nuclear@0
|
66 void set_union(const GeomObject *obj1, const GeomObject *obj2);
|
nuclear@0
|
67 void set_intersection(const GeomObject *obj1, const GeomObject *obj2);
|
nuclear@0
|
68
|
nuclear@23
|
69 bool contains(const Vector3 &pt) const;
|
nuclear@0
|
70 bool intersect(const Ray &ray, HitPoint *hit = 0) const;
|
nuclear@0
|
71 };
|
nuclear@0
|
72
|
nuclear@15
|
73 } // namespace goatgfx
|
nuclear@15
|
74
|
nuclear@0
|
75 #endif // GEOMOBJ_H_
|