-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmain.cpp
77 lines (56 loc) · 1.57 KB
/
main.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
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 <string>
#include <fstream>
#include <sstream>
#include <vector>
#include <cmath>
#include <random>
#include <limits>
#include <cstdlib>
#include "string_tools.h"
#include "math_tools.h"
#include "mesh.h"
#include "geometry.h"
#include "camera.h"
#include "time_tools.h"
#include "bvh.h"
#include "sampler.h"
#include "renderer.h"
#include "file_tools.h"
int main(int argc, char** argv)
{
if (argc != 4)
{
std::cerr << "Usage: " << argv[0] << " [filename] [image width] [spp]"<< std::endl;
return 1;
}
std::string filename = std::string(argv[1]);
Mesh mesh = read_obj(filename.c_str());
int width = std::atoi(argv[2]);
int height = width;
int spp = std::atoi(argv[3]);
//spp *= spp;
int path_depth = 5;
float fov = 39.3076f * pi / 180.0f;
//float fov = 60.0f * pi / 180.0f;
float3 origin(0.0f);
origin = float3(0.278f, 0.273f, -0.8f) * 1000.0f;
//origin = float3(0,0.1,0.1);
//origin = float3(-8,1,14);
//origin = float3(0.0f, 91.0f, -50.0f);
mat3f R(0.0f);
R(0,0) = -1.0f;
R(1,1) = 1.0f;
R(2,2) = -1.0f;
Camera camera(origin, R, fov);
Timer timer;
Renderer renderer(height, width, spp, path_depth);
renderer.set_mesh(mesh);
renderer.set_camera(camera);
std::cout << "done in " << timer.elapsed(1) * 1e-6 << "s." << std::endl;
renderer.render();
std::cout << timer.elapsed() / 1e6f << "s elapsed." << std::endl;
std::string out_file("out.ppm");
write_ppm(renderer.get_image(), height, width, out_file);
return 0;
}