-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScene.h
68 lines (55 loc) · 1.58 KB
/
Scene.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
65
66
67
68
#pragma once
namespace Tmpl8 {
class Scene
{
public:
Scene(Surface* screen);
Camera* camera;
void render(int row);
void increaseAccumulator();
void resetAccumulator();
int addPrimitive(Primitive* primitive);
void addLightSource(LightSource* lightSource);
int loadModel(const char *filename, Material* material, vec3 translationVector = vec3(0));
void translateModel(int id, vec3 vector);
void loadSkydome(const char* fileName);
int getPrimitivesCount();
void clear();
private:
Surface* screen;
vec4 accumulator[SCRHEIGHT * SCRWIDTH];
int accumulatorCounter;
float inversedAccumulatorCounter;
std::mt19937 randomNumbersGenerator;
TopBVH* topBHV;
std::vector<BVH*> BVHs;
bool topBVHExists;
std::vector<Primitive*> primitives;
std::vector<LightSource*> lightSources;
HDRBitmap* skydome;
bool skydomeLoaded;
struct Model
{
Model::Model(int id, int startIndex, int endIndex)
{
this->id = id;
this->startIndex = startIndex;
this->endIndex = endIndex;
}
int id, startIndex, endIndex;
};
std::vector<Model*> models;
vec4 sample(Ray* ray, bool isLastPrimitiveSpecular = false);
vec4 sampleSkydome(Ray* ray);
vec4 illuminate(Ray* ray);
Ray* computeDiffuseReflectionRay(Ray* ray);
Ray* computeReflectionRay(Ray* ray);
Ray* computeRefractionRay(Ray* ray);
float calculateRefractionProbability(Ray* ray);
void intersectPrimitives(Ray* ray, bool isShadowRay = false);
void intersectLightSources(Ray* ray);
Pixel convertColorToPixel(vec4 color);
void buildTopBVH();
int buildBVH(int startIndex, int endIndex);
};
}