-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathObject.h
64 lines (48 loc) · 1.2 KB
/
Object.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
#ifndef OBJECT_H
#define OBJECT_H
#include "Matrix.h"
#include "Ray.h"
#include <vector>
#include <utility>
#include <memory>
// #include <opencv2/opencv.hpp>
using namespace std;
#define eps 0.00001
#define c_limit 0.01
// #define s_pow 4
Ray make_ray(float a, float b, float c, float d, float e, float f);
float dot(Ray &p, Ray &q);
void add_vecs(vector<float> &a1, vector<float> &a2);
void mult_const(vector<float> &a, float f);
class Object{
public:
vector<float> k_ads;
float kr, kt, eta;
float s_pow;
vector<float> color;
Matrix t;
Object();
void set_color(int r, int g, int b);
Ray reflected(Ray &r, Ray &n);
Ray refracted(Ray &r, Ray &n);
virtual Ray normal(Ray &r, pair<float, vector<float> > &pr) = 0;
virtual pair<float, vector<float> > intersection(Ray &r) = 0;
};
class Sphere : public Object {
public:
float radius;
pair<float, vector<float> > intersection(Ray &r);
Ray normal(Ray &r, pair<float, vector<float> > &pr);
};
class Triangle : public Object {
public:
vector<float> a;
vector<float> b;
vector<float> c;
vector<float> nml;
Triangle();
void Calc_Normal();
pair<float, vector<float> > intersection(Ray &r);
Ray normal(Ray &r, pair<float, vector<float> > &pr);
};
#endif