-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.cpp
More file actions
53 lines (42 loc) · 1.43 KB
/
main.cpp
File metadata and controls
53 lines (42 loc) · 1.43 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
#include <vector>
#include <iostream>
#include <cstring>
#include "./libraries/bitmap_image.hpp"
#include "./src/DisplayControl.h"
#include "./src/simpleRayTracing.h"
#include "./src/readObj.h"
using namespace std;
int main(int argc, char* argv[]) {
if (argc > 1) {
vector<vector<double>> vertices;
vector<vector<int>> flats;
vector<vector<double>> normals;
vector<double> minCoordinate(3, 0);
vector<double> maxCoordinate(3, 0);
char modelsPath[] = "./models/";
readObj(
strcat(modelsPath, argv[1]),
minCoordinate, maxCoordinate,
vertices, flats, normals
);
int angle = 0;
if (argv[3]) angle = atoi(argv[3]);
vector<int> rgb(3, 0);
if (argv[5]) rgb[0] = atoi(argv[5]);
if (argv[6]) rgb[1] = atoi(argv[6]);
if (argv[7]) rgb[2] = atoi(argv[7]);
DisplayControl *DC = new DisplayControl(
minCoordinate, maxCoordinate, angle, rgb
);
bitmap_image *image = new bitmap_image(DC->widthPx, DC->heightPx);
simpleRayTracing(
DC, minCoordinate, maxCoordinate, vertices, flats, normals, image
);
char picturesPath[] = "./pictures/";
strtok(argv[1], "."); strcat(argv[1], ".bmp");
image->save_image(strcat(picturesPath, argv[1]));
} else {
cout << "Invalid arguments" << endl;
}
return 0;
}