-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSceneObject.h
62 lines (57 loc) · 2.05 KB
/
SceneObject.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
/*--------------------------------------------------------------
* COSC363 Ray Tracer
* CSSE, University of Canterbury.
*
* The SceneObject class
* This is a generic type for storing objects in the scene.
* Being an abstract class, this class cannot be instantiated.
* Sphere, Plane etc, must be defined as subclasses of SceneObject
* and provide implementations for the virtual functions
* intersect() and normal().
-----------------------------------------------------------------*/
#ifndef H_SOBJECT
#define H_SOBJECT
#include <glm/glm.hpp>
class SceneObject
{
protected:
glm::vec3 color_ = glm::vec3(1); //material color
bool refl_ = false; //reflectivity: true/false
bool refr_ = false; //refractivity: true/false
bool spec_ = true; //specularity: true/false
bool tran_ = false; //transparency: true/false
bool _light = false; //light source: true/false
float reflc_ = 0.8; //coefficient of reflection
float refrc_ = 0.8; //coefficient of refraction
float tranc_ = 0.8; //coefficient of transparency
float refri_ = 1.0; //refractive index
float shin_ = 50.0; //shininess
public:
SceneObject() {}
virtual float intersect(glm::vec3 p0, glm::vec3 dir) = 0;
virtual glm::vec3 normal(glm::vec3 pos) = 0;
virtual ~SceneObject() {}
glm::vec3 lighting(glm::vec3 lightPos, glm::vec3 viewVec, glm::vec3 hit);
void setColor(glm::vec3 col);
void setReflectivity(bool flag);
void setReflectivity(bool flag, float refl_coeff);
void setRefractivity(bool flag);
void setRefractivity(bool flag, float refr_coeff, float refr_indx);
void setShininess(float shininess);
void setSpecularity(bool flag);
void setTransparency(bool flag);
void setLight(bool flag);
void setTransparency(bool flag, float tran_coeff);
glm::vec3 getColor();
float getReflectionCoeff();
float getRefractionCoeff();
float getTransparencyCoeff();
float getRefractiveIndex();
float getShininess();
bool isReflective();
bool isRefractive();
bool isSpecular();
bool isTransparent();
bool isLight();
};
#endif