parse and write scene

This commit is contained in:
Shuo Feng 2024-02-13 23:45:29 -05:00
parent 03b6bbbb8e
commit 7d273f9420
Signed by: sfeng
GPG key ID: 1E83AE6CD1C037B1
3 changed files with 22 additions and 1 deletions

View file

@ -1,6 +1,11 @@
#include "RayTracer.h" #include "RayTracer.h"
#include "../external/simpleppm.h"
#include "Parser.h" #include "Parser.h"
#include <vector>
using std::vector;
void RayTracer::parse() { void RayTracer::parse() {
for (auto i = json["output"].begin(); i != json["output"].end(); ++i) for (auto i = json["output"].begin(); i != json["output"].end(); ++i)
scenes.push_back(Parser::getScene(*i)); scenes.push_back(Parser::getScene(*i));
@ -8,7 +13,14 @@ void RayTracer::parse() {
void RayTracer::render() {} void RayTracer::render() {}
void RayTracer::output() {} void RayTracer::output() {
for (auto scene : scenes) {
int width = scene->getWidth();
int height = scene->getHeight();
vector<double> buffer(3 * width * height);
save_ppm("build/" + scene->getName(), buffer, width, height);
}
}
void RayTracer::run() { void RayTracer::run() {
parse(); parse();

View file

@ -1,5 +1,11 @@
#include "Scene.h" #include "Scene.h"
string Scene::getName() { return name; }
int Scene::getWidth() { return width; }
int Scene::getHeight() { return height; }
void Scene::setRaysPerPixel(const Eigen::VectorXi &raysPerPixel) { void Scene::setRaysPerPixel(const Eigen::VectorXi &raysPerPixel) {
this->raysPerPixel = raysPerPixel; this->raysPerPixel = raysPerPixel;
} }

View file

@ -32,6 +32,9 @@ private:
bool globalIllum = false; bool globalIllum = false;
public: public:
string getName();
int getWidth();
int getHeight();
void setRaysPerPixel(const Eigen::VectorXi &); void setRaysPerPixel(const Eigen::VectorXi &);
void setAntialiasing(bool); void setAntialiasing(bool);
void setTwoSideRender(bool); void setTwoSideRender(bool);