mirror of
https://github.com/vonhyou/ray-tracer-comp371.git
synced 2025-08-14 01:28:02 +00:00
parse and write scene
This commit is contained in:
parent
03b6bbbb8e
commit
7d273f9420
3 changed files with 22 additions and 1 deletions
|
@ -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();
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue