-
Notifications
You must be signed in to change notification settings - Fork 1
/
GeometricObject.cpp
62 lines (48 loc) · 1.22 KB
/
GeometricObject.cpp
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
#include "Constants.h"
#include "Material.h"
#include "GeometricObject.h"
GeometricObject::GeometricObject(void)
: material_ptr(NULL)
{temp_color.r = 1;
temp_color.g = 1;
temp_color.b = 1;}
GeometricObject::GeometricObject(const GeometricObject& object) {
if(object.material_ptr)
material_ptr = object.material_ptr -> clone();
else material_ptr = NULL;
temp_color.r = object.temp_color.r;
temp_color.g = object.temp_color.g;
temp_color.b = object.temp_color.b;
}
GeometricObject& GeometricObject::operator= (const GeometricObject& rhs) {
if (this == &rhs)
return (*this);
if(material_ptr) {
delete material_ptr;
material_ptr = NULL;
}
if(rhs.material_ptr)
material_ptr = rhs.material_ptr -> clone();
temp_color.r = rhs.temp_color.r;
temp_color.g = rhs.temp_color.g;
temp_color.b = rhs.temp_color.b;
return(*this);
}
GeometricObject::~GeometricObject(void) {
if(material_ptr) {
delete material_ptr;
material_ptr = NULL;
}
}
void GeometricObject::set_material(Material* mPtr) {
material_ptr = mPtr;
}
void GeometricObject::set_color(float r, float g, float b)
{
temp_color.r = r;
temp_color.g = g;
temp_color.b = b;
}
bool GeometricObject::shadow_hit(const Ray& ray, float& tmin) const {
return(false);
}