-
Notifications
You must be signed in to change notification settings - Fork 0
/
Primitive.hpp
executable file
·67 lines (56 loc) · 1.53 KB
/
Primitive.hpp
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
#pragma once
#include <glm/glm.hpp>
#include "Ray.hpp"
class Primitive {
public:
virtual ~Primitive();
virtual bool intersect( Ray &ray, float closet, float fart, Intersection &intersection);
};
class Sphere : public Primitive {
Primitive * primative;
public:
Sphere();
virtual ~Sphere();
virtual bool intersect( Ray &ray, float closet, float fart, Intersection &intersection) override;
};
class Cube : public Primitive {
Primitive * primative;
public:
Cube();
virtual ~Cube();
virtual bool intersect( Ray &ray, float closet, float fart, Intersection &intersection) override;
};
class NonhierSphere : public Primitive {
public:
NonhierSphere(const glm::vec3& pos, double radius)
: position(pos), rad(radius)
{
}
virtual ~NonhierSphere();
virtual bool intersect( Ray &ray, float closet, float fart, Intersection &intersection) override;
private:
glm::vec3 position;
double rad;
};
class NonhierBox : public Primitive {
public:
NonhierBox(const glm::vec3& pos, double size);
virtual ~NonhierBox();
virtual bool intersect( Ray &ray, float closet, float fart, Intersection &intersection) override;
private:
glm::vec3 vertices[8];
glm::vec3 position;
double m_size;
Primitive * m_mesh;
};
class NonhierCone : public Primitive {
public:
NonhierCone(const glm::vec3& pos, double size);
virtual ~NonhierCone();
virtual bool intersect( Ray &ray, float closet, float fart, Intersection &intersection) override;
private:
glm::vec3 position;
double m_size;
glm::vec3 vertices[4];
Primitive * m_mesh;
};