-
Notifications
You must be signed in to change notification settings - Fork 0
/
Box.h
56 lines (46 loc) · 1.16 KB
/
Box.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#ifndef Box_h
#define Box_h
#include "Primitive.h"
#include "Animation.h"
#include "Point.h"
#include <map>
class Ray;
struct PointPair;
class Box : public Primitive {
public:
Box(Material* material,
Animation<Point>& min,
Animation<Point>& max);
virtual ~Box();
virtual void getBounds(BoundingBox& bbox, const RenderContext&) const;
virtual void intersect(HitRecord& hit, const RenderContext& context, const Ray& ray) const;
virtual void normal(Vector& normal, const RenderContext& context,
const Point& hitpos, const Ray& ray, const HitRecord& hit) const;
virtual void preprocess(int maxTime);
protected:
Animation<Point> min;
Animation<Point> max;
private:
std::vector<PointPair> _pairs;
Vector n;
};
struct PointPair
{
PointPair() {}
PointPair(const Point& a, const Point& b)
{
pair[0] = a;
pair[1] = b;
}
const Point& operator[](int i) const
{
return pair[i];
}
/*Point operator[](int i) const
{
return pair[i];
}*/
private:
Point pair[2];
};
#endif