equal
deleted
inserted
replaced
13 #include "noise.h" |
13 #include "noise.h" |
14 |
14 |
15 #include "vector.h" |
15 #include "vector.h" |
16 |
16 |
17 using namespace std; |
17 using namespace std; |
|
18 |
|
19 /* axis-aligned bounding box */ |
|
20 class BBox |
|
21 { |
|
22 public: |
|
23 Vector3 L; |
|
24 Vector3 R; |
|
25 BBox(): L(), R() {}; |
|
26 }; |
18 |
27 |
19 class Ray |
28 class Ray |
20 { |
29 { |
21 public: |
30 public: |
22 Vector3 a, dir; |
31 Vector3 a, dir; |
82 // all intersections (only for CSG) |
91 // all intersections (only for CSG) |
83 virtual bool intersect_all(const Ray &ray, float dist, vector<float> &allts) = 0; |
92 virtual bool intersect_all(const Ray &ray, float dist, vector<float> &allts) = 0; |
84 |
93 |
85 // normal at point P |
94 // normal at point P |
86 virtual Vector3 normal(Vector3 &P) = 0; |
95 virtual Vector3 normal(Vector3 &P) = 0; |
|
96 |
|
97 virtual BBox get_bbox(); |
87 }; |
98 }; |
88 |
99 |
89 class Sphere: public Shape |
100 class Sphere: public Shape |
90 { |
101 { |
91 float sqr_radius; |
102 float sqr_radius; |
128 |
139 |
129 Triangle(const Vector3 &aA, const Vector3 &aB, const Vector3 &aC, Material *amaterial); |
140 Triangle(const Vector3 &aA, const Vector3 &aB, const Vector3 &aC, Material *amaterial); |
130 bool intersect(const Ray &ray, float &dist); |
141 bool intersect(const Ray &ray, float &dist); |
131 bool intersect_all(const Ray &ray, float dist, vector<float> &allts) {return false;}; |
142 bool intersect_all(const Ray &ray, float dist, vector<float> &allts) {return false;}; |
132 Vector3 normal(Vector3 &) { return N; }; |
143 Vector3 normal(Vector3 &) { return N; }; |
|
144 BBox get_bbox(); |
133 }; |
145 }; |
134 |
146 |
135 #endif |
147 #endif |