1
1
#include " PerspectiveGatherer.h"
2
2
3
- std::string renderAmbientOcclusion ()
4
- {
5
- return " " ;
6
- }
3
+ // std::string renderAmbientOcclusion()
4
+ // {
5
+ // // hardcode filename until options come out
6
+ // std::string component = "all.g";
7
+ // std::string pathToInput = "../db/";
8
+ // std::string fileInput = "moss.g";
9
+ // std::string pathToOutput = "../output/";
10
+ // std::string fileOutput = "moss.png";
11
+ // std::cout << "Processing file: " << fileInput << std::endl;
12
+
13
+ // // FIX security vulnerability
14
+ // std::string inputname = pathToInput + fileInput;
15
+ // std::string outputname = pathToOutput + fileOutput;
16
+
17
+ // std::ifstream file;
18
+ // file.open(outputname);
19
+ // if (file) {
20
+ // std::string rmFile = "rm " + outputname;
21
+ // auto result2 = system(rmFile.c_str());
22
+ // }
23
+ // file.close();
24
+ // // TODO Need to somehow decide what to render if there are multiple components.
25
+ // // Maybe let user choose which one to render e.g. pass in all.g?
26
+
27
+ // // EX: ../../../../../build/bin/rt -C 255/255/255 -s 1024 -c "set ambSamples=64" ../db/moss.g all.g
28
+ // std::string render = "../../../../../build/bin/rt -C 255/255/255 -s 1024 -c \"set ambSamples=64\" -o " + outputname + " " + inputname + " " + component;
29
+ // auto result2 = system(render.c_str());
30
+ // std::cout << "Successlly generated ambient occlusion file\n";
31
+ // return outputname;
32
+ // }
7
33
8
34
std::string renderPerspective (RenderingFace face)
9
35
{
10
- return " " ;
36
+ // hardcode filename until options come out
37
+ std::string component = " all.g" ;
38
+ std::string pathToInput = " ../db/" ;
39
+ std::string fileInput = " moss.g" ;
40
+ std::string pathToOutput = " ../output/" ;
41
+ std::string fileOutput = " moss" ;
42
+
43
+ // do directory traversal checks
44
+ if (fileOutput.find (" ../" ) != std::string::npos) {
45
+ std::cout << " ERROR: Output file name cannot contain ../\n " ;
46
+ return " " ;
47
+ }
48
+
49
+ std::cout << " Processing file: " << fileInput << std::endl;
50
+
51
+ // FIX security vulnerability
52
+ std::string inputname = pathToInput + fileInput;
53
+ std::string outputname = pathToOutput + fileOutput;
54
+ std::string render;
55
+
56
+ int a, e;
57
+ switch (face) {
58
+ case FRONT:
59
+ a = 0 , e = 0 ;
60
+ outputname += " _front.png" ;
61
+ render = " ../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string (a) + " -e " + std::to_string (e) + " -o " + outputname + " " + inputname + " " + component;
62
+ break ;
63
+ case RIGHT:
64
+ a = 90 , e = 0 ;
65
+ outputname += " _right.png" ;
66
+ render = " ../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string (a) + " -e " + std::to_string (e) + " -o " + outputname + " " + inputname + " " + component;
67
+ break ;
68
+ case BACK:
69
+ a = 180 , e = 0 ;
70
+ outputname += " _back.png" ;
71
+ render = " ../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string (a) + " -e " + std::to_string (e) + " -o " + outputname + " " + inputname + " " + component;
72
+ break ;
73
+ case LEFT:
74
+ a = 270 , e = 0 ;
75
+ outputname += " _left.png" ;
76
+ render = " ../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string (a) + " -e " + std::to_string (e) + " -o " + outputname + " " + inputname + " " + component;
77
+ break ;
78
+ case TOP:
79
+ a = 0 , e = 90 ; // may need to change "a"?
80
+ outputname += " _top.png" ;
81
+ render = " ../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string (a) + " -e " + std::to_string (e) + " -o " + outputname + " " + inputname + " " + component;
82
+ break ;
83
+ case BOTTOM:
84
+ a = 0 , e = 270 ;
85
+ outputname += " _bottom.png" ;
86
+ render = " ../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string (a) + " -e " + std::to_string (e) + " -o " + outputname + " " + inputname + " " + component;
87
+ break ;
88
+ case AMBIENT:
89
+ a = 45 , e = 45 ;
90
+ outputname += " _ambient.png" ;
91
+ render = " ../../../../../build/bin/rt -C 255/255/255 -s 1024 -c \" set ambSamples=64\" -o " + outputname + " " + inputname + " " + component;
92
+ break ;
93
+ }
94
+
95
+ std::ifstream file;
96
+ file.open (outputname);
97
+ if (file) {
98
+ std::string rmFile = " rm " + outputname;
99
+ auto result2 = system (rmFile.c_str ());
100
+ }
101
+ file.close ();
102
+
103
+ auto result2 = system (render.c_str ());
104
+ std::cout << " Successlly generated perspective rendering png file\n " ;
105
+ return outputname;
11
106
}
0 commit comments