-
Notifications
You must be signed in to change notification settings - Fork 2
/
Primitive.cpp
49 lines (40 loc) · 1.26 KB
/
Primitive.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
//
// Created by lazycal on 2017/6/11.
//
#include "Primitive.h"
int Primitive::cnt = 0;
void Primitive::input(const std::string &var, std::stringstream &fin) {
if ( var == "color=" ) fin >> color;
if ( var == "absor=" ) fin >> absor;
if ( var == "refl=" ) fin >> refl;
if ( var == "refr=" ) fin >> refr;
if ( var == "diff=" ) fin >> diff;
if ( var == "spec=" ) fin >> spec;
if ( var == "rindex=" ) fin >> rindex;
if ( var == "texture=" ) {
std::string file; fin >> file;
texture = imread(file);
assert(texture.data != NULL);
}
}
Primitive::Primitive() {
hashId = rand();
color = absor = Color();
refl = refr = diff = spec = 0;
rindex = 0;
id = cnt++;
}
Primitive::~Primitive() {
}
std::ostream &operator<<(std::ostream &os, const Primitive &primitive) {
os << "color: " << primitive.color << " absor: " << primitive.absor << " refl: " << primitive.refl << " refr: "
<< primitive.refr << " diff: " << primitive.diff << " spec: " << primitive.spec << " rindex: "
<< primitive.rindex << " id: " << primitive.id;
return os;
}
Color Primitive::getColor(const Vector3 &P) {
return color;
}
void Primitive::generateMeshes(std::vector<Vector3> &points, std::vector<int4> &meshes)
{
}