-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdemo.cpp
67 lines (50 loc) · 1.33 KB
/
demo.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
#include <iostream>
#include <sstream>
#include <opencv2/opencv.hpp>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "Scene/Scene.h"
#include "Accelerate/Accelerate.h"
#include "Camera/Camera.h"
#include "PathTracing/PathTracing.h"
using namespace std;
using namespace cv;
#define SCREEN_WIDTH 800
#define SCREEN_HEIGHT 800
#define FOV 70
int main( int argc, char** argv )
{
int ssp = 10;
if( argc >= 3 )
ssp = std::atoi( argv[2] );
Scene scene( argv[1] );
std::shared_ptr<Object> tree = KdTree::buildTree( scene.getMeshes() );
Camera camera( SCREEN_WIDTH, SCREEN_HEIGHT, FOV );
PathTracing tracer;
// ball
float tx = 0;
float ty = 4.6;
float tz = 13.5;
// wall
//float tx = 1.5;
//float ty = 5.464;
//float tz = 16;
//cornell
//float tx = -0.01;
//float ty = 0.79495;
//float tz = 2.5;
glm::mat4x4 t;
t = glm::translate( t, glm::vec3( tx, ty, tz) );
camera.transform( t );
//camera.showPosition();
//camera.setPosition( tree );
//camera.showPosition();
auto img = tracer.render( tree, camera, ssp );
//imshow( "Result", img );
//waitKey( 0 );
stringstream ss;
ss << argv[1] << "_" << ssp << ".jpg";
cout << ss.str() << endl;
imwrite( ss.str(), img );
return 0;
}