-
Notifications
You must be signed in to change notification settings - Fork 0
/
hit.h
42 lines (31 loc) · 832 Bytes
/
hit.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
/* File: hit.h; Mode: C++; Tab-width: 3; Author: Simon Flannery; */
#ifndef HIT_H
#define HIT_H
#include <float.h>
#include "math.h"
#include "ray.h"
class Material;
class Hit
{
public:
Hit(float t = FLT_MAX) : tmin(t), material(NULL) { }
float GetT() const { return tmin; }
Material* GetMaterial() const { return material; }
point3f GetIntersectionPoint() const { return intersection_point; }
vector3f GetNormal() const { return normal; }
void Set(float t, Material* m, const vector3f& n, const Ray& ray)
{
tmin = t;
material = m;
normal = n;
intersection_point = ray.PointAtParameter(tmin);
return;
}
protected:
private:
float tmin;
Material* material;
vector3f normal;
point3f intersection_point;
};
#endif