-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRay.h
59 lines (51 loc) · 971 Bytes
/
Ray.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
57
58
59
#ifndef RAY_H
#define RAY_H
#include<glm/vec3.hpp>
#include <glm/glm.hpp>
#include<glm/gtx/vector_angle.hpp>
#include <glm/gtx/fast_square_root.hpp>
#include <glm/gtx/normal.hpp>
#include <glm/gtx/scalar_relational.hpp>
class Ray
{
public:
Ray()
{
setStart(glm::vec3(0.0f, 0.0f, 0.0f));
setDirection(glm::vec3(1.0f, 1.0f, 1.0f));
}
Ray(Ray& r)
{
setStart(r.getStart());
setDirection(r.getDirection());
}
Ray(glm::vec3 s, glm::vec3 dir)
{
setStart(s);
setDirection(dir);
}
Ray& operator=(Ray& r)
{
if(this != &r)
{
this->setStart(r.getStart());
this->setDirection(r.getDirection());
}
return *this;
}
void setStart(glm::vec3 s) {start = s;}
glm::vec3 getStart() {return start;}
void setDirection(glm::vec3 dir) {direction = dir;}
glm::vec3 getDirection()
{
return glm::normalize(direction);
}
glm::vec3 getDirectionNotNormalised()
{
return direction;
}
private:
glm::vec3 start;
glm::vec3 direction;
};
#endif