diff --git a/.DS_Store b/.DS_Store index b52972d3bc9..06650c1f644 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/output/moss_ambient.png b/output/moss_ambient.png new file mode 100644 index 00000000000..334ada9dc14 Binary files /dev/null and b/output/moss_ambient.png differ diff --git a/output/moss_front.png b/output/moss_front.png new file mode 100644 index 00000000000..85ad3477356 Binary files /dev/null and b/output/moss_front.png differ diff --git a/output/moss_right.png b/output/moss_right.png new file mode 100644 index 00000000000..ac2f3dc08cf Binary files /dev/null and b/output/moss_right.png differ diff --git a/output/moss_top.png b/output/moss_top.png new file mode 100644 index 00000000000..f72a5435058 Binary files /dev/null and b/output/moss_top.png differ diff --git a/src/PerspectiveGatherer.cpp b/src/PerspectiveGatherer.cpp index cedba417a94..aac9862d9c0 100644 --- a/src/PerspectiveGatherer.cpp +++ b/src/PerspectiveGatherer.cpp @@ -1,11 +1,106 @@ #include "PerspectiveGatherer.h" -std::string renderAmbientOcclusion() -{ - return ""; -} +// std::string renderAmbientOcclusion() +// { +// // hardcode filename until options come out +// std::string component = "all.g"; +// std::string pathToInput = "../db/"; +// std::string fileInput = "moss.g"; +// std::string pathToOutput = "../output/"; +// std::string fileOutput = "moss.png"; +// std::cout << "Processing file: " << fileInput << std::endl; + +// // FIX security vulnerability +// std::string inputname = pathToInput + fileInput; +// std::string outputname = pathToOutput + fileOutput; + +// std::ifstream file; +// file.open(outputname); +// if (file) { +// std::string rmFile = "rm " + outputname; +// auto result2 = system(rmFile.c_str()); +// } +// file.close(); +// // TODO Need to somehow decide what to render if there are multiple components. +// // Maybe let user choose which one to render e.g. pass in all.g? + +// // EX: ../../../../../build/bin/rt -C 255/255/255 -s 1024 -c "set ambSamples=64" ../db/moss.g all.g +// std::string render = "../../../../../build/bin/rt -C 255/255/255 -s 1024 -c \"set ambSamples=64\" -o " + outputname + " " + inputname + " " + component; +// auto result2 = system(render.c_str()); +// std::cout << "Successlly generated ambient occlusion file\n"; +// return outputname; +// } std::string renderPerspective(RenderingFace face) { - return ""; + // hardcode filename until options come out + std::string component = "all.g"; + std::string pathToInput = "../db/"; + std::string fileInput = "moss.g"; + std::string pathToOutput = "../output/"; + std::string fileOutput = "moss"; + + // do directory traversal checks + if (fileOutput.find("../") != std::string::npos) { + std::cout << "ERROR: Output file name cannot contain ../\n"; + return ""; + } + + std::cout << "Processing file: " << fileInput << std::endl; + + // FIX security vulnerability + std::string inputname = pathToInput + fileInput; + std::string outputname = pathToOutput + fileOutput; + std::string render; + + int a, e; + switch (face) { + case FRONT: + a = 0, e = 0; + outputname += "_front.png"; + render = "../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string(a) + " -e " + std::to_string(e) + " -o " + outputname + " " + inputname + " " + component; + break; + case RIGHT: + a = 90, e = 0; + outputname += "_right.png"; + render = "../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string(a) + " -e " + std::to_string(e) + " -o " + outputname + " " + inputname + " " + component; + break; + case BACK: + a = 180, e = 0; + outputname += "_back.png"; + render = "../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string(a) + " -e " + std::to_string(e) + " -o " + outputname + " " + inputname + " " + component; + break; + case LEFT: + a = 270, e = 0; + outputname += "_left.png"; + render = "../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string(a) + " -e " + std::to_string(e) + " -o " + outputname + " " + inputname + " " + component; + break; + case TOP: + a = 0, e = 90; // may need to change "a"? + outputname += "_top.png"; + render = "../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string(a) + " -e " + std::to_string(e) + " -o " + outputname + " " + inputname + " " + component; + break; + case BOTTOM: + a = 0, e = 270; + outputname += "_bottom.png"; + render = "../../../../../build/bin/rtedge -s 1024 -W -R -a " + std::to_string(a) + " -e " + std::to_string(e) + " -o " + outputname + " " + inputname + " " + component; + break; + case AMBIENT: + a = 45, e = 45; + outputname += "_ambient.png"; + render = "../../../../../build/bin/rt -C 255/255/255 -s 1024 -c \"set ambSamples=64\" -o " + outputname + " " + inputname + " " + component; + break; + } + + std::ifstream file; + file.open(outputname); + if (file) { + std::string rmFile = "rm " + outputname; + auto result2 = system(rmFile.c_str()); + } + file.close(); + + auto result2 = system(render.c_str()); + std::cout << "Successlly generated perspective rendering png file\n"; + return outputname; } \ No newline at end of file diff --git a/src/PerspectiveGatherer.h b/src/PerspectiveGatherer.h index ef3e9cc850b..3dca21bf7d9 100644 --- a/src/PerspectiveGatherer.h +++ b/src/PerspectiveGatherer.h @@ -16,7 +16,8 @@ enum RenderingFace RIGHT, LEFT, BACK, - BOTTOM + BOTTOM, + AMBIENT }; // TODO: add correct parameters and return type diff --git a/src/RenderHandler.cpp b/src/RenderHandler.cpp index 9496c38af06..3f35a4645ef 100644 --- a/src/RenderHandler.cpp +++ b/src/RenderHandler.cpp @@ -2,7 +2,11 @@ void makeRenderSection(IFPainter& img, InformationGatherer& info, int offsetX, int offsetY, int width, int height) { - + // std::string ambOccImg = renderAmbientOcclusion(); + std::string ambOccImg = renderPerspective(AMBIENT); + std::string frontImg = renderPerspective(FRONT); + std::string rightImg = renderPerspective(RIGHT); + std::string topImg = renderPerspective(TOP); } int selectLayout(int secWidth, int secHeight, int modelLength, int modelWidth, int modelHeight) diff --git a/src/a.out b/src/a.out index 35159d10be7..4cfcea064b2 100755 Binary files a/src/a.out and b/src/a.out differ diff --git a/src/pch.h b/src/pch.h index 4b67122eae9..84dc22a11c3 100644 --- a/src/pch.h +++ b/src/pch.h @@ -9,6 +9,7 @@ #include #include #include +#include // Visualization project header files #include "Options.h"