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