-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
77 lines (62 loc) · 2.4 KB
/
main.cpp
File metadata and controls
77 lines (62 loc) · 2.4 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include <iostream>
#include <iomanip>
#include "GeometricObject/geometricobject.hpp"
#include "ViewPlane/viewplane.hpp"
#include "Colour/colour.hpp"
#include "World/world.hpp"
#include "Material/material.hpp"
#include "Lights/lights.hpp"
#include "Sampler/sampler.hpp"
void World::build(){
const int height = 600;
const int width = 600;
Sphere* s_ptr = new Sphere(maths::Point3D( 0, 85, -50 ), 100.0f);
s_ptr->SetColour(colours::RED);
s_ptr->setMaterial(std::make_shared<Reflective>
(0.7f, 0.3f, colours::RED, 0.5f, colours::WHITE, 50.0f,
colours::WHITE, .8f));
add_obj(s_ptr);
s_ptr = new Sphere(maths::Point3D( 95, -85 , -100 ), 100.0f);
s_ptr->SetColour(Colour(colours::BLUE));
s_ptr->setMaterial(std::make_shared<Reflective>
(0.7f, 0.3f, colours::BLUE, 0.5f, colours::WHITE, 50.0f,
colours::WHITE, .8f));
add_obj(s_ptr);
s_ptr = new Sphere(maths::Point3D( -95, -85, -100 ), 100.0f);
s_ptr->SetColour(colours::LIME_GREEN);
s_ptr->setMaterial(std::make_shared<Reflective>
(0.7f, 0.3f, colours::LIME_GREEN, 0.5f, colours::WHITE, 50.0f,
colours::WHITE, .8f));
add_obj(s_ptr);
s_ptr = new Sphere(maths::Point3D( 0, 0, 0), 10000.0f);
s_ptr->SetColour(colours::LIME_GREEN);
s_ptr->setMaterial(std::make_shared<Matte>(1.0f, 0.4f, colours::LIGHT_BLUE));
add_obj(s_ptr);
Plane* p_ptr = new Plane(maths::Point3D{ 0, -200, 0 }, maths::Vector{ 0,1,0 }, Colour{ 1,1,1 });
p_ptr->setMaterial(std::make_shared<Matte>(0.50f, 0.4f, colours::GREY));
add_obj(p_ptr);
tracer_ptr = new MultipuleObj(this);
background_colour = Colour(1.0f, 1.0f, 1.0f);
vp.SetResolution(width, height);
vp.SetMaxDepth(1);
amb_light_ptr = new Ambient();
amb_light_ptr->setColour({ 1, 1, 1 });
amb_light_ptr->scaleRadiance(1.0f);
lights.push_back(
std::make_shared<PointLight>(PointLight{ {0, 300, 300} }));
lights[0]->setColour({ 1, 1, 1 });
lights[0]->scaleRadiance(1.5f);
vp.set_sampler(new Regular(16, 83));
PinHole* pinhole_ptr = new PinHole;
pinhole_ptr->set_eye(maths::Point3D{ 0,150,600 });
pinhole_ptr->set_lookat(maths::Point3D{ 0,0,0 });
pinhole_ptr->set_view_distance(500.0f);
pinhole_ptr->set_up(maths::Vector{ 0,1,0 });
pinhole_ptr->compute_uvw();
set_camera(pinhole_ptr);
}
int main(){
World w;
w.build();
w.camera_ptr->render_scene("out_pinhole.bmp", w, 64, false);
}