-
Notifications
You must be signed in to change notification settings - Fork 0
/
Primitive.hpp
48 lines (41 loc) · 880 Bytes
/
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
#pragma once
#include <glm/glm.hpp>
class Primitive {
public:
virtual ~Primitive();
int m_type;
};
class Sphere : public Primitive {
public:
virtual ~Sphere();
};
class Cube : public Primitive {
public:
virtual ~Cube();
};
class NonhierSphere : public Primitive {
public:
NonhierSphere(const glm::vec3& pos, double radius)
: m_pos(pos), m_radius(radius)
{
m_type = 1;
}
virtual ~NonhierSphere();
bool hit(const glm::vec3 &ray,const glm::vec3 &eye,double &hit_point,glm::vec3 &normal);
private:
glm::vec3 m_pos;
double m_radius;
};
class NonhierBox : public Primitive {
public:
NonhierBox(const glm::vec3& pos, double size)
: m_pos(pos), m_size(size)
{
m_type = 2;
}
bool hit(const glm::vec3 &ray,const glm::vec3 &eye,double &hit_point, glm::vec3 &norm);
virtual ~NonhierBox();
private:
glm::vec3 m_pos;
double m_size;
};