-
Notifications
You must be signed in to change notification settings - Fork 0
/
drawable.h
71 lines (58 loc) · 1.75 KB
/
drawable.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
60
61
62
63
64
65
66
67
68
69
70
71
#pragma once
#include <QtCore>
#include <glm/glm.hpp>
// An abstract drawable
class Drawable
{
public:
enum class Type{
OPAQUE, REFLEXIVE, TRANSPARENT
};
Drawable(std::string newName = "");
std::string name;
static const glm::vec3 whiteColor;
static const glm::vec3 blackColor ;
float refractionIndice;
Type type;
public:
virtual bool hasIntercepted(glm::vec3 ray, glm::vec3 origin, glm::vec3 & touchPoint) const =0;
virtual glm::vec3 getNormal(glm::vec3 point) const = 0;
virtual glm::vec3 getDiffuseColor(glm::vec3 point) const = 0;
glm::vec3 position;
glm::vec3 diffuseColor;
glm::vec3 specularColor;
public:
~Drawable(){}
};
// A sphere is defined by its position and its radius
class Sphere : public Drawable
{
public:
Sphere(float radius, std::string newName = "");
~Sphere();
virtual bool hasIntercepted(glm::vec3 ray, glm::vec3 origin, glm::vec3 & touchPoint) const override;
virtual glm::vec3 getNormal(glm::vec3 point) const override;
virtual glm::vec3 getDiffuseColor(glm::vec3 point) const override;
float radius;
};
// A plane is defined by its position and 2 more points no colinears
class Plane : public Drawable
{
public:
Plane(std::string newName = "");
~Plane();
virtual bool hasIntercepted(glm::vec3 ray, glm::vec3 origin, glm::vec3 & touchPoint) const override;
virtual glm::vec3 getNormal(glm::vec3 point) const override;
virtual glm::vec3 getDiffuseColor(glm::vec3 point) const override;
glm::vec3 pointA;
glm::vec3 pointB;
};
class Chess : public Plane
{
public:
Chess(std::string newName = "") ;
float tileSize;
glm::vec3 getDiffuseColor(glm::vec3 point) const override;
glm::vec3 color1;
glm::vec3 color2;
};