-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSurface.cpp
More file actions
51 lines (40 loc) · 1.45 KB
/
Copy pathSurface.cpp
File metadata and controls
51 lines (40 loc) · 1.45 KB
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
//
// Created by Jiang Kairong on 3/7/18.
//
#include "Surface.h"
Surface::Surface(const ColorRGB32f &colorAmbient, const ColorRGB32f &colorDiffuse, const ColorRGB32f &colorSpecular,
double phongExponent) : colorAmbient(colorAmbient), colorDiffuse(colorDiffuse),
colorSpecular(colorSpecular), phongExponent(phongExponent) {}
const ColorRGB32f &Surface::getColorAmbient() const {
return colorAmbient;
}
void Surface::setColorAmbient(const ColorRGB32f &colorAmbient) {
Surface::colorAmbient = colorAmbient;
}
const ColorRGB32f &Surface::getColorDiffuse() const {
return colorDiffuse;
}
void Surface::setColorDiffuse(const ColorRGB32f &colorDiffuse) {
Surface::colorDiffuse = colorDiffuse;
}
const ColorRGB32f &Surface::getColorSpecular() const {
return colorSpecular;
}
void Surface::setColorSpecular(const ColorRGB32f &colorSpecular) {
Surface::colorSpecular = colorSpecular;
}
double Surface::getPhongExponent() const {
return phongExponent;
}
void Surface::setPhongExponent(double phongExponent) {
Surface::phongExponent = phongExponent;
}
bool Surface::updateIntersectInfo(IntersectionInfo &info, const Ray &ray, double t) {
auto hitPoint = ray.getPoint(t);
if (info.hitObject == nullptr || (info.hitObject != nullptr && ((hitPoint - ray.getS()).norm() < (info.hitPoint - ray.getS()).norm()))) {
info.hitObject = this;
info.hitPoint = hitPoint;
return true;
}
return false;
}