-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathHit.h
More file actions
84 lines (69 loc) · 1.19 KB
/
Hit.h
File metadata and controls
84 lines (69 loc) · 1.19 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#ifndef HIT_H
#define HIT_H
#include <vecmath.h>
#include "Ray.h"
#include <float.h>
class Material;
class Hit
{
public:
// constructors
Hit()
{
material = NULL;
t = FLT_MAX;
hasTex=false;
}
Hit( float _t, Material* m, const Vector3f& n )
{
t = _t;
material = m;
normal = n;
hasTex=false;
}
Hit( const Hit& h )
{
t = h.t;
material = h.material;
normal = h.normal;
hasTex=h.hasTex;
}
// destructor
~Hit()
{
}
float getT() const
{
return t;
}
Material* getMaterial() const
{
return material;
}
const Vector3f& getNormal() const
{
return normal;
}
void set( float _t, Material* m, const Vector3f& n )
{
t = _t;
material = m;
normal = n;
}
void setTexCoord(const Vector2f & coord){
texCoord = coord;
hasTex = true;
}
bool hasTex;
Vector2f texCoord;
private:
float t;
Material* material;
Vector3f normal;
};
inline ostream& operator << ( ostream &os, const Hit& h)
{
os << "Hit <" << h.getT() << ", " << h.getNormal() << ">";
return os;
}
#endif // HIT_H