mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-06-08 15:31:59 +00:00
implement alpha 1
This commit is contained in:
parent
099e762b40
commit
550bf180ba
2 changed files with 33 additions and 2 deletions
|
@ -1,5 +1,33 @@
|
|||
#include "RayTracer.h"
|
||||
#include "../external/simpleppm.h"
|
||||
|
||||
RayTracer::RayTracer(nlohmann::json scene) {}
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
void RayTracer::run() {}
|
||||
RayTracer::RayTracer(nlohmann::json scene) : scene(scene) {}
|
||||
|
||||
void RayTracer::run() {
|
||||
std::string filename;
|
||||
int sizeX = -1, sizeY = -1;
|
||||
for (auto itr = scene["output"].begin(); itr != scene["output"].end();
|
||||
++itr) {
|
||||
|
||||
if (itr->contains("filename")) {
|
||||
filename = (*itr)["filename"].get<std::string>();
|
||||
|
||||
std::cout << filename << std::endl;
|
||||
}
|
||||
|
||||
if (itr->contains("size")) {
|
||||
sizeX = (*itr)["size"].begin()->get<int>();
|
||||
sizeY = ((*itr)["size"].begin() + 1)->get<int>();
|
||||
|
||||
std::cout << sizeX << " " << sizeY << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<double> buffer(3 * sizeX * sizeY);
|
||||
|
||||
save_ppm(filename, buffer, sizeX, sizeY);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,9 @@ class RayTracer {
|
|||
public:
|
||||
RayTracer(nlohmann::json);
|
||||
void run();
|
||||
|
||||
private:
|
||||
nlohmann::json scene;
|
||||
};
|
||||
|
||||
#endif // !RAY_TRACER_H_
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue